gradle-swagger-generator-plugin icon indicating copy to clipboard operation
gradle-swagger-generator-plugin copied to clipboard

Boilerplate should be done by the plugin, not by the user

Open asarkar opened this issue 6 years ago • 2 comments

Using the plugin requires the following boilerplate set up:

compileJava.dependsOn swaggerSources.wiremock.code
sourceSets.main.java.srcDir "${swaggerSources.wiremock.code.outputDir}/src/main/java"
sourceSets.main.resources.srcDir "${swaggerSources.wiremock.code.outputDir}/src/main/resources"

idea {
    module {
        sourceDirs += file("${swaggerSources.wiremock.code.outputDir}/src/main/java")
        sourceDirs += file("${swaggerSources.wiremock.code.outputDir}/src/main/resources")
        generatedSourceDirs += file("${swaggerSources.wiremock.code.outputDir}")
    }
}

A good-natured Gradle plugin should do the above in the plugin code. See this discussion in the Gradle forum on a similar issue.

Environment

Plugin version: 2.15.1 Swagger Codegen version: 2.3.1 Gradle version: 4.10.2

asarkar avatar Dec 20 '18 02:12 asarkar

For my uses, I found it better to keep the generated builds as totally seperate gradle builds and add the following:

task buildJavaSwagger( type: GradleBuild ,dependsOn: generateSwaggerCodeJavaSource) {
  group 'build'
  inputs.files generateSwaggerCodeJavaSource.outputs.files
  dir = file("${generatedDir}/java")
  tasks = ["build"]
}

DALDEI avatar Jan 09 '19 16:01 DALDEI

Hi @int128, could share some workaround or fix for it, please?

rmarinsky avatar Jul 18 '19 07:07 rmarinsky