OpenAPITools / OpenAPITools/openapi-generator
[REQ] Allow generating only src/main/java in gradle plugin
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
When using the gradle plugin instead of creating a whole new project for java clients, I would rather just have the code generated as a precompile step and added to the classpath like https://github.com/joelittlejohn/jsonschema2pojo handles code generation.
Describe the solution you'd like
Ability to only generate the code classes in src/main/java for java clients and then the generated classes be auto referenced in the existing gradle project that's dong the code generation.
Describe alternatives you've considered
This is able as close as I've been able to come to accomplishing that with the current plugin, but it still generates a ton of extra needed stuff like the gradle project, gradle wrapper, and a bunch of other things. I would really like to be able to generate just the source code.
in build.gradle.kts
val openApiGeneratedDir = "${project.buildDir}/generated/sources/openApi"
tasks.compileJava {
dependsOn(tasks.openApiGenerate)
}
sourceSets.main {
java.srcDir(openApiGeneratedDir)
}
openApiGenerate {
inputSpec.set("https://xxx.yyy.zzz")
validateSpec.set(true)
generatorName.set("java")
engine.set("mustache")
skipOverwrite.set(false)
outputDir.set(openApiGeneratedDir)
apiPackage.set("datalake.subscription.api")
invokerPackage.set("datalake.subscription.invoker")
modelPackage.set("datalake.subscription.model")
generateApiTests.set(false)
generateApiDocumentation.set(false)
generateModelTests.set(false)
generateModelDocumentation.set(false)
configOptions.set(mapOf(
"java8" to "true",
"dateLibrary" to "java8",
"library" to "native",
"asyncNative" to "true",
"serializationLibrary" to "jackson"
))
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
Start with the Gradle plugin configuration shown in build.gradle.kts and trace how openApiGenerate handles outputDir and generated project files. Define done as generating Java client source classes for an existing Gradle project without wrapper or other project artifacts, with those classes available through the existing source set.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100