OpenAPITools / OpenAPITools/openapi-generator
Gradle plugin does not generate working gradle build for java generator with rest-assured library
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
Using gradle open api generator to generate java client code using the rest-assured library.
The generated pom (maven build) is ok, but the generated gradle build (build.gradle) is missing a dependency version, the : jakarta_annotation_version
So running the generated gradle build, e.g: ./gradlew build fails
pom extract which works fine:
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${jakarta-annotation-version}</version>
<scope>provided</scope>
</dependency>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
build.gradle extract :
dependencies {
implementation "io.swagger:swagger-annotations:$swagger_annotations_version"
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation "io.rest-assured:rest-assured:$rest_assured_version"
implementation "io.gsonfire:gson-fire:$gson_fire_version"
implementation 'com.google.code.gson:gson:$gson_version'
implementation "com.squareup.okio:okio:$okio_version"
implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version"
testImplementation "junit:junit:$junit_version"
}
but the ext does not contain any jakarta version and looks like:
ext {
swagger_annotations_version = "1.6.6"
rest_assured_version = "4.5.1"
junit_version = "4.13.2"
gson_version = "2.8.9"
gson_fire_version = "1.8.5"
okio_version = "1.17.5"
}
So gradle build fails with
./gradlew compile
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/jonas.bryllert/jonas/work/projects/message-template-service/build/generated/openapiclient/build.gradle' line: 115
* What went wrong:
A problem occurred evaluating root project 'message-template-openapi-restassured-client'.
> Could not get unknown property 'jakarta_annotation_version' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
openapi-generator version
Gradle plugin:
id("org.openapi.generator") version "6.0.0"
OpenAPI declaration file content or url
Command line used for generation
Using the gradle plugin as above. Here is the snippet from the gradle build that creates the task for building the java openapi client:
tasks.register<org.openapitools.generator.gradle.plugin.tasks.GenerateTask>("generateOpenApiClientSource") {
inputSpec.set(apiSpec)
generatorName.set("java")
outputDir.set(generatedClientSourcesDir)
groupId.set("xxxxxx")
id.set("xxxxxx-openapi-restassured-client")
version.set("$gitVersion")
packageName.set("xxxxxx.openapi.client")
apiPackage.set("xxxxxx.openapi.client.api")
modelPackage.set("xxxxxx.openapi.client.model")
library.set("rest-assured")
}
Steps to reproduce
Use any sample openapi yaml file
Related issues/PRs
Suggest a fix/enhancement
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Compare the generated build.gradle dependency declarations with the working generated pom, focusing on the missing jakarta_annotation_version entry. Reproduce the failure with ./gradlew build or ./gradlew compile; done means the generated Gradle project defines the Jakarta annotation version and builds successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100