|
5 | 5 | <property name="build.dir" value="build" />
|
6 | 6 | <property name="jarfile" value="ij.jar" />
|
7 | 7 | <property name="javadoc.dir" value="../api" />
|
| 8 | + <property name="repository" value="https://maven.scijava.org/content/groups/public" /> |
| 9 | + <property name="src-tests.dir" value="tests" /> |
| 10 | + <property name="build-tests.dir" value="${build.dir}/tests" /> |
| 11 | + <property name="build-tests-lib.dir" value="${build.dir}/tests/lib" /> |
8 | 12 |
|
9 |
| - |
10 |
| - <target name="compile" description="Compile everything."> |
| 13 | + <target name="compile" description="Compile the source code."> |
11 | 14 | <!-- First, ensure the build directory exists. -->
|
12 | 15 | <mkdir dir="${build.dir}" />
|
13 | 16 | <!-- Build everything; add debug="on" to debug -->
|
|
26 | 29 | <copy todir="${build.dir}/macros"><fileset dir="macros"/></copy>
|
27 | 30 | <!-- Build ij.jar. -->
|
28 | 31 | <jar jarfile="${jarfile}" basedir="${build.dir}"
|
29 |
| - manifest="MANIFEST.MF" /> |
| 32 | + manifest="MANIFEST.MF" |
| 33 | + excludes="${src-tests.dir}" /> |
30 | 34 | </target>
|
31 | 35 |
|
32 | 36 |
|
|
74 | 78 | </target>
|
75 | 79 |
|
76 | 80 |
|
| 81 | + <target name="compile-tests" depends="compile" description="Compile the unit tests."> |
| 82 | + <!-- First, ensure needed build directories exist. --> |
| 83 | + <mkdir dir="${build-tests.dir}" /> |
| 84 | + <mkdir dir="${build-tests-lib.dir}" /> |
| 85 | + <!-- Download dependencies needed for the unit tests. --> |
| 86 | + <get src="${repository}/junit/junit/4.13.2/junit-4.13.2.jar" |
| 87 | + dest="${build-tests-lib.dir}" skipexisting="true" /> |
| 88 | + <get src="${repository}/org/hamcrest/hamcrest/2.2/hamcrest-2.2.jar" |
| 89 | + dest="${build-tests-lib.dir}" skipexisting="true" /> |
| 90 | + <get src="${repository}/ome/formats-api/6.9.0/formats-api-6.9.0.jar" |
| 91 | + dest="${build-tests-lib.dir}" skipexisting="true" /> |
| 92 | + <get src="${repository}/ome/formats-bsd/6.9.0/formats-bsd-6.9.0.jar" |
| 93 | + dest="${build-tests-lib.dir}" skipexisting="true" /> |
| 94 | + <!-- Build the unit tests in debug mode. --> |
| 95 | + <path id="compile-tests.classpath"> |
| 96 | + <pathelement location="${build.dir}" /> |
| 97 | + <fileset dir="${build-tests-lib.dir}" includes="*.jar" /> |
| 98 | + </path> |
| 99 | + <javac srcdir="${src-tests.dir}" destdir="${build-tests.dir}" classpathref="compile-tests.classpath" |
| 100 | + optimize="on" source="1.8" target="1.8" debug="on" includeantruntime="false" encoding="utf-8" |
| 101 | + excludes="data/**" /> |
| 102 | + </target> |
| 103 | + |
| 104 | + |
| 105 | + <target name="run-tests" depends="compile-tests" description="Run the unit tests."> |
| 106 | + <path id="run-tests.classpath"> |
| 107 | + <pathelement location="${build.dir}" /> |
| 108 | + <pathelement location="${build-tests.dir}" /> |
| 109 | + <fileset dir="${build-tests-lib.dir}" includes="*.jar" /> |
| 110 | + </path> |
| 111 | + <!-- Construct a list of test classes to run. --> |
| 112 | + <path id="test-files"> |
| 113 | + <fileset dir="${src-tests.dir}" includes="**/*Test.java" /> |
| 114 | + </path> |
| 115 | + <pathconvert dirsep="." pathsep=" " property="test-classes" refid="test-files"> |
| 116 | + <regexpmapper from="^.*/tests/(.*)\.java$$" to="\1" /> |
| 117 | + </pathconvert> |
| 118 | + <!-- Run all the test classes. --> |
| 119 | + <java classname="org.junit.runner.JUnitCore" classpathref="run-tests.classpath" fork="yes"> |
| 120 | + <arg line="${test-classes}" /> |
| 121 | + </java> |
| 122 | + </target> |
| 123 | + |
| 124 | + |
77 | 125 | </project>
|
0 commit comments