Wow, thanks everyone for the great responses. This community rocks! We've
moved to Gradle at work as an experiment from Ant and Maven. Now that we're
getting the hang of it, we can't imagine writing another Ant script!
--Eric
On Jan 11, 2011, at 2:12 PM, Rene Groeschke wrote:
> Hi,
> Am 11.01.11 21:40, schrieb Eric Nelson:
>> I'm sorry if this is a newbie question, but what is the significance of the
>> << operator in Gradle scripts? As an example:
>>
>> task hello << {
>> println "hello"
>> }
> task hello << {
> println "hello"
> }
>
> is just a shortcut for
> -----
> task hello {
> doLast{
> println "hello"
> }
> }
> -----
>
> As you can read in the userguide
> (http://gradle.org/0.9.1/docs/userguide/build_lifecycle.html), there is
> a configuration phase and a execution phase. everything in a doLast{}
> closure is executed during the execution phase. Simple tasks (as the
> hello task above) don't need any configuration so the shortcut notation
> is all you need. Some tasks need configuration. As a rule of thumb, the
> configuration phase defines the WHAT, the execution phase takes care of
> the HOW.
>
> Let's take a look at a typical definition of a Copy task:
> -----
> task copyTask(type: Copy) {
> from 'src/main/webapp'
> into 'build/explodedWar'
> }
> -----
> The task definition above tells gradle WHAT to copy. The HOW (the copy
> action itself) is implemented in the Copy class. A refactored task that
> prints to stdout and seperates WHAT and HOW can look like that:
> -----
> class PrintlnTask extends DefaultTask{
> def output;
>
> @TaskAction
> void print {
> println output
> }
> }
>
> task hello(type: PrintlnTask) {
> output = "hello"
> }
> -----
>
> 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
>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email