final GroovyShell groovy = new GroovyShell(classLoader, new Binding(), configuration);This behavior was unexpected since it does not follow the normal Ant convention and because the documentation states the src attribute is a File containing Groovy statements rather than stating it expects a Groovy Script.
try {
final Script script = groovy.parse(txt, scriptName);
script.setProperty("ant", new AntBuilder(this));
// code removed for brevity
script.setProperty("args", cmdline.getCommandline());
script.run();
}
Random thoughts about my interests in Java, consulting, scripting in Java and software development (especially for small and medium size organizations).
Monday, March 10, 2008
Groovy Ant task is for Groovy Scripts
Groovy includes an Ant task for executing either file based or embedded Groovy. I recently discovered the file option denoted by the src attribute must be a Groovy script and not a Groovy class containing a main method. If you have used the Java task, you might expect the Ant arg set to be passed as a parameters to the main method since it is the common Ant convention for passing command line arguments. However, as you can see in the following snippet of code from org.codehaus.groovy.ant.Groovy, a GroovyShell is created and the args are passed as a property to the script.
Subscribe to:
Post Comments (Atom)
AWS EC2 Hibernate Java SDK v2 Example
I recently wanted to automate the creation of developer VMs in AWS using EC2 instances. To improve the developer experience (DX), I didn...
-
In May of 2009, I wrote the blog post The Ultimate Enterprise Java Build Solution . Over the past 7 years since I wrote the post I have help...
-
Early in my career I took on the role of setting up and operating the build infrastructure of many of the projects I have consulted on. I st...
-
Class loading issues are a common frustration for many Java developers. The dreaded java.langClassNotFoundException means they can forget a...
No comments:
Post a Comment