groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject RE: groovy issue with @Grab
Date Wed, 23 Mar 2016 10:13:04 GMT
Ok, these explanations make sense to me. Annotating the imports with their corresponding @Grab
statement is indeed an elegant solution. We will update or internal scripts to follow this.



De : Guillaume Laforge []
Envoyé : mercredi 23 mars 2016 10:51
À :
Objet : Re: groovy issue with @Grab

And it'd be more idiomatic to write the example below as:

import static org.apache.commons.lang3.text.WordUtils.*

println capitalize("this is another test")

(I've also upgraded the version of commons-lang)


On Wed, Mar 23, 2016 at 10:33 AM, Jochen Theodorou <<>>

On 23.03.2016 10:08, DECLOEDT Loic EVADERIS wrote:

I am taking the opportunity to inform you of an issue we have seen since
a long time.

When a @Grab statement is in a script, the next statement MUST be a
variable statement. For example, a code like this:




// this var declaration is required to avoid startup error

//def i = 0

an annotation has to annotate something. Java allows annotations on variable declarations,
classes, methods, packages and imports (at least I think it was both), as well as parameters.
Since we follow the Java rules for annotation placement, the same applies to us.... we have
been talking about extending this, but the current parser gets in the way of doing that, since
such a change is highly ambiguous in many cases. After all, you are replacing a clear distinction
of for example statements and their introducing keywords with something all have in common.

Is it a known issue ?

yes, we hope once the long work on the new grammar is done, this issue can be tackled.

bye Jochen

Guillaume Laforge
Apache Groovy committer & PMC Vice-President
Product Ninja & Advocate at Restlet<>

Social: @glaforge<> / Google+<>
View raw message