I've had the need for "wiring variations" on several occasions, but typically
not limited to a single task. Therefore I'd like to propose a more general
concept. Let's call it "true lifecycle tasks". :-)

A true lifecycle task behaves like a normal task, with three differences:

1. It can't have any actions
2. It doesn't show up in the command line output
3. Its configuration block(s) are only evaluated once Gradle has determined
that the task is going to be executed

Note that the configuration blocks can contain any configuration, not
necessarily related to the task itself. They can also add new task
dependencies between arbitrary tasks.

'integTestAll' now looks as follows (syntax is just exemplary):

integTestAll(type: LifecycleTask) {
  jettyStop.dependsOn integTest
  integTest.dependsOn jettyStart
}

(It would be nice to have a more succinct syntax for task chains, e.g.
'jettyStop.dependsOn(integTest).dependsOn(jettyStart)'.)

Since those task dependencies are introduced conditionally, 'jettyStop' on
its own doesn't depend on 'integTest'. This makes a lot of sense, both
conceptually and in practice. I suppose your solution would have achieved
the same.

But true lifecycle tasks can do more. If we use them for tasks like 'check'
and 'build', those tasks no longer appear in the command line output (which
is good). True lifecycle tasks are also a great fit for modeling different
build types:

task ciBuild(type: LifecycleTask) {
  dependsOn(build)
  check.dependsOn(ciOnlyChecks)
}

'ciOnlyChecks' could even be introduced conditionally within the 'ciBuild'
configuration block.

Imagine 'ciBuild' is added by a plugin. Then builds can easily add CI build
specific behavior like so:

ciBuild { ... }

Or potentially for multiple build types at once:

configure(ciBuild, releaseBuild) { ... }

I'm sure there are more applications of this concept, but these are the ones
I can think of right now. What do you think?

Cheers,
Peter

PS: I also have (vague) ideas on generalizing finalizer tasks, but I'll
leave them for another post.



--
View this message in context: 
http://gradle.1045684.n5.nabble.com/Task-Variations-tp4884963p4887685.html
Sent from the gradle-dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to