Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 533756d

Browse files
committed
Automatic download of JUnit JAR file added
1 parent 219cc9a commit 533756d

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

build.xml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
<!-- Ant build file for base64coder Java version -->
22
<project name="base64Coder" default="buildAll">
33

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"/>
1222

1323
<target name="buildAll" description="Compiles and generates the API docs."
14-
depends="buildJar, javaDoc">
15-
</target>
24+
depends="buildJar, javaDoc"/>
1625

1726
<target name="buildJar" description="Compiles the Java source and builds the JAR file.">
1827
<delete dir="${classesDir}" failonerror="true"/>
@@ -27,15 +36,15 @@
2736
<delete dir="${classesDir}" failonerror="true"/>
2837
</target>
2938

30-
<target name="compileTest" description="Compiles the test class.">
39+
<target name="compileTest" description="Compiles the test class." depends="getJUnitJar">
3140
<delete dir="${testClassesDir}" failonerror="true"/>
3241
<mkdir dir="${testClassesDir}"/>
3342
<!-- Note: The "Sun proprietary" warnings cannot be suppressed as of 2010-02. -->
3443
<javac srcdir="${testSrcDir}" deprecation="true" includeAntRuntime="false" debug="true" debuglevel="lines,source"
3544
target="1.5" destdir="${testClassesDir}">
3645
<compilerarg line="-Xlint -Xmaxerrs 6"/>
3746
<classpath>
38-
<pathelement location="${junitJar}"/>
47+
<pathelement location="${jUnitJar}"/>
3948
<pathelement location="${jarFile}"/>
4049
</classpath>
4150
</javac>
@@ -58,12 +67,12 @@
5867
</target>
5968

6069
<target name="test" description="Runs the JUnit tests."
61-
depends="compileTest">
70+
depends="compileTest, getJUnitJar">
6271
<delete dir="${testReportsDir}" failonerror="true"/>
6372
<mkdir dir="${testReportsDir}"/>
64-
<junit haltonfailure="on">
73+
<junit haltonfailure="true">
6574
<classpath>
66-
<pathelement location="${junitJar}"/>
75+
<pathelement location="${jUnitJar}"/>
6776
<pathelement location="${jarFile}"/>
6877
<pathelement location="${testClassesDir}"/>
6978
</classpath>
@@ -72,4 +81,16 @@
7281
</junit>
7382
</target>
7483

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+
7596
</project>

lib/junit-4.8.1.jar

-231 KB
Binary file not shown.

0 commit comments

Comments
 (0)