You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] [Java] Generated build.gradle incompatible with Gradle v9.x and Java 17+ #22084
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Using Gradle 9.x, the generated build.gradle file does not work. When running any task on this build.gradle file, the following error is reported:
FAILURE: Build failed with an exception.
* Where:
Build file '/tmp/openapi-generator/modules/openapi-generator-gradle-plugin/samples/local-spec/build/java-resttemplate-api-client/build.gradle' line: 81
* What went wrong:
A problem occurred evaluating root project 'client'.
> Could not set unknown property 'sourceCompatibility' for root project 'client' of type org.gradle.api.Project.
The build.gradle.mustache template does use deprecated and with Gradle 9 invalid syntax:
@wing328 concerning the Java compatibility, is Java 17 as the target version in the generated build.gradle file ok?
I see that the project itself uses Java 11. I guess creating Java 17 sources would break some integration test which uses Java 11?
I saw a couple of templates already using Java17, so it should be fine to add this to all.
The existing templates using Java17 also use the flag java17 to conditionally set which Java version to use, e.g. here in src/main/resources/Java/libraries/webclient/build.gradle.mustache:
Activity
wing328 commentedon Oct 6, 2025
can you please file a PR with the suggested change when you've time? 🙏
HenningWaack commentedon Oct 7, 2025
@wing328 concerning the Java compatibility, is Java 17 as the target version in the generated build.gradle file ok?
I see that the project itself uses Java 11. I guess creating Java 17 sources would break some integration test which uses Java 11?I saw a couple of templates already using Java17, so it should be fine to add this to all.
The existing templates using Java17 also use the flag
java17to conditionally set which Java version to use, e.g. here insrc/main/resources/Java/libraries/webclient/build.gradle.mustache:I would use this in a similar way in the other templates, too.
wing328 commentedon Oct 8, 2025
yes
the project itself usually targets a lower version (even though already reached EOL) to keep more users happy
for auto-generated java code, it's ok to default o jdk 17 to start with.
TheMrMilchmann commentedon Oct 14, 2025
Note that there is also another problem with nullable properties that causes issues with Gradle 9. #22050 would solve this.
openapi-generator-cli is not compatible with Gradle 9.x
[Java] Fix generated build.gradle incompatible with Gradle 9 (OpenAPI…