summaryrefslogtreecommitdiff
path: root/libre/junit/build.xml
blob: 2ad00a86cf2c0852feb6422e35e6e7e0a08ba6cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<project name="junit" default="dist" basedir="."
         xmlns:artifact="antlib:org.apache.maven.artifact.ant">
  <tstamp />
  <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>

  <property file="${user.home}/.junit.properties" />
  <property name="src" value="src/main/java" />
  <property name="srcresources" location="src/main/resources" />
  <property name="target" location="target" />
  <property name="bin" location="${target}/main" />
  <property name="version-base" value="4.12" />
  <property name="version" value="${version-base}" />
  <property name="dist" value="junit${version}" />
  <property name="versionfile" value="${src}/junit/runner/Version.java" />
  <property name="testsrc" location="src/test/java" />
  <property name="testsresources" location="src/test/resources" />
  <property name="testbin" location="${target}/test/java" />
  <property name="unjarred" 
            value="**/*.jar, ${testfiles}, doc/**, README.html, .classpath, .project, cpl-v10.html" />

  <property name="binjar" value="junit-${version}.jar" />
  <property name="srcjar" value="junit-${version}-sources.jar" />

  <property name="javadocdir" location="${dist}/javadoc" />
  <property name="hamcrestlib" location="lib/hamcrest-core-1.3.jar" />

  <target name="init">
    <tstamp/>
  </target>

  <target name="versiontag" depends="init">
    <filter token="version" value="${version}" />
  
    <copy 
        file="${versionfile}.template" 
        tofile="${versionfile}" 
        filtering="on"
        overwrite="true"
        />
  </target>

  <target name="clean">
    <!-- If two builds are made within a minute -->
    <delete dir="${dist}" quiet="true" />
    <!-- Delete all previous temporary build artifacts -->
    <delete dir="${target}" quiet="true" />
  </target>

  <macrodef name="junit_compilation">
    <attribute name="srcdir"/>
    <attribute name="destdir"/>
    <attribute name="classpath"/>
    <sequential>
      <mkdir dir="@{destdir}"/>
      <javac 
          srcdir="@{srcdir}"
          destdir="@{destdir}"
          debug="on"
          classpath="@{classpath}"
          includeantruntime="false"
          source="1.5"
          target="1.5"
          >
        <compilerarg value="-Xlint:unchecked" />
      </javac>
    </sequential>
  </macrodef>
  
  <target name="build" depends="versiontag">
    <junit_compilation srcdir="${src}" destdir="${bin}" classpath="${hamcrestlib}"/>
    <junit_compilation srcdir="${testsrc}" destdir="${testbin}" classpath="${hamcrestlib};${bin}"/>
  </target>

  <target name="jars" depends="build">
    <mkdir dir="${dist}" />
    <jar 
        jarfile="${dist}/${srcjar}"
        basedir="${src}"
        excludes="${unjarred}, **/*.class"
        />
    <jar 
        jarfile="${dist}/${binjar}"
        basedir="${bin}"
        excludes="${unjarred}, **/*.java, build.xml"
        />
  </target>

  <target name="samples-and-tests">
    <copy todir="${dist}">
      <fileset dir="${testbin}" />
      <fileset dir="${testsrc}" />
    </copy>
  </target>
  
  <target name="javadoc">
    <javadoc destdir="${javadocdir}"
             author="false"
             version="false"
             use="false"
             windowtitle="JUnit API"
             stylesheetfile="src/main/javadoc/stylesheet.css"
             >
      <excludepackage name="junit.*" />
      <excludepackage name="org.junit.internal.*" />
      <excludepackage name="org.junit.experimental.theories.internal.*" />
      
      <sourcepath location="${src}" />
      <link href="http://docs.oracle.com/javase/1.5.0/docs/api/" />

      <classpath>
        <pathelement location="${hamcrestlib}" />
      </classpath>
    </javadoc>
  </target>

  <target name="populate-dist" 
          depends="clean, build, jars, samples-and-tests, javadoc"
          >
    <copy todir="${dist}/doc">
      <fileset dir="doc"/>
    </copy>
    <copy file="README.md" tofile="${dist}/README.md" />
    <copy file="BUILDING" tofile="${dist}/BUILDING" />
    <copy file="epl-v10.html" tofile="${dist}/epl-v10.html" />
    <copy file="build.xml" tofile="${dist}/build.xml" />
  </target>

  <macrodef name="run-dist-tests">
    <!-- Runs the tests against the built jar files -->
    <element name="extra-args" implicit="yes" />
    <sequential>
      <java classname="org.junit.runner.JUnitCore" fork="yes" failonerror="true">
        <extra-args />  
        <arg value="org.junit.tests.AllTests"/>
        <classpath>
          <pathelement location="${dist}" />
          <pathelement location="${dist}/${binjar}" />
          <pathelement location="${hamcrestlib}" />
          <pathelement location="${testsresources}" />
        </classpath>
      </java>    
    </sequential>
  </macrodef>

  <macrodef name="run-local-tests">
    <!-- Runs the tests against the local class files -->
    <sequential>
      <java classname="org.junit.runner.JUnitCore" fork="yes" failonerror="true">
        <arg value="org.junit.tests.AllTests"/>
        <classpath>
          <pathelement location="${bin}" />
          <pathelement location="${testbin}" />
          <pathelement location="${hamcrestlib}" />
          <pathelement location="${testsresources}" />
        </classpath>
      </java>    
    </sequential>
  </macrodef>

  <target name="test" depends="build">
    <run-local-tests />
  </target>

  <target name="dist" depends="populate-dist">
    <run-dist-tests>
      <jvmarg value="-Dignore.this=ignored"/>
    </run-dist-tests>
  </target>

  <target name="profile" depends="populate-dist">
    <run-dist-tests>
      <jvmarg value="-agentlib:hprof=cpu=samples"/>
    </run-dist-tests>
  </target>
</project>