Reputation: 11921
If a plugin defines a series of tasks, is it possible to inject a dependency into these, such that the dependency is called before the plugin-defined task is executed?
The native-artifacts plugin defines buildNar (and buildNarxxx, where xxx is the platform config) tasks. It also defines extractNarDepsxxx (where xxx is the platform config for the Nar to be built). extractNarDeps is not called before builder, so the build fails as required dependencies are not downloaded prior to the attempted build.
How do I inject extractNarDepsxxx as a dependency into buildNarxxx?
Upvotes: 1
Views: 2147
Reputation: 84874
Ok. Consider the following example:
apply plugin: 'java'
task someTask
task anotherTask
tasks.classes.mustRunAfter(anotherTask)
tasks.build.dependsOn(someTask)
There's a single plugin applied java
and two custom tasks someTask
and anotherTask
.
Task build
(taken from java
plugin) dependsOn
someTask
. It means that when You run gradle build
this task will be executed.
Task classes
mustRunAfter
anotherTask
. So when You type gradle build anotherTask
, anotherTask
will run before build
.
Try it. An ask further questions when needed.
Upvotes: 3