Skip to content

[Java][RestTemplate] Gradle Build include non-compatible Spring Dependency with jakarta disabled #21426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

steven-blakowski
Copy link
Contributor

Summary

The generator for RestTemplate include the Spring dependencies with version 6.x.x for gradle in case of JakartaEE=false. However, this version require at least JDK17+, whereas the latest compatible dependency for Spring is version 5.x.x and also compatible with JDK 8 or 11.

openapi-generator version

  • openapi-generator-cli 7.13.0
  • latest master version

Steps to reproduce

This error can be reproduced quite easily on master branch with the following commands:

cd samples/client/petstore/java/resttemplate
./gradlew clean build

Output:

* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not resolve org.springframework:spring-web:6.2.8.
     Required by:
         project :
      > No matching variant of org.springframework:spring-web:6.2.8 was found. The consumer was configured to find a library for use during compile-time, compatible with Java 8, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally but:
          - Variant 'apiElements' declares a library for use during compile-time, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8
          - Variant 'runtimeElements' declares a library for use during runtime, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8

Related issues/PRs

A similar issue with the dependencies was reported by #14925

Implementation hint

While trying to integrate gradle additionally into the Samples Java Client JDK11 Job, several further permissions and dependency issues occurred.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328
Copy link
Member

wing328 commented Jun 18, 2025

https://github.com/OpenAPITools/openapi-generator/actions/runs/15716990742/job/44319517775?pr=21426

thanks for the pr

let me know if you need help updating the samples

@steven-blakowski
Copy link
Contributor Author

Thanks for the hint. The samples are updated.

@wing328 wing328 merged commit cef971c into OpenAPITools:master Jun 19, 2025
159 checks passed
@wing328
Copy link
Member

wing328 commented Jun 19, 2025

thanks for the fix, which has been merged into master and will be included in the upcoming v7.14.0 release (due today)

@steven-blakowski steven-blakowski deleted the fix-resttemplate-without-jakartaee branch June 22, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants