Managing auto-generated code dependencies across multiple projects


(Damon Kohler) #1

I have multiple separate projects (i.e. not a single multi-project build) that depend on generated code. Many projects depend on the same generated code. So for each logical group of generated code, I generate it, compile it, install it to my local ivy repo, and declare external dependencies on it.

I’d like to remove the separate compile and install step for generated code. Instead, if the external dependency is not available, I’d like to generate, compile, and install it. Is there a straightforward way to accomplish this? I think I’m looking for some sort of hook into dependency resolution that would allow me to trigger the generated code installation step.

Are there any examples/plugins I could look at that may be doing something similar?


(Peter Niederwieser) #2

The straightforward way to accomplish this is to turn this into a single multi-project build. The other standard solution is to keep things as they are. In that case, upstream projects would typically be built and published by a CI server for consumption by downstream projects. If you aren’t happy with either solution, you’ll have to roll your own. As a starting point, check out ‘org.gradle.api.artifacts.Configuration’ and related classes.