I have not been able to upgrade past Groovy 1.5.8, due to massive memory
issues.  I've identified the exact scenario that cause problems, but I
don't know if it is a bug, or what the solution is.

 

The <groovy> task can be used as long as the taskdef is done once, or
the taskdef uses loaderref when done in a loop.  But, if the loop calls
a sub project, (eg antcall) the loaderref attribute does not help.

 

The <scriptdef language="groovy"> task seems to have the exact same
behavior as the <groovy> task.

 

The <script language="groovy"> task cannot be used in a loop, since
there is no way to separate the script execution from the groovy
task/script definition.

 

Any help would be greatly appreciated.

 

Thanks, Mike

 

PS - Attached is the script I used for diagnosing this.  It uses
AntContrib to loop.  It can run as follows:

       ant -f GroovyMem.xml -Diterations=100 -D3rdparty_libdir=
\3rdPartyJars\lib

<?xml version="1.0"?>
<project name="GroovyMem" default="all" xmlns:antc="antlib:net.sf.antcontrib">

   <path id="groovy.class.path">
      <fileset dir="${3rdparty_libdir}">
         <include name="groovy-all*.jar"/>
         <include name="bsf.jar"/>
         <include name="commons-logging.jar"/>
      </fileset>
   </path>

   <target name="all"                     depends="test_groovy, 
                                                   test_groovy_script_def,
                                                   test_groovy_script"/>
   
   <target name="test_groovy"             depends="init">
      <antc:for list="${iteration_list}" param="iteration" delimiter=",">
         <sequential>
            <echo message="@{iteration}"/>
            <antcall target="run_groovy" inheritAll="false"/>               
         </sequential>
      </antc:for>
   </target>

   <target name="run_groovy">
            <taskdef name="groovy"
               classname="org.codehaus.groovy.ant.Groovy"
               classpathref="groovy.class.path"
               loaderref="groovy"/>

            <groovy>
               // do nothing
            </groovy>               
   </target>
      
   <target name="test_groovy_script"      depends="init">
      <antc:for list="${iteration_list}" param="iteration" delimiter=",">
         <sequential>
            <echo message="@{iteration}"/>
            <script language="groovy" classpathref="groovy.class.path">
            </script>
         </sequential>
      </antc:for>
   </target>
      
   <target name="test_groovy_script_def"  depends="init">
      <antc:for list="${iteration_list}" param="iteration" delimiter=",">
         <sequential>
            <scriptdef name="GroovyScriptDef"     language="groovy"
                                              classpathref="groovy.class.path"
                                                 loaderref="groovy">
               <![CDATA[
               ]]>
            </scriptdef>
            <echo message="@{iteration}"/>
            <GroovyScriptDef/>
         </sequential>
      </antc:for>
   </target>
      
   <target name="init">
      <IterateInit iterations="${iterations}" property="iteration_list"/>
   </target>
   
   <scriptdef name="IterateInit"               language="groovy"
                                           classpathref="groovy.class.path">
      <attribute name="iterations"/>
      <attribute name="property"/>
      <!-- Attempt to format date.  If cannot parse, do not set property -->
      <![CDATA[
         def ant        = new AntBuilder(project)
         def limit      = Integer.parseInt(attributes.iterations)
         def i_string   = ""
         
         for (i=1; i<=limit; i++)
            i_string += i +","

         ant.property(name:attributes.property, value=i_string)
      ]]>
   </scriptdef>
   
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to