martes, 17 de octubre de 2017

Ant as a script director

Hi, this entry on the blog is for using Ant as a scripting integration together with Groovy.

<‍project‍>
<‍property name="groovy.home" value="/home/vagrant/.sdkman/candidates/groovy/current/"/‍>
   <‍property name="groovy.version" value="X.Y.Z"/‍>
   <‍path id="groovy.classpath"‍>
     <‍fileset dir="${groovy.home}/lib"‍>
       <‍include name="**/*.jar"/‍>
     <‍/fileset‍>
   <‍/path‍>
<‍target name="targetSample"‍>
    <‍taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="groovy.classpath"/‍>
      
        ant.ant(antfile:'build.xml'){ // you antfile name
           target(name:'targetTest') // your targetName
           property(name:'param1',value:'theParamValue') // your params name and values
        }
        def salutation="Hello World"
        print(salutation)
       <‍/groovy‍>
 <‍/target‍>
<‍target name="targetTest"‍>
        <‍echo‍>Hola mundo Groovy! <‍/echo‍>
<‍/target‍>
<‍/project‍>
Output
Buildfile: /home/vagrant/ant-tests/build.xml

targetSample:

targetTest:
     [echo] Hola mundo Groovy!
Hello World

BUILD SUCCESSFUL
Total time: 1 second

No hay comentarios:

Publicar un comentario