I discover that the packaging configuration knows where the foo archive should be, but doesn’t know which task should build it! Conversely, adding the dependency like this works as expected:
It occurs to me that could it simply be “too late” to add extra task dependencies at this point, because the Task Graph has already been calculated… ?
This does seem likely, because forcibly resolving this configuration from a Project.afterEvaluate handler (i.e. adding the new ProjectDependency objects before Gradle builds the Task Execution Graph) does the trick!
I feel dirty now, and not in a good way. Better suggestions would be very welcome.
Cheers,
Chris
Edit: While it is presumably necessary for my withDependencies {} handler to execute before Gradle builds the Task Execution Graph, it does not appear to be sufficient. For example, I have since tried forcibly resolving my configuration like this:
on the basis that compileClasspath is already being resolved at the right time. However, while my new ProjectDependency objects were created before the Task Execution Graph, they still did not trigger any new task dependencies. I have therefore reverted to using Project.afterEvaluate {} again.
I fear that I have entered the realm of Undocumented Behaviour…!!!
The path is printed and the fooMaker is automatically run before bar.
As the example you posted has various errors that made it not run at all but only throw syntax errors, it is hard to guess what your actual problem is or was.
Hi, thanks for reply. Sorry about the syntax errors, I was trying to transcribe the salient features from my test project late at night and clearly mistyped a few things.
As I have since discovered, Gradle is building the Task Execution Graph before it adds the new ProjectDependency to the sub-project - something I have proved by adding these lines to the “root” project:
Hm, interesting, I guess you found a bug you should report.
If you add a directroy baz, inside an empty file settings.gradle, and in your top-level setting.gradle the line includeBuild 'baz', then it works as expected.
At least this difference in behaviour is probably not expected.
Happily, I have confirmed that your “composite build” trick works for my actual Gradle project too . (Not that my plugin code can use your trick, but I am now confident that resolving #17765 will also solve my Real World problem .)