Open AceHack opened 4 years ago
@AceHack You can achieve what you're trying to do by defining an ignore file.
For example:
cat > .openapi-generator-java-sources.ignore <<EOF
*
**/*
!**/src/main/java/**/*
EOF
Then, in your task add this:
ignoreFileOverride.set(".openapi-generator-java-sources.ignore")
You can name the ignore file whatever you want, and put it under any directory you want. The patterns work the same as gitignore (although rather than ignoring committed files you're ignoring generated files). The big differences is that patterns are relative to your generated directory only, and we don't support the ignore file in nested directories (that is, we don't traverse directories and merge like gitignore does).
Let me know if that works for you.
Having the same problem and it almost works with this ignore patterns but not quite yet. (see image)
Same with me @mmoehring.
As a nice to have, would be cool for IntelliJ to pickup generated folder automatically, like when using Mapstruct. I think is because they use "annotationProcessor". e.g:
dependencies {
compileOnly("org.mapstruct:mapstruct")
annotationProcessor("org.mapstruct:mapstruct-processor")
}
compileJava {
options.compilerArgs = [
"-Amapstruct.defaultComponentModel=spring",
"-Amapstruct.suppressGeneratorTimestamp=true",
"-Amapstruct.suppressGeneratorVersionInfoComment=true",
"-Amapstruct.unmappedTargetPolicy=ERROR"
]
}
To have a similar layout as mapstruct I did:
openApiGenerate {
generatorName = "java"
library = "jersey2"
inputSpec = "...".toString()
outputDir = "$buildDir/generated/sources/openapi".toString()
ignoreFileOverride = file("$rootDir/.openapi-generator-java-sources.ignore").toString()
configOptions = [
dateLibrary: "java8",
sourceFolder: "java/main"
]
}
compileJava.dependsOn tasks.openApiGenerate
sourceSets {
main {
java {
srcDir new File(buildDir, "/generated/sources/openapi/java/main")
}
}
}
An I have to run on command line so the sources are generated as IntelliJ doesn't seem to execute the openApiGenerate task.
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