Eclipse 内で Groovy を実行しているときに、プログラムの引数をどのように処理するのか疑問に思っています。コマンドラインからの場合ほど簡単ではなく、理解するのに苦労しています。私はEclipse 3.5を使用しています。私の実行構成には、これらの引数がすべて 1 行に含まれています。
--classpath "${workspace_loc:/GroovyProject};${workspace_loc:/GroovyProject}"
--main groovy.ui.GroovyMain "C:\Temp\Workspace\GroovyProject\GroovyTest.groovy "
argtest1
argtest2
argtest3
この作業を行うために使用しているスクリプトは次のようになります。
// GroovyTest.groovy
class GroovyTest {
static main(args) {
println "hello, world"
for (arg in this.args ) {
println "Argument:" + arg;
}
}
}
私が得るエラーは次のとおりです。
hello, world
Caught: groovy.lang.MissingPropertyException: No such property: args
for class: GroovyTest at GroovyTest.main(GroovyTest.groovy:5)