Failing that, define propertysets with the properties you need to propagate, then invoke ant via a java task with a fork, and the set of environment variables you want (including classpath.)
Peter West "...you will find rest for your souls. For my yoke is easy, and my burden is light." On 06/08/2012, at 11:04 PM, Nicolas Lalevée <nicolas.lale...@hibnet.org> wrote: > > Le 6 août 2012 à 14:37, Steve Amerige a écrit : > >> Some more info on this problem: >> >> The issue is is a ClassLoader delegation model >> <http://docs.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html> >> problem. If the classpath has in it a path to Groovy 1.7.10 (as it does), >> then even if I explicitly add the classpath in Ant as I do below, the 1.7.10 >> version will still be used because it has already been loaded. The only >> solutions I can think of include: >> >> 1. Export all Ant properties and the current classpath to a file. Use exec >> to run ant with a classpath that puts the Groovy 2.0.1 directory before the >> other directories in the classpath. Then, load the ant properties and >> continue. >> >> 2. Discover if there is any way of doing dynamic classloading that gets past >> the delegation model problem. > > There is a possible hack I guess. > There is a deprecated option to typedef : reverseLoader. If set to true, the > classloader inheritance is inverted. > I don't know why it is deprecated but surely for a good reason, so use it at > your own risk ;) > > Nicolas > >> >> If you have any ideas, please send them my way! By mid-week, I'll wind up >> doing whatever the best solution there is for this problem, even if it is >> (1) above. >> >> Enjoy, >> Steve Amerige >> SAS Institute, Deployment Developer >> >> On 8/3/2012 1:57 PM, Steve Amerige wrote: >>> 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 >>> >>> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@ant.apache.org > For additional commands, e-mail: user-h...@ant.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional commands, e-mail: user-h...@ant.apache.org