Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !14925

[Java][webclient/resttemplate] fix dependencies for gradle with jakarta enabled

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/ChristianMoesl/fix-gradle-build-with-jakarta into master 2 years ago
  • Overview 9
  • Commits 1
  • Pipelines 0
  • Changes 12

Created by: ChristianMoesl

This PR fixes build errors, because of wrong dependencies in the gradle build templates for java clients with spring dependencies (webclient & resttemplate) and useJakartaEe enabled.

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

cd samples/client/petstore/java/webclient-jakarta
chmod +x gradlew && gradle clean build

It will result in build errors like these: image

What was done:

  • remove swagger dependency, if it isn't in use
  • use jakarta >= 2.0 if useJakartaEe is enabled (only jakarta 2.0 and above exposes annotations in jakarta.annotations.* namespace)
  • use spring boot 3 and spring 6 for jakarta support
  • added a Gradle build step to CI

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 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    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*. For Windows users, please run the script in Git BASH.
  • In case you are adding a new generator, run the following additional script :
    ./bin/utils/ensure-up-to-date.sh
    Commit all changed files.
  • File the PR against the correct branch: master (6.3.0) (minor release - breaking changes with fallbacks), 7.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.
Compare
  • master (base)

and
  • latest version
    3d032617
    1 commit, 2 years ago

12 files
+ 105
- 69

    Preferences

    File browser
    Compare changes
.github/‎workflows‎
samples-java-cl‎ient-jdk17.yaml‎ +4 -1
modules/…/…/…‎/…/…/libraries‎
restte‎mplate‎
build.grad‎le.mustache‎ +25 -3
webc‎lient‎
build.grad‎le.mustache‎ +33 -7
samples/client‎/petstore/java‎
restte‎mplate‎
build.‎gradle‎ +3 -5
resttempla‎te-jakarta‎
build.‎gradle‎ +8 -10
gra‎dlew‎ +0 -0
resttempla‎te-swagger1‎
build.‎gradle‎ +3 -3
resttempla‎te-withXml‎
build.‎gradle‎ +3 -5
webc‎lient‎
build.‎gradle‎ +7 -10
webclien‎t-jakarta‎
build.‎gradle‎ +12 -15
gra‎dlew‎ +0 -0
webclient-nu‎llable-arrays‎
build.‎gradle‎ +7 -10
.github/workflows/samples-java-client-jdk17.yaml
+ 4
- 1
  • View file @ 3d032617

  • Edit in single-file editor

  • Open in Web IDE


@@ -34,6 +34,9 @@ jobs:
path: |
~/.m2
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
- name: Build
- name: Build with Maven
working-directory: ${{ matrix.sample }}
run: mvn clean package
- name: Build with Gradle
working-directory: ${{ matrix.sample }}
run: gradle clean build
modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/build.gradle.mustache
+ 25
- 3
  • View file @ 3d032617

  • Edit in single-file editor

  • Open in Web IDE


@@ -32,8 +32,14 @@ if(hasProperty('target') && target == 'android') {
targetSdkVersion 22
}
compileOptions {
{{#useJakartaEe}}
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
{{/useJakartaEe}}
{{^useJakartaEe}}
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
{{/useJakartaEe}}
}
// Rename the aar correctly
@@ -66,7 +72,7 @@ if(hasProperty('target') && target == 'android') {
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
archiveClassifier = 'sources'
}
artifacts {
@@ -78,8 +84,14 @@ if(hasProperty('target') && target == 'android') {
apply plugin: 'java'
apply plugin: 'maven-publish'
{{#useJakartaEe}}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
{{/useJakartaEe}}
{{^useJakartaEe}}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
{{/useJakartaEe}}
publishing {
publications {
@@ -91,26 +103,36 @@ if(hasProperty('target') && target == 'android') {
}
task execute(type:JavaExec) {
main = System.getProperty('mainClass')
mainClass = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
}
ext {
{{#swagger1AnnotationLibrary}}
swagger_annotations_version = "1.6.9"
{{/swagger1AnnotationLibrary}}
jackson_version = "2.14.1"
jackson_databind_version = "2.14.1"
{{#openApiNullable}}
jackson_databind_nullable_version = "0.2.6"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
{{#useJakartaEe}}
spring_web_version = "6.0.3"
jakarta_annotation_version = "2.1.1"
{{/useJakartaEe}}
{{^useJakartaEe}}
spring_web_version = "5.3.24"
jakarta_annotation_version = "1.3.5"
{{/useJakartaEe}}
jodatime_version = "2.9.9"
junit_version = "4.13.2"
}
dependencies {
{{#swagger1AnnotationLibrary}}
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
{{/swagger1AnnotationLibrary}}
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation "org.springframework:spring-web:$spring_web_version"
implementation "org.springframework:spring-context:$spring_web_version"
modules/openapi-generator/src/main/resources/Java/libraries/webclient/build.gradle.mustache
+ 33
- 7
  • View file @ 3d032617

  • Edit in single-file editor

  • Open in Web IDE


@@ -32,8 +32,14 @@ if(hasProperty('target') && target == 'android') {
}
compileOptions {
{{#useJakartaEe}}
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
{{/useJakartaEe}}
{{^useJakartaEe}}
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
{{/useJakartaEe}}
}
// Rename the aar correctly
@@ -66,7 +72,7 @@ if(hasProperty('target') && target == 'android') {
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
archiveClassifier = 'sources'
}
artifacts {
@@ -78,8 +84,14 @@ if(hasProperty('target') && target == 'android') {
apply plugin: 'java'
apply plugin: 'maven-publish'
{{#useJakartaEe}}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
{{/useJakartaEe}}
{{^useJakartaEe}}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
{{/useJakartaEe}}
publishing {
publications {
@@ -91,17 +103,17 @@ if(hasProperty('target') && target == 'android') {
}
task execute(type:JavaExec) {
main = System.getProperty('mainClass')
mainClass = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
archiveClassifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}
@@ -112,22 +124,36 @@ if(hasProperty('target') && target == 'android') {
}
ext {
{{#swagger1AnnotationLibrary}}
swagger_annotations_version = "1.6.3"
{{/swagger1AnnotationLibrary}}
{{#useJakartaEe}}
spring_boot_version = "3.0.1"
jakarta_annotation_version = "2.1.1"
reactor_version = "3.5.1"
reactor_netty_version = "1.1.1"
{{/useJakartaEe}}
{{^useJakartaEe}}
spring_boot_version = "2.6.6"
jakarta_annotation_version = "1.3.5"
reactor_version = "3.4.3"
reactor_netty_version = "1.0.4"
{{/useJakartaEe}}
jackson_version = "2.13.4"
jackson_databind_version = "2.13.4.2"
{{#openApiNullable}}
jackson_databind_nullable_version = "0.2.6"
{{/openApiNullable}}
jakarta_annotation_version = "1.3.5"
reactor_version = "3.4.3"
reactor_netty_version = "1.0.4"
{{#joda}}
jodatime_version = "2.9.9"
{{/joda}}
junit_version = "4.13.2"
}
dependencies {
{{#swagger1AnnotationLibrary}}
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
{{/swagger1AnnotationLibrary}}
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation "io.projectreactor:reactor-core:$reactor_version"
implementation "org.springframework.boot:spring-boot-starter-webflux:$spring_boot_version"
samples/client/petstore/java/resttemplate/build.gradle
+ 3
- 5
  • View file @ 3d032617

  • Edit in single-file editor

  • Open in Web IDE


@@ -66,7 +66,7 @@ if(hasProperty('target') && target == 'android') {
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
archiveClassifier = 'sources'
}
artifacts {
@@ -91,24 +91,22 @@ if(hasProperty('target') && target == 'android') {
}
task execute(type:JavaExec) {
main = System.getProperty('mainClass')
mainClass = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
}
ext {
swagger_annotations_version = "1.6.9"
jackson_version = "2.14.1"
jackson_databind_version = "2.14.1"
jackson_databind_nullable_version = "0.2.6"
jakarta_annotation_version = "1.3.5"
spring_web_version = "5.3.24"
jakarta_annotation_version = "1.3.5"
jodatime_version = "2.9.9"
junit_version = "4.13.2"
}
dependencies {
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation "org.springframework:spring-web:$spring_web_version"
implementation "org.springframework:spring-context:$spring_web_version"
samples/client/petstore/java/resttemplate-jakarta/build.gradle
+ 8
- 10
  • View file @ 3d032617

  • Edit in single-file editor

  • Open in Web IDE


@@ -32,8 +32,8 @@ if(hasProperty('target') && target == 'android') {
targetSdkVersion 22
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
// Rename the aar correctly
@@ -66,7 +66,7 @@ if(hasProperty('target') && target == 'android') {
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
archiveClassifier = 'sources'
}
artifacts {
@@ -78,8 +78,8 @@ if(hasProperty('target') && target == 'android') {
apply plugin: 'java'
apply plugin: 'maven-publish'
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
publishing {
publications {
@@ -91,24 +91,22 @@ if(hasProperty('target') && target == 'android') {
}
task execute(type:JavaExec) {
main = System.getProperty('mainClass')
mainClass = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
}
ext {
swagger_annotations_version = "1.6.9"
jackson_version = "2.14.1"
jackson_databind_version = "2.14.1"
jackson_databind_nullable_version = "0.2.6"
jakarta_annotation_version = "1.3.5"
spring_web_version = "5.3.24"
spring_web_version = "6.0.3"
jakarta_annotation_version = "2.1.1"
jodatime_version = "2.9.9"
junit_version = "4.13.2"
}
dependencies {
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation "org.springframework:spring-web:$spring_web_version"
implementation "org.springframework:spring-context:$spring_web_version"
0 Assignees
None
Assign to
Reviewer
Oleh Kurpiak's avatar
Oleh Kurpiak
Request review from
Labels
2
Client: Java Issue: Bug
2
Client: Java Issue: Bug
    Assign labels
  • Manage project labels

Milestone
6.5.0
6.5.0 (expired)
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
3
3 participants
Oleh Kurpiak
Administrator
Jim Schubert
Reference: OpenAPITools/openapi-generator!14925
Source branch: github/fork/ChristianMoesl/fix-gradle-build-with-jakarta

Menu

Explore Projects Groups Snippets