From ed0248ce3f71335f55a4abeb0056f2c7872e47b0 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 19 Apr 2016 05:04:20 -0800 Subject: [PATCH] Clarify task dependencies. --- plug-in-development/index.html | 61 +++++++++++++++------------------- 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/plug-in-development/index.html b/plug-in-development/index.html index 094fe2b..13d014d 100644 --- a/plug-in-development/index.html +++ b/plug-in-development/index.html @@ -470,7 +470,7 @@ The @Task annotation accepts the following attributes: If your task cannot run until another task has run, you need to declare a dependency. Dependencies cause additional tasks than those requested to be executed. For example, "assemble" depends on "compile", which means that whenever you invoke "assemble", "compile" will be automatically run first. This is a dependency and it is controlled by "dependsOn" and - "reverseDependsOn". + "reverseDependsOn". You can see "reverseDependsOn" as a way to insert your task before an existing task.

Orderings, controlled by "runBefore" and "runAfter" merely specify an ordering @@ -479,58 +479,49 @@ The @Task annotation accepts the following attributes: by the user).

- The reverse direction attributes "reverseDependsOn" and "runAfter" are useful - when you want to declare a dependency/ordering on a task that you do not control, and that you can therefore - not modify. -

-

-

-For example, compileTest is declared as "dependsOn" the task compile. -This means that it doesn't make sense to run compileTest unless compile has run first. -However, if a user invokes the task compile, they probably don't want to invoke compileTest, -so a dependency is exactly what we need here: invoking compileTest will trigger compile -but not the other way around. -

-

-There are times where you want to define a task that will always run after a given task. -For example, you could have a "signJarFile" task that should always be invoked if someone builds a jar -file. You don't expect users to invoke that target explicitly, but whenever they invoke the "assemble" -target, you want your "signJarFile" target to be invoked. When you want such a task to always be invoked -even if the user didn't explicitly request it, you should use "reverseDependsOn". -

-

-Here are a few different scenarios to illustrate how the three attributes work for the task exampleTask: +Here are a few different scenarios to illustrate how the three attributes work for the task example:

Result of the command ./kobaltw --dryRun compile

- + + - + - - - + + + + + + +
Configuration for exampleTaskConfiguration for example ResultNote
runBefore = "compile"dependsOn = "compile" -
kobalt-line-count:clean
-kobalt-line-count:exampleTask
-kobalt-line-count:compile
+
clean
+compile
+example
runAfter = "compile" -
kobalt-line-count:clean
-kobalt-line-count:compile
+ Make the "example" task depend on "compile".
reverseDependsOn = "compile" -
kobalt-line-count:clean
-kobalt-line-count:compile
-kobalt-line-count:exampleTask
+
clean
+example
+compile
+ Insert the "example" task before "compile". +
runAfter = "compile" +
clean
+compile
+
+ Make "example" run after "compile" but only if it's invoked explicitly. +

Dynamic tasks