In a multi-project build, I want project A to package up source for all the projects it depends on, into one big zip file. This is proving to be more difficult than I expected, so I think I’m doing something wrong. Here’s what I’ve done so far:
- I tried to find all the transitive project dependencies of this project using the configurations object, but I didn’t see that information collected in any one spot. I built a little recursive closure to calculate it from configurations.blah.allDependencies. 1. I tried a Zip task which built its own CopySpec dynamically, from the collected transitive dependencies. But dependencies aren’t resolved while the task is being evaluated, so it thinks the project has no dependencies. 1. I changed it to compute its CopySpec in a doFirst closure, but the task never gets run because it has no inputs or outputs until doFirst executes. Gradle thinks it’s up-to-date. 1. I split it into two tasks, srcSpec, and srcZip. srcZip depends on srcSpec. When srcSpec runs, it builds a CopySpec and then does “srcZip.with(copySpec)”. Strangely, the srcZip task only executes sometimes; other times, Gradle thinks it’s up-to-date.
I guess my question is: Where do I put my code to compute a dynamic CopySpec, based on this project’s dependencies?