Run multiple ant tasks on the same virtual machine

I am running a unit test using ant

<target name="test" depends="tomcatDeploy" description="Build and run tests">
    <ant dir="${aDir}" target="test"/>
    <ant dir="${bDir}" target="test"/>
    <ant dir="${cDir}" target="test"/>
    <ant dir="${dDir}/ExtFramework"  target="test"/>
</target>

      

and I want to run them on the same VM - otherwise I get a lot of overhead when creating the jvm and recreating the statics, etc.

Is there a way to do this?

0


a source to share


4 answers


I think the subant task is what you are looking for. Assuming that all of your subdirectories have a common parent, you can do something like the following:

<target name="test" depends="tomcatDeploy" description="Build and run tests">
    <subant target="test">
        <fileset dir="${parent}" includes="**/build.xml"/>
    </subant>
</target>

      



EDIT How do you conduct tests? If you are using a task junit

, do you have one fork="yes"

? If so, this will run the tests in a new virtual machine. Change this to fork="no"

to run the tests in the same virtual machine.

+1


a source


The task itself does not create a new virtual machine. Have your tests been created to create a new virtual machine?



0


a source


Try to minimize the problem. Does your test create a new virtual machine if you start it manually via JUnit? Or does the problem only occur when combined with ant?
It is probably JUnit or your tests creating a new VM and leaking memory.

0


a source


<parallel threadCount='4'>
  <ant target='TargetThatConsumesLotsOfCPUTimeAndMemory'>
    <param name='file' value='one.txt'/>
  </ant>
  <ant target='TargetThatConsumesLotsOfCPUTimeAndMemory'>
    <param name='file' value='two.txt'/>

  </ant>
  <ant target='TargetThatConsumesLotsOfCPUTimeAndMemory'>
    <param name='file' value='three.txt'/>
  </ant>
  <!-- repeated about 40 times -->
</parallel>

      

http://www.java-tips.org/other-api-tips/ant/how-to-use-parallel-task.html

0


a source







All Articles