I get "Invalid source release: 17" as an error!
Use Java 17. Open up File > Project Structure
and change your SDK to Java 17.
If you still get the issue, you may need to go into File > Settings > Build, Execution, Deployment > Build Tools > Gradle
and change the Java that Gradle uses too.
This template is available under the CC0 license. Feel free to learn from it and incorporate it in your own projects.