Hi all,
My Ant script is being called with an environment including the
classpath that includes the folder containing the groovy-all-1.7.10.jar
file. I want to execute Groovy 2.0 code from my Ant script. I cannot
change any aspect of how my Ant script is called. I must limit my
solution to that which I can put into my own Ant script.
My challenge is to figure a way to run groovy 2.0 code. My attempt
below fails to do this. I'm hoping someone will have a solution.
Ideally, it will NOT involve using *exec *because in the groovy code I
will be using AntBuilder to access various tasks, macros, etc. that are
defined back on the Ant side and I want logging information to go to the
same logfile as well.
*Can anyone think of a way to execute some Groovy 2.0 code given that
the classpath already includes a 1.7 Groovy jar file?*
Thanks,
Steve Amerige
SAS Institute, Deployment Developer
Note below that the Groovy system version is 1.7.10, not 2.0.1.
<?xml version="1.0" encoding="UTF-8"?>
<project name="Ant" default="main" basedir=".">
<path id="my.classpath">
<fileset dir="C:/test/groovy-2.0.1/embeddable">
<include name="groovy-all-2.0.1.jar" />
</fileset>
</path>
<taskdef
name="groovy"
classname="org.codehaus.groovy.ant.Groovy"
classpath="C:/test/groovy-2.0.1/embeddable/groovy-all-2.0.1.jar"/>
<target name="main">
<groovy classpathref="my.classpath">
println GroovySystem.getVersion()
println GroovySystem.class.getClassLoader().getURLs().join("\n")
</groovy>
</target>
</project>
Buildfile: C:\test\build.xml
main:
[groovy] *1.7.10*
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-antlr.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-apache-bcel.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-apache-bsf.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-apache-log4j.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-apache-oro.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-apache-regexp.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-apache-resolver.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-commons-logging.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-commons-net.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-jai.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-javamail.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-jdepend.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-jmf.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-jsch.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-junit.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-launcher.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-netrexx.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-nodeps.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-starteam.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-stylebook.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-swing.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-trax.jar
[groovy]
file:/C:/eclipse/plugins/org.apache.ant_1.7.1.v20100518-1145/lib/ant-weblogic.jar
[groovy]
file:/C:/eclipse/configuration/org.eclipse.osgi/bundles/84/1/.cp/lib/remoteAnt.jar
[groovy]
file:/C:/eclipse/configuration/org.eclipse.osgi/bundles/772/1/.cp/lib/antdebug.jar
[groovy]
file:/C:/eclipse/configuration/org.eclipse.osgi/bundles/772/1/.cp/lib/remote.jar
[groovy]
file:/C:/eclipse/configuration/org.eclipse.osgi/bundles/1140/1/.cp/antlibs/remoteAnt.jar
[groovy] file:/C:/Program%20Files/Java/jdk1.6.0_24/lib/tools.jar
[groovy]
file:/C:/eclipse/plugins/org.eclipse.swt.win32.win32.x86_64_3.6.2.v3659c.jar
[groovy] file:/C:/test/ant-contrib/ant-contrib.jar
[groovy]
file:/C:/eclipse/plugins/org.codehaus.groovy_1.7.10.xx-20110918-1400-e36/lib/groovy-all-1.7.10.jar
[groovy] file:/C:/test/json_0.2.0.0_SAS_20100917120500/JSON.jar
BUILD SUCCESSFUL
Total time: 1 second