Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/samples-java-client-jdk17.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ jobs:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-${{ github.job }}-${{ env.cache-name }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}

- name: Build
- name: Build with Gradle
working-directory: ${{ matrix.sample }}
# the microprofile library does not generate a Gradle build; skip samples without a wrapper
if: ${{ hashFiles(format('{0}/gradlew', matrix.sample)) != '' }}
run: /bin/sh gradlew build -x test --no-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,15 @@ public void processOpts() {
String pomTemplate = mpRestClientVersions.get(microprofileRestClientVersion).pomTemplate;
supportingFiles.add(new SupportingFile(pomTemplate, "", "pom.xml"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("build.gradle.mustache", "", "build.gradle").doNotOverwrite());
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle").doNotOverwrite());
supportingFiles.add(new SupportingFile("gradle.properties.mustache", "", "gradle.properties").doNotOverwrite());
supportingFiles.add(new SupportingFile("gradlew.mustache", "", "gradlew"));
supportingFiles.add(new SupportingFile("gradlew.bat.mustache", "", "gradlew.bat"));
supportingFiles.add(new SupportingFile("gradle-wrapper.properties.mustache",
gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.properties"));
supportingFiles.add(new SupportingFile("gradle-wrapper.jar",
gradleWrapperPackage.replace(".", File.separator), "gradle-wrapper.jar"));
supportingFiles.add(new SupportingFile("api_exception.mustache", apiExceptionFolder, "ApiException.java"));
supportingFiles.add(new SupportingFile("api_exception_mapper.mustache", apiExceptionFolder, "ApiExceptionMapper.java"));
if (getSerializationLibrary() == null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'maven-publish'

group = '{{groupId}}'
version = '{{artifactVersion}}'

repositories {
mavenCentral()
}

{{#java17}}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
{{/java17}}
{{^java17}}
{{#microprofile3}}
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
{{/microprofile3}}
{{^microprofile3}}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
{{/microprofile3}}
{{/java17}}

publishing {
publications {
maven(MavenPublication) {
artifactId = '{{artifactId}}'
from components.java
}
}
}

task execute(type:JavaExec) {
mainClass = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}

task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives sourcesJar
archives javadocJar
}

ext {
microprofile_rest_client_api_version = "{{microprofileRestClientVersion}}"
{{#useBeanValidation}}
{{#microprofile3}}
beanvalidation_version = "3.0.1"
{{/microprofile3}}
{{^microprofile3}}
beanvalidation_version = "3.0.2"
{{/microprofile3}}
{{/useBeanValidation}}
{{#useBeanValidationFeature}}
hibernate_validator_version = "{{#microprofile3}}8.0.3.Final{{/microprofile3}}{{^microprofile3}}5.2.2.Final{{/microprofile3}}"
{{/useBeanValidationFeature}}
jackson_jaxrs_version = "2.17.1"
{{#jackson}}
jackson_version = "2.17.1"
{{/jackson}}
{{#microprofile3}}
jakarta_activation_version = "2.1.0"
jakarta_annotation_version = "2.0.0"
jakarta_json_bind_version = "3.0.0"
jakarta_json_version = "2.0.1"
jakarta_ws_rs_version = "3.0.0"
jakarta_xml_bind_version = "3.0.1"
jaxb_version = "3.0.2"
{{/microprofile3}}
{{^microprofile3}}
jakarta_activation_version = "1.2.2"
jakarta_annotation_version = "1.3.5"
jakarta_json_bind_version = "1.0.2"
jakarta_json_version = "1.1.6"
jakarta_ws_rs_version = "2.1.6"
jakarta_xml_bind_version = "2.3.3"
jaxb_version = "2.2.11"
{{/microprofile3}}
{{#microprofileMutiny}}
mutiny_version = "1.10.0"
{{/microprofileMutiny}}
{{#useReflectionEqualsHashCode}}
commons_lang3_version = "3.17.0"
{{/useReflectionEqualsHashCode}}
junit_version = "5.10.2"
}

dependencies {
// Eclipse MicroProfile Rest Client
implementation "org.eclipse.microprofile.rest.client:microprofile-rest-client-api:$microprofile_rest_client_api_version"

// JAX-RS
compileOnly "jakarta.ws.rs:jakarta.ws.rs-api:$jakarta_ws_rs_version"

compileOnly "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
{{#useBeanValidation}}
// Bean Validation API support
compileOnly "jakarta.validation:jakarta.validation-api:$beanvalidation_version"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: MicroProfile 1.x/2.0 clients with useBeanValidation=true fail compilation: generated sources import javax.validation, but this dependency resolves Bean Validation 3 under jakarta.validation. Select the javax Validation API for the non-microprofile3 branch.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/Java/libraries/microprofile/build.gradle.mustache, line 111:

<comment>MicroProfile 1.x/2.0 clients with `useBeanValidation=true` fail compilation: generated sources import `javax.validation`, but this dependency resolves Bean Validation 3 under `jakarta.validation`. Select the javax Validation API for the non-`microprofile3` branch.</comment>

<file context>
@@ -0,0 +1,149 @@
+    compileOnly "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
+    {{#useBeanValidation}}
+    // Bean Validation API support
+    compileOnly "jakarta.validation:jakarta.validation-api:$beanvalidation_version"
+    {{/useBeanValidation}}
+    {{#useBeanValidationFeature}}
</file context>

{{/useBeanValidation}}
{{#useBeanValidationFeature}}
implementation "org.hibernate{{#microprofile3}}.validator{{/microprofile3}}:hibernate-validator:$hibernate_validator_version"
{{/useBeanValidationFeature}}
{{#jsonb}}
implementation "jakarta.json.bind:jakarta.json.bind-api:$jakarta_json_bind_version"
implementation "jakarta.json:jakarta.json-api:$jakarta_json_version"
implementation "jakarta.xml.bind:jakarta.xml.bind-api:$jakarta_xml_bind_version"
implementation "com.sun.xml.bind:jaxb-core:$jaxb_version"
implementation "com.sun.xml.bind:jaxb-impl:$jaxb_version"
{{/jsonb}}
{{#jackson}}
// JSON processing: jackson
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
{{#withXml}}
// XML processing with Jackson
implementation "jakarta.xml.bind:jakarta.xml.bind-api:$jakarta_xml_bind_version"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-xml:$jackson_version"
{{/withXml}}
{{/jackson}}
implementation "jakarta.activation:jakarta.activation-api:$jakarta_activation_version"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_jaxrs_version"
{{#microprofileMutiny}}
implementation "io.smallrye.reactive:mutiny:$mutiny_version"
{{/microprofileMutiny}}
{{#useReflectionEqualsHashCode}}
// For equals and hashCode using reflection
implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
{{/useReflectionEqualsHashCode}}

testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Generated JUnit tests have no Jupiter engine at runtime, so Gradle cannot execute them under useJUnitPlatform(). Add junit-jupiter-engine to testRuntimeOnly, matching the shared Java build template.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/Java/libraries/microprofile/build.gradle.mustache, line 144:

<comment>Generated JUnit tests have no Jupiter engine at runtime, so Gradle cannot execute them under `useJUnitPlatform()`. Add `junit-jupiter-engine` to `testRuntimeOnly`, matching the shared Java build template.</comment>

<file context>
@@ -0,0 +1,149 @@
+    implementation "org.apache.commons:commons-lang3:$commons_lang3_version"
+    {{/useReflectionEqualsHashCode}}
+
+    testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
+}
+
</file context>
Suggested change
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"

}

test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
README.md
build.gradle
docs/CatRequest.md
docs/DefaultApi.md
docs/DogRequest.md
docs/PetBase.md
docs/PetRequest.md
docs/PetType.md
gradle.properties
gradle/wrapper/gradle-wrapper.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
pom.xml
settings.gradle
src/main/java/org/openapitools/client/RFC3339DateFormat.java
src/main/java/org/openapitools/client/RFC3339InstantDeserializer.java
src/main/java/org/openapitools/client/RFC3339JavaTimeModule.java
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'java'
apply plugin: 'maven-publish'

group = 'org.openapitools'
version = '1.0.0'

repositories {
mavenCentral()
}

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

publishing {
publications {
maven(MavenPublication) {
artifactId = 'microprofile-oneof-interface'
from components.java

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The Gradle artifact omits the Jandex index Maven builds produce, so Quarkus consumers will not automatically scan this dependency and DefaultApi will not be available for CDI rest-client injection. Configure equivalent Jandex indexing before packaging/publishing.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/java/microprofile-oneof-interface/build.gradle, line 20:

<comment>The Gradle artifact omits the Jandex index Maven builds produce, so Quarkus consumers will not automatically scan this dependency and `DefaultApi` will not be available for CDI rest-client injection. Configure equivalent Jandex indexing before packaging/publishing.</comment>

<file context>
@@ -0,0 +1,79 @@
+    publications {
+        maven(MavenPublication) {
+           artifactId = 'microprofile-oneof-interface'
+           from components.java
+        }
+    }
</file context>

}
}
}

task execute(type:JavaExec) {
mainClass = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}

task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
archiveClassifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives sourcesJar

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: publish will omit the source and Javadoc JARs: adding them to archives does not attach them to MavenPublication. Add source/Javadoc variants to the Java component or explicitly attach both artifacts to maven.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/java/microprofile-oneof-interface/build.gradle, line 41:

<comment>`publish` will omit the source and Javadoc JARs: adding them to `archives` does not attach them to `MavenPublication`. Add source/Javadoc variants to the Java component or explicitly attach both artifacts to `maven`.</comment>

<file context>
@@ -0,0 +1,79 @@
+}
+
+artifacts {
+    archives sourcesJar
+    archives javadocJar
+}
</file context>

archives javadocJar
}

ext {
microprofile_rest_client_api_version = "3.0"
jackson_jaxrs_version = "2.17.1"
jackson_version = "2.17.1"
jakarta_activation_version = "2.1.0"
jakarta_annotation_version = "2.0.0"
jakarta_json_bind_version = "3.0.0"
jakarta_json_version = "2.0.1"
jakarta_ws_rs_version = "3.0.0"
jakarta_xml_bind_version = "3.0.1"
jaxb_version = "3.0.2"
junit_version = "5.10.2"
}

dependencies {
// Eclipse MicroProfile Rest Client
implementation "org.eclipse.microprofile.rest.client:microprofile-rest-client-api:$microprofile_rest_client_api_version"

// JAX-RS
compileOnly "jakarta.ws.rs:jakarta.ws.rs-api:$jakarta_ws_rs_version"

compileOnly "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
// JSON processing: jackson
implementation "com.fasterxml.jackson.core:jackson-core:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-annotations:$jackson_version"
implementation "com.fasterxml.jackson.core:jackson-databind:$jackson_version"
implementation "jakarta.activation:jakarta.activation-api:$jakarta_activation_version"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_jaxrs_version"

testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: gradlew test will not execute the generated JUnit 5 tests because this declares only the API, not a Jupiter engine. Add the engine as a test runtime dependency, matching other Java Gradle samples.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/client/petstore/java/microprofile-oneof-interface/build.gradle, line 74:

<comment>`gradlew test` will not execute the generated JUnit 5 tests because this declares only the API, not a Jupiter engine. Add the engine as a test runtime dependency, matching other Java Gradle samples.</comment>

<file context>
@@ -0,0 +1,79 @@
+    implementation "jakarta.activation:jakarta.activation-api:$jakarta_activation_version"
+    implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jackson_jaxrs_version"
+
+    testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
+}
+
</file context>
Suggested change
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit_version"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junit_version"

}

test {
useJUnitPlatform()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator).
# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option.
#
# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
# For example, uncomment below to build for Android
#target = android
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading