diff --git a/plug-in-development/index.html b/plug-in-development/index.html index f3e2915..22900b5 100644 --- a/plug-in-development/index.html +++ b/plug-in-development/index.html @@ -362,7 +362,7 @@ public fun myConfig(project: Project, init: Info.() -> Unit) : Info {
- Static tasks are functions declared directly on your plug-in and annotated with the @Task
annotation. Here is an example:
+ Static tasks are functions declared directly in your plug-in class and annotated with the @Task
annotation. Here is an example:
@Task(name = "lineCount", description = "Count the lines", runBefore = arrayOf("compile")) @@ -391,8 +391,34 @@ fun lineCount(project: Project): TaskResult {
+ The difference between runAfter
and wrapAfter
is subtle but important. runAfter
+ is just a declaration of dependency. It's basically the reverse of runBefore
but it's useful in case
+ you are not the author of the task you want to run before (if you were, you would just use the runBefore
+ annotation on it). Since you can't say "a runBefore b"
because you don't own task "a",
+ you say "b runAfter a"
.
+
+ For example, compileTest
is declared as a runAfter
for 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.
+
+ However, 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 wrapAfter
. You are essentially wrapping
+ an existing task with your own task. Note that there is no wrapBefore
annotation since runBefore
+ achieves the same functionality.
+