There's also the @Field transform which transforms a local variable in a
script into a script's field.

On Wed, Mar 14, 2012 at 12:34, Russel Winder <rus...@winder.org.uk> wrote:

> Groovy scope rules mean that outside of a class definition, i.e. in a
> script:
>
> final x = 1
> def X ( ) {
>  x
> }
>
> fails due to the way code is constructed into a class.  The usual trick
> is to make use of the script binding:
>
> x = 1
> def X ( ) {
>  x
> }
>
> works fine -- in a Groovy script.  This used to work fine in a Gradle
> script as well, but this is no longer the case. Deprecation warnings
> about project.ext get issued.
>
> One solution is to never use functions in Gradle scripts, but always to
> use variables bound to lambda functions.
>
> Is there though a way around this fact that Gradle scripts obey Groovy
> script scoping but no longer have a script binding usable in the Gradle
> script?
>
> Thanks.
>
> --
> Russel.
>
> =============================================================================
> Dr Russel Winder      t: +44 20 7585 2200   voip:
> sip:russel.win...@ekiga.net
> 41 Buckmaster Road    m: +44 7770 465 077   xmpp: rus...@winder.org.uk
> London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
>



-- 
Guillaume Laforge
Groovy Project Manager
SpringSource, a division of VMware

Blog: http://glaforge.appspot.com/
Social: @glaforge <http://twitter.com/glaforge> /
Google+<https://plus.google.com/u/0/114130972232398734985/posts>

Reply via email to