|
1 | 1 | <!-- Ant build file for base64coder Java version -->
|
2 | 2 | <project name="base64Coder" default="buildAll">
|
3 | 3 |
|
4 |
| -<property name="srcDir" location="src/main/java"/> |
5 |
| -<property name="classesDir" location="target/classes"/> |
6 |
| -<property name="javaDocDir" location="target/javadoc"/> |
7 |
| -<property name="jarFile" location="target/base64coder.jar"/> |
8 |
| -<property name="junitJar" location="lib/junit-4.8.1.jar"/> |
9 |
| -<property name="testSrcDir" location="src/test/java"/> |
10 |
| -<property name="testClassesDir" location="target/test-classes"/> |
11 |
| -<property name="testReportsDir" location="target/test-reports"/> |
| 4 | +<fail message="This buildfile requires at least Ant 1.8."> |
| 5 | + <condition> |
| 6 | + <not> |
| 7 | + <antversion atleast="1.8"/> |
| 8 | + </not> |
| 9 | + </condition> |
| 10 | +</fail> |
| 11 | + |
| 12 | +<property environment="env"/> |
| 13 | + |
| 14 | +<property name="srcDir" location="src/main/java"/> |
| 15 | +<property name="classesDir" location="target/classes"/> |
| 16 | +<property name="javaDocDir" location="target/javadoc"/> |
| 17 | +<property name="jarFile" location="target/base64coder.jar"/> |
| 18 | +<property name="testSrcDir" location="src/test/java"/> |
| 19 | +<property name="testClassesDir" location="target/test-classes"/> |
| 20 | +<property name="testReportsDir" location="target/test-reports"/> |
| 21 | +<property name="jUnitVersionToDownload" value="4.7"/> |
12 | 22 |
|
13 | 23 | <target name="buildAll" description="Compiles and generates the API docs."
|
14 |
| - depends="buildJar, javaDoc"> |
15 |
| -</target> |
| 24 | + depends="buildJar, javaDoc"/> |
16 | 25 |
|
17 | 26 | <target name="buildJar" description="Compiles the Java source and builds the JAR file.">
|
18 | 27 | <delete dir="${classesDir}" failonerror="true"/>
|
|
27 | 36 | <delete dir="${classesDir}" failonerror="true"/>
|
28 | 37 | </target>
|
29 | 38 |
|
30 |
| -<target name="compileTest" description="Compiles the test class."> |
| 39 | +<target name="compileTest" description="Compiles the test class." depends="getJUnitJar"> |
31 | 40 | <delete dir="${testClassesDir}" failonerror="true"/>
|
32 | 41 | <mkdir dir="${testClassesDir}"/>
|
33 | 42 | <!-- Note: The "Sun proprietary" warnings cannot be suppressed as of 2010-02. -->
|
34 | 43 | <javac srcdir="${testSrcDir}" deprecation="true" includeAntRuntime="false" debug="true" debuglevel="lines,source"
|
35 | 44 | target="1.5" destdir="${testClassesDir}">
|
36 | 45 | <compilerarg line="-Xlint -Xmaxerrs 6"/>
|
37 | 46 | <classpath>
|
38 |
| - <pathelement location="${junitJar}"/> |
| 47 | + <pathelement location="${jUnitJar}"/> |
39 | 48 | <pathelement location="${jarFile}"/>
|
40 | 49 | </classpath>
|
41 | 50 | </javac>
|
|
58 | 67 | </target>
|
59 | 68 |
|
60 | 69 | <target name="test" description="Runs the JUnit tests."
|
61 |
| - depends="compileTest"> |
| 70 | + depends="compileTest, getJUnitJar"> |
62 | 71 | <delete dir="${testReportsDir}" failonerror="true"/>
|
63 | 72 | <mkdir dir="${testReportsDir}"/>
|
64 |
| - <junit haltonfailure="on"> |
| 73 | + <junit haltonfailure="true"> |
65 | 74 | <classpath>
|
66 |
| - <pathelement location="${junitJar}"/> |
| 75 | + <pathelement location="${jUnitJar}"/> |
67 | 76 | <pathelement location="${jarFile}"/>
|
68 | 77 | <pathelement location="${testClassesDir}"/>
|
69 | 78 | </classpath>
|
|
72 | 81 | </junit>
|
73 | 82 | </target>
|
74 | 83 |
|
| 84 | +<target name="getJUnitJar" depends="getJUnitJar2" unless="jUnitJar"> |
| 85 | + <!-- Download the JUnit JAR file from the central Maven repository. --> |
| 86 | + <property name="jUnitJar" location="target/junit-${jUnitVersionToDownload}.jar"/> |
| 87 | + <get src="http://repo1.maven.org/maven2/junit/junit/${jUnitVersionToDownload}/junit-${jUnitVersionToDownload}.jar" dest="${jUnitJar}" skipexisting="true"/> |
| 88 | +</target> |
| 89 | +<target name="getJUnitJar2" unless="jUnitJar"> |
| 90 | + <!-- The OS environment variable JUNIT_JAR can be set to the path name of the JUnit JAR file. --> |
| 91 | + <condition property="jUnitJar" value="${env.JUNIT_JAR}"> |
| 92 | + <isset property="env.JUNIT_JAR"/> |
| 93 | + </condition> |
| 94 | +</target> |
| 95 | + |
75 | 96 | </project>
|
0 commit comments