Greetings. I’m using the org.openapi.generator Gradle Plugin to generate Java classes based on an OpenAPI input spec in YAML format. When the generator gets invoked, it will spit out the Java source files in a directory which I’ve configured to be ${project.rootDir}/generated.
I’ve set the compileJava task to depend on the task that generates the code since there is Java code that uses the generated code. So the first time I compile, the OpenAPI generator gets invoked and creates the Java source files according to the input spec. Then the regular Java compilation takes place. If I recompile, the generator will not be invoked. We have a project requirement that the generated Java source files must be checked into our repo. However, when I check the generated files into git, the next time I run ./gradlew build, the OpenAPI generator gets invoked again.
All I want to accomplish is that the OpenAPI generator task ONLY gets invoked if the input spec file has a newer timestamp than the output directory, or if the output directory doesn’t exist. I have looked into the documentation for Gradle Incremental Builds, etc., and have tried implementing a Gradle task to somehow do it, but haven’t been able to wrap my head around it. I wish is was as simple as in the good old Make days…
Any help with this is highly appreciated. Thanks.