'Gradle: Resolve annotation processor circular dependency when generating only resource files
I am creating an annotation processor based on therapi scribe to add Javadoc JSONs for each class in all project modules to its module's JAR, without requiring any classes to be annotated. As part of the JSON creation step, I am using an existing data model defined in another module (and cannot be moved) in my project to construct and serialize the JSON, which I also want to use at runtime. However, as I wish to create Javadoc JSONs for this same data model class, I can't add the second module as a dependency without creating a cycle. My current (simplified) gradle config with said cycle is as follows:
Data Model module (':javadoc-model') + other misc. modules to be documented:
dependencies {
annotationProcessor project(':javadoc-annotationprocessor')
}
Annotation Processor module (':javadoc-annotationprocessor'):
dependencies {
api project(':javadoc-model')
}
That all being said, since my annotation processor only creates resource files (that are not referenced elsewhere during the build process), the actual "dependence" of the data model module on the annotation processor does not include any changes to the classes defined in the model module. Is there is a way to specify that this annotation processor does not affect the actual class output, or to possibly specify an order of compilation such that javadoc-model is compiled, used by the javadoc-annotationprocessor module, and then the annotation processor is run on the javadoc-model module?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
