Slackbot
08/05/2022, 8:59 PMJohn Bellini
08/05/2022, 9:08 PMprotocol
that generates the code and then have your rest-app
and service-client
depend on protocol
Ben Madore
08/05/2022, 9:38 PMVampire
08/05/2022, 10:30 PMVampire
08/05/2022, 10:31 PMBen Madore
08/05/2022, 10:49 PMNiels Doucet
08/06/2022, 6:24 PMBen Madore
08/09/2022, 1:06 AMapi-model
already publishes a bunch of classes, that would conflict with the classes generated into service-client
Vampire
08/09/2022, 7:37 AMBen Madore
08/09/2022, 3:09 PMBen Madore
08/22/2022, 3:52 PMsrc/main/resources/static/apispec/ApiSpec.yaml
build.gradle.kts
val apiSpec: Configuration by configurations.creating {
isCanBeResolved = false
isCanBeConsumed = true
}
artifacts {
// the build path resulting from (i assume) result of `processResources`
add("apiSpec", file("build/resources/main/static/apispec/ApiSpec.yaml"))
]
openApiGenerate {
inputSpec.set("src/main/resources/static/apispec/ApiSpec.yaml")
// configure code generation into project a ...
}
configure<SourceSetContainer> {
named("main") {
java.srcDir(openApiGenerate.outputDir.get())
}
}
tasks.withType<JavaCompile>().configureEach {
dependsOn(tasks.named("openApiGenerate"))
}
project b
(consumes ApiSpec from a
):
build.gradle.kts
val apiSpecConfiguration by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
}
dependencies {
apiSpecConfiguration(project(path=":a", configuration="apiSpec"))
}
val apiSpecFile = apiSpecConfiguration.incoming.artifacts.artifactFiles.singleFile
openApiGenerate {
inputSpec.set(apiSpecFile.absolutePath)
// configure code generation into project b ...
}
tasks.withType<JavaCompile>().configureEach {
dependsOn(tasks.named("openApiGenerate"))
}
on a clean build i now get:
* What went wrong:
A problem was found with the configuration of task ':b:openApiGenerate' (type 'GenerateTask').
- In plugin 'org.openapi.generator' type 'org.openapitools.generator.gradle.plugin.tasks.GenerateTask' property 'inputSpec' specifies file '/Users/me/projects/myproj/a/build/resources/main/static/apispec/ApiSpec.yaml' which doesn't exist.
Reason: An input file was expected to be present but it doesn't exist.
Possible solutions:
1. Make sure the file exists before the task is called.
2. Make sure that the task which produces the file is declared as an input.
what is the proper way to declare that consuming a
configuration apiSpec
depends on processResources
to copy the file into build? or should i just add the file from the src/
path into the artifact as that will always be present (there’s no post-processing)?Vampire
08/22/2022, 11:21 PMadd("apiSpec", file("build/resources/main/static/apispec/ApiSpec.yaml")) {
builtBy(tasks.processResources)
}
Or, as you said, just use the source path, that is also what you use to generate the code in a
so would probably be more consistent.Ben Madore
08/23/2022, 12:39 AMBen Madore
08/23/2022, 12:57 AMartifacts {
add("apiSpec", apiSpecFile) {
builtBy(tasks.processResources)
}
}
seems to work fine (though, not really reliant on processResources but 🤷 )Vampire
08/23/2022, 8:05 AMbuiltBy
.