groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russel Winder <rus...@winder.org.uk>
Subject Re: About the syntax of groovy
Date Sun, 01 Nov 2015 18:51:10 GMT
On Fri, 2015-10-30 at 09:53 -0700, daniel_sun wrote:
> Hi all, 
> 
>      Could you tell me the following gradle code comply with the
> syntax of
> groovy?  The 'task' can be a method, what about 'taskA' and
> '<<'?  Thanks in
> advance. 
> 
> task taskA << { 
>     println "i'm task A" 
> } 

If I remember correctly, this syntax only works because Gradle applies
an AST transform to the code. The more tradition Groovy code that this
gets transformed to is:

task('taskA') << {
    println "i'm task A"
}

which is pure Groovy.

Though I suspect I am now going to have to say Apache Groovy now.

> ----------- my experimental code, but failed with exceptions
> ----------------- 
> def task(t) { 
>     t() 
> } 
> 
> task taskA << { 
>     println "i'm task A" 
> } 
> ================= 
> groovy.lang.MissingPropertyException: No such property: taskA for
> class:
> ConsoleScript8 
> 
>         at ConsoleScript8.run(ConsoleScript8:5) 
> ----------------------------
> 
> 
> 
> --
> View this message in context: http://groovy.329449.n5.nabble.com/Abou
> t-the-syntax-of-groovy-tp5729026.html
> Sent from the Groovy Users mailing list archive at Nabble.com.
-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder@ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder


Mime
View raw message