parameters - How do you pass args to gmaven groovy:execute? -
i need pass in args groovy script executed via gmaven. can no problem if execute script directly on command line so:
printargs.groovy...
for (a in this.args) { println("argument: " + a) }
command...
$groovy printargs.groovy fe fi fo fum
output...
argument: fee argument: fi argument: fo argument: fum
i can't see how pass these args in via plugin though using mvn groovy:execute. ideally, want set default params in plugin config, able override them when execute command. nice able pass them named-args if possible.
<plugin> <groupid>org.codehaus.gmaven</groupid> <artifactid>gmaven-plugin</artifactid> <version>1.3</version> <configuration> <source>${pom.basedir}/src/main/resources/printargs.groovy</source> </configuration> </plugin>
the plugin documentation bit scarce (and outdated). see there 'properties' optional param don't think used purpose (or if is, can't work!).
cheers :)
ok, can answer own question reference sake...
rather pass in list of args, possible reference project properties follows:
def someprop = project.properties['someprop']
in doing this, can reference properties defined in tag within pom. furthermore, can define properties in same configuration tag groovy script.
gmaven plugin config...
<configuration> <properties> <name>world</name> </properties> <source>${pom.basedir}/src/main/resources/bootstrap/helloworld.groovy</source> </configuration>
helloworld.groovy...
println("hello $project.properties.name!") // works // println("hello $project.properties['name']!")
Comments
Post a Comment