Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make ref files changes invalidate cache when running GenerateSwaggerCode? #144

Closed
galargh opened this issue Feb 14, 2019 · 3 comments

Comments

@galargh
Copy link

galargh commented Feb 14, 2019

Question

I'm running GenerateSwaggerCode task on input yaml that contains multiple $refs. With such a setup, gradle doesn't pick up referenced files as input files for the task. Hence, it caches the task output and doesn't rerun the task on content changes in any of the referenced files.

What's the correct approach to both keep using gradle cache and rerun generation on ref changes?

As a workaround, I've added the directory which contains the referenced files as templateDir. So now my codegen task definition looks like that:

devCodegen {
  inputFile = file("${projectDir}/src/main/swagger/schema/api.yml")
    code {
      language = "java"
      outputDir = file("${buildDir}/swagger/codegen/api")
      additionalProperties = [...]
      wipeOutputDir = false
      templateDir = file("${projectDir}/src/main/swagger/schema")
    }
  }

Environment

Plugin version: 2.15.0
Swagger Codegen version: 2.2.3
Gradle version: 5.1.1
Java version: 8
OS: OSX

@galargh
Copy link
Author

galargh commented Feb 14, 2019

I think I got it. Specifying code.input.files seems to do the trick :)

devCodegen {
  inputFile = file("${projectDir}/src/main/swagger/schema/api.yml")
  code {
    input.files "${projectDir}/src/main/swagger/schema"
    language = "java"
    outputDir = file("${buildDir}/swagger/codegen/api")
    additionalProperties = [...]
    wipeOutputDir = false
  }
}

@galargh galargh closed this as completed Feb 14, 2019
@anascotti
Copy link

input.files is not recognized by GenerateSwaggerCode task

> Could not get unknown property 'input' for task ':acquiring-core:generateSwaggerCode' of type org.hidetake.gradle.swagger.generator.GenerateSwaggerCode.
Plugin version: 2.18.2
Swagger Codegen version: 2.4.18
Gradle version: 6.8.3

@galargh
Copy link
Author

galargh commented Mar 31, 2021

input.files is not recognized by GenerateSwaggerCode task

> Could not get unknown property 'input' for task ':acquiring-core:generateSwaggerCode' of type org.hidetake.gradle.swagger.generator.GenerateSwaggerCode.
Plugin version: 2.18.2
Swagger Codegen version: 2.4.18
Gradle version: 6.8.3

@anascotti I probably missed a trailing s in my workaround. You can try inputs.files instead. Because it's getInputs on DefaultTask, not getInput (https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html#getInputs--).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants