Ant中如何使用并行任务
How to use parallel task in Ant
你好,我正在处理 运行 通过 Ant 调用一一测试的应用程序。在 .bat 文件中调用 build.xml,在其中调用另一个名为 .class 的文件 test 是否有机会在 Ant 中进行并行处理?
我的 ant 配置如下所示:
<target name="testexec-run-pattern" description="=> run JUnit tests by Pattern">
<mkdir dir="${junit.dir}/xml" />
<input addproperty="input.pattern" />
<echo message="Executing pattern: ${input.pattern}" />
<junit showoutput="true" printsummary="on">
<classpath refid="classpath" />
<batchtest todir="${junit.dir}/xml">
<formatter type="xml" extension=".xml" usefile="true" />
<zipfileset src="${test.jar}">
<patternset includes="${input.pattern}" />
</zipfileset>
</batchtest>
</junit>
</target>
其中包含的模式集是 运行 的测试。我希望这些测试 运行 并行。我想我需要像 foreach 这样的东西才能使所有测试在线程中成为 运行。
在 Ant 中,Task 可以使用 parallel
标签并行执行。以下是从 official Apache Ant site 中提取的示例:
<macrodef name="dbpurge">
<attribute file="file"/>
<sequential>
<java jar="utils/dbpurge.jar" fork="true" >
<arg file="@{file} />
</java>
</sequential>
</macrodef>
<parallel threadCount="4">
<dbpurge file="db/one" />
<dbpurge file="db/two" />
<dbpurge file="db/three" />
<dbpurge file="db/four" />
<dbpurge file="db/five" />
<dbpurge file="db/six" />
<dbpurge file="db/seven" />
<dbpurge file="db/eight" />
<!-- repeated about 40 times -->
</parallel>
This example represents a typical need for use of the threadCount and threadsPerProcessor attributes. Spinning up all 40 of those tasks could cripple the system for memory and CPU time. By limiting the number of concurrent executions you can reduce contention for CPU, memory and disk IO, and so actually finish faster. This is also a good candidate for use of threadCount (and possibly threadsPerProcessor) because each task is independent (every new JVM is forked) and has no dependencies on the other tasks.
参考official Apache Ant site了解更多信息。
你好,我正在处理 运行 通过 Ant 调用一一测试的应用程序。在 .bat 文件中调用 build.xml,在其中调用另一个名为 .class 的文件 test 是否有机会在 Ant 中进行并行处理?
我的 ant 配置如下所示:
<target name="testexec-run-pattern" description="=> run JUnit tests by Pattern">
<mkdir dir="${junit.dir}/xml" />
<input addproperty="input.pattern" />
<echo message="Executing pattern: ${input.pattern}" />
<junit showoutput="true" printsummary="on">
<classpath refid="classpath" />
<batchtest todir="${junit.dir}/xml">
<formatter type="xml" extension=".xml" usefile="true" />
<zipfileset src="${test.jar}">
<patternset includes="${input.pattern}" />
</zipfileset>
</batchtest>
</junit>
</target>
其中包含的模式集是 运行 的测试。我希望这些测试 运行 并行。我想我需要像 foreach 这样的东西才能使所有测试在线程中成为 运行。
在 Ant 中,Task 可以使用 parallel
标签并行执行。以下是从 official Apache Ant site 中提取的示例:
<macrodef name="dbpurge">
<attribute file="file"/>
<sequential>
<java jar="utils/dbpurge.jar" fork="true" >
<arg file="@{file} />
</java>
</sequential>
</macrodef><parallel threadCount="4">
<dbpurge file="db/one" />
<dbpurge file="db/two" />
<dbpurge file="db/three" />
<dbpurge file="db/four" />
<dbpurge file="db/five" />
<dbpurge file="db/six" />
<dbpurge file="db/seven" />
<dbpurge file="db/eight" />
<!-- repeated about 40 times -->
</parallel>This example represents a typical need for use of the threadCount and threadsPerProcessor attributes. Spinning up all 40 of those tasks could cripple the system for memory and CPU time. By limiting the number of concurrent executions you can reduce contention for CPU, memory and disk IO, and so actually finish faster. This is also a good candidate for use of threadCount (and possibly threadsPerProcessor) because each task is independent (every new JVM is forked) and has no dependencies on the other tasks.
参考official Apache Ant site了解更多信息。