11
A
回答
12
用不了多长时间 - 蚂蚁并不难。
下面是一个示例,可重用的build.xml,您可以从中开始。这对我来说是足够通用的重用。目录命名约定应该很容易遵循。我使用模仿IntelliJ输出的布局。
<?xml version="1.0" encoding="UTF-8"?>
<project name="xslt-converter" basedir="." default="package">
<property name="version" value="1.6"/>
<property name="haltonfailure" value="no"/>
<property name="out" value="out"/>
<property name="production.src" value="src"/>
<property name="production.lib" value="lib"/>
<property name="production.resources" value="config"/>
<property name="production.classes" value="${out}/production/${ant.project.name}"/>
<property name="test.src" value="test"/>
<property name="test.lib" value="lib"/>
<property name="test.resources" value="config"/>
<property name="test.classes" value="${out}/test/${ant.project.name}"/>
<property name="exploded" value="out/exploded/${ant.project.name}"/>
<property name="exploded.classes" value="${exploded}/WEB-INF/classes"/>
<property name="exploded.lib" value="${exploded}/WEB-INF/lib"/>
<property name="reports.out" value="${out}/reports"/>
<property name="junit.out" value="${reports.out}/junit"/>
<property name="testng.out" value="${reports.out}/testng"/>
<path id="production.class.path">
<pathelement location="${production.classes}"/>
<pathelement location="${production.resources}"/>
<fileset dir="${production.lib}">
<include name="**/*.jar"/>
<exclude name="**/junit*.jar"/>
<exclude name="**/*test*.jar"/>
</fileset>
</path>
<path id="test.class.path">
<path refid="production.class.path"/>
<pathelement location="${test.classes}"/>
<pathelement location="${test.resources}"/>
<fileset dir="${test.lib}">
<include name="**/junit*.jar"/>
<include name="**/*test*.jar"/>
</fileset>
</path>
<path id="testng.class.path">
<fileset dir="${test.lib}">
<include name="**/testng*.jar"/>
</fileset>
</path>
<available file="${out}" property="outputExists"/>
<target name="clean" description="remove all generated artifacts" if="outputExists">
<delete dir="${out}" includeEmptyDirs="true"/>
<delete dir="${reports.out}" includeEmptyDirs="true"/>
</target>
<target name="create" description="create the output directories" unless="outputExists">
<mkdir dir="${production.classes}"/>
<mkdir dir="${test.classes}"/>
<mkdir dir="${reports.out}"/>
<mkdir dir="${junit.out}"/>
<mkdir dir="${testng.out}"/>
<mkdir dir="${exploded.classes}"/>
<mkdir dir="${exploded.lib}"/>
</target>
<target name="compile" description="compile all .java source files" depends="create">
<!-- Debug output
<property name="production.class.path" refid="production.class.path"/>
<echo message="${production.class.path}"/>
-->
<javac srcdir="src" destdir="${out}/production/${ant.project.name}" debug="on" source="${version}">
<classpath refid="production.class.path"/>
<include name="**/*.java"/>
<exclude name="**/*Test.java"/>
</javac>
<javac srcdir="${test.src}" destdir="${out}/test/${ant.project.name}" debug="on" source="${version}">
<classpath refid="test.class.path"/>
<include name="**/*Test.java"/>
</javac>
</target>
<target name="junit-test" description="run all junit tests" depends="compile">
<!-- Debug output
<property name="test.class.path" refid="test.class.path"/>
<echo message="${test.class.path}"/>
-->
<junit printsummary="yes" haltonfailure="${haltonfailure}">
<classpath refid="test.class.path"/>
<formatter type="xml"/>
<batchtest fork="yes" todir="${junit.out}">
<fileset dir="${test.src}">
<include name="**/*Test.java"/>
</fileset>
</batchtest>
</junit>
<junitreport todir="${junit.out}">
<fileset dir="${junit.out}">
<include name="TEST-*.xml"/>
</fileset>
<report todir="${junit.out}" format="frames"/>
</junitreport>
</target>
<taskdef resource="testngtasks" classpathref="testng.class.path"/>
<target name="testng-test" description="run all testng tests" depends="compile">
<!-- Debug output
<property name="test.class.path" refid="test.class.path"/>
<echo message="${test.class.path}"/>
-->
<testng classpathref="test.class.path" outputDir="${testng.out}" haltOnFailure="${haltonfailure}" verbose="2" parallel="methods" threadcount="50">
<classfileset dir="${out}/test/${ant.project.name}" includes="**/*.class"/>
</testng>
</target>
<target name="exploded" description="create exploded deployment" depends="testng-test">
<copy todir="${exploded.classes}">
<fileset dir="${production.classes}"/>
</copy>
<copy todir="${exploded.lib}">
<fileset dir="${production.lib}"/>
</copy>
</target>
<target name="package" description="create package file" depends="exploded">
<jar destfile="${out}/${ant.project.name}.jar" basedir="${production.classes}" includes="**/*.class"/>
</target>
</project>
8
相关问题
- 1. 学习编写惯用c#的最佳资源是什么?
- 2. 什么是学习.NET webservices的最佳资源?
- 3. 什么是学习(N)ASM的最佳资源?
- 4. 什么是学习基于证据调度的最佳资源?
- 5. 什么是学习XML的最佳资源?
- 6. 什么是学习CIL的最佳资源(MSIL)
- 7. 什么是学习Windows PowerShell的最佳资源?
- 8. 什么是学习Java Portlet Specification(JSR-168)的最佳资源?
- 9. 什么是学习MSBuild的最佳资源?
- 10. iOS:学习使用Interface Builder的最佳资源是什么
- 11. 学习AngularJS的最佳资源
- 12. 学习MVC 3的最佳资源?
- 13. OAuth的最佳学习资源
- 14. 学习Core Data的最佳资源?
- 15. 学习MEAN Stack的最佳资源
- 16. 学习PyGame的最佳资源?
- 17. 学习mediawiki的最佳资源?
- 18. 学习.NET泛型的最佳资源?
- 19. Spring MVC的最佳学习资源?
- 20. 什么是学习XNA的好资源?
- 21. 最佳资源学习JSP和Servlets?
- 22. 什么是学习机器学习的最佳编程语言?
- 23. 学习windbg的功能和优点的最佳资源是什么?
- 24. 什么是学习视觉工作室工具的单一最佳资源?
- 25. 向ASP.NET程序员教授ASP.NET MVC的最佳学习资源是什么?
- 26. 什么是用于学习OpenOffice.org脚本API的(单一)最佳在线资源?
- 27. 什么是学习UML的最佳来源?
- 28. 什么是学习PHP扩展最值得推荐的资源?
- 29. 学习Grails有什么好的资源?
- 30. 学习json有什么好的资源?
谢谢你的例子!我认为这将对未来的参考非常有用。 – frm 2010-07-29 23:35:46
原谅我 - 我发布了错误的文件。现在在那里的那个是我推荐的。我希望你会发现它很干净,易于理解,并且很容易适应你自己的情况。 – duffymo 2010-07-30 00:00:53