Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

where the closure comprising the body of the target appears to have no parameters, in fact there is an implicit parameter it.  When called from the command line it always has the value null but when called from within a Gant script the target closure can be called with a parameter.  For details see Targets and Parameters

Why do I get "Error evaluating Gantfile: No such property: env" when env should be available?

In the following example:

Code Block

ant.property(environment:'env')

...

ant.echo("${env.CATALINA_HOME}")

You will get an error similar to:

build, line 11 -- Error evaluating Gantfile: No such property: env for class: build

This is a phasing issue between groovy's GString and Ant -- Groovy attempts to interpret the env.CATALINA_HOME as part of a GString rather than allowing the expression to be sent as is to the Ant project instance for expansion of properties.

Use single quotes instead (switches of GString interpretation) and it will work just fine.