Hi Sean,
Am 11.01.11 23:54, schrieb Sean Van Buggenum:
> Hi all,
>
> I am new to gradle, and am having troubles understanding the order in
> which tasks are run, and what the various keywords (as obvious as they
> sound) actually mean.
>
> For example:, the very first example in the groovy documentation:
>
> task hello {
> doLast {
> println 'Hello world!'
> }
> }
>
> What is the doLast block doing in the hello task? Does this mean that
> the "Hello world" printout will be the last even to occur in the hello
> task?
>
> So, if we have:
>
>
> task hello {
>
> println 'do it then!'
>
> doLast {
> println 'goodbye world'
> }
>
> println 'do it now!'
>
> doFirst {
> println 'Hello world!'
>
> }
> }
>
>
> we do indeed see things done in the order
>
> do it then!
> do it now!
> hello world
> goodbye world
> --------------------------
>
> But what exactly is the use of determining the order of things running
> WITHIN a task in this way. Shouldn't it just be iterative ... step by
> step..... what comes first gets done first like in as a c program?
> I ask this not in criticism, only to point out where I need the help
> in understanding the new paradigm.
First of all have a look at this 2 hour old thread about understanding
<< & doLast at http://bit.ly/gSceDL
A task can have multiple actions. Those actions of are organised as a
chain. doLast adds an action to the end of the chain and the doFirst
adds an action to the beginning of the chain. Everything not enclosed a
doLast or doFirst closure is executed during the configuration phase.
Everything else in the task is executed during the configuration phase
In the example above this means:
1. gradle starts configuration phase (configuring the tasks, creating
the task graph)
2. println "do it then" is executed during configuration phase
3. println "do it now" is executed during configuration phase
4. configuration phase finished and execution phase is started
(executing the tasks)
5. "hello world!' is printed as the action was added to the beginning of
the tasks action chain/list
6. "goodbye world' is printed as the action was added at the end of the
tasks action chain/list
> Another example shown in the documentation:
>
>
> task hello << {
> println 'Hello Earth'
> }
> hello.doFirst {
> println 'Hello Venus'
> }
> hello.doLast {
> println 'Hello Mars'
> }
> hello << {
> println 'Hello Jupiter'
> }
>
>
> shows the output as:
>
>
>> gradle -q hello
> Hello Venus
> Hello Earth
> Hello Mars
> Hello Jupiter
> ------------------
>
>
> This completely throws me. I would have expected that "Hello Mars" is
> done last (since it is shown as a doLast).
> Why is it not the case?
>
With the explanation of the first example, this shouldn't thrill you
anymore. << is a shortcut for doLast
regards,
René--
------------------------------------
Rene Groeschke
[email protected]
http://www.breskeby.com
http://twitter.com/breskeby
------------------------------------
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email