I’m trying to understand how I would have to declare a dependency on an artifact of a configuration in the same project so that a dependency on the task producing the artifact is established implicitly.
In the case I’m currently looking at, a project with basically the following build.gradle is supposed to build a JAR with some Java code and XML/XSL resources first, then build a PDF for the manual using the jdocbook plugin, using the resources in the JAR:
This works - running the “buildDocs” task added by the jdocbook plugin runs the “assemble” task first, and the resulting JAR file is used by JDocBook. But I’m guessing that there is a way to avoid the “afterEvaluate” part and have this dependency added implicitly. I haven’t found it, yet, though. Changing the above dependency to
jdocbookStyles configurations.runtime
or
jdocbookStyles configurations.archives
didn’t help - I still need to add the task dependency explictly. What is the intended way of doing this?
findAll() requires all the tasks to be added to the TaskContainer at that point. While matching() runs for any tasks that have already been added and any tasks that are added in the future.
Ah, it looks like a bug in the custom task for jdocbook.
@Input just records the value and doesn’t add any dependencies. That would need to be @InputFiles instead. The only way to make it work would be to use tasks.matching or tasks.withType right now.