ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Amerige <Steve.Amer...@sas.com>
Subject Re: How to Execute Groovy 2.0 Code from an Ant File that has Groovy 1.7 Classpath
Date Tue, 07 Aug 2012 19:15:03 GMT
On 8/6/2012 9:04 AM, Nicolas Lalevée wrote:
> 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

The code shown below _does_ work!  Thank you very much!  Is this the 
best way to take care of this need for both Ant 1.7 and Ant 1.8?  
Specifically, what about using *<classloader>* task as an alternative?  
I couldn't find examples of how *<classloader>* is used, but saw it in 
the 1.8 source code?

If there is a better way to give my classpath priority other than the 
*reverseloader *trick, can someone provide example code that works in 
both Ant 1.7 and 1.8 (even if conditional code is used) so that I get it 
right?

Many thanks!

Steve Amerige
SAS Institute, Deployment Developer

*build.xml:*

<?xml version="1.0" encoding="UTF-8"?>

<project name="Ant" default="main" basedir=".">

<taskdef
    name="groovy"
    classname="org.codehaus.groovy.ant.Groovy"
    classpath="C:/groovy-2.0.1/embeddable/groovy-all-2.0.1.jar"
    reverseloader="true"/>

<target name="main">
<echo message="ant: ${ant.version}"/>
<groovy>
         println GroovySystem.getVersion()
</groovy>
</target>

</project>**

*output with Ant 1.7.1:*

*without reverseloader="true":*

main:
      [echo] ant: Apache Ant version 1.7.1 compiled on June 27 2008
    [groovy] 1.7.10
BUILD SUCCESSFUL

*with reverseloader="true":*

   [taskdef] The reverseloader attribute is DEPRECATED. It will be removed
main:
      [echo] ant: Apache Ant version 1.7.1 compiled on June 27 2008
    [groovy] 2.0.1
BUILD SUCCESSFUL

*output with Ant 1.8.4:*

*without reverseloader="true":*

main:
      [echo] ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
    [groovy] 1.7.10
BUILD SUCCESSFUL

*with reverseloader="true":*

   [taskdef] The reverseloader attribute is DEPRECATED. It will be removed
main:
      [echo] ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
    [groovy] 2.0.1
BUILD SUCCESSFUL

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message