4 build.xml - the JPF core build script
5 using Ant (http://jakarta.apache.org/ant)
8 build (default) compile classes and build JPF jar files
9 compile compile JPF and its specific (modeled) environment libraries
10 test run all JPF tests
11 clean remove the files that have been generated by the build process
12 buildinfo create buildinfo properties file
15 <project name="jpf-core" default="build" basedir=".">
17 <!-- ===================== ===== COMMON SECTION ========================== -->
20 local props have to come first, because Ant properties are immutable
21 NOTE: this file is local - it is never in the repository!
23 <property file="local.properties"/>
24 <property environment="env"/>
26 <!-- compiler settings -->
27 <property name="debug" value="on"/>
28 <property name="deprecation" value="on"/>
30 <uptodate property="build_uptodate" targetfile="build/main/gov/nasa/jpf/build.properties" srcfile="build.properties"/>
33 <!-- generic classpath settings -->
35 <pathelement location="build/main"/>
36 <pathelement location="build/peers"/>
37 <pathelement location="build/annotations"/>
39 <include name="lib/*.jar"/>
44 <!-- init: common initialization -->
48 <mkdir dir="build"/> <!-- the build root -->
50 <!-- the things that have to be in the classpath of whatever runs Ant -->
51 <available property="have_javac" classname="com.sun.tools.javac.Main"/>
52 <fail unless="have_javac">no javac was found __or__ check http://babelfish.arc.nasa.gov/trac/jpf/wiki/install/build for possible solutions</fail>
55 <available file="src/main" type="dir" property="have_main"/>
56 <available file="src/annotations" type="dir" property="have_annotations"/>
57 <available file="src/peers" type="dir" property="have_peers"/>
58 <available file="src/classes" type="dir" property="have_classes"/>
59 <available file="src/tests" type="dir" property="have_tests"/>
60 <available file="src/examples" type="dir" property="have_examples"/>
62 <available file=".hg" type="dir" property="have_hg"/>
64 <!-- for the core, it's a fail if any of these is missing -->
65 <fail unless="have_main">no src/main</fail>
66 <fail unless="have_annotations">no src/annotations</fail>
67 <fail unless="have_peers">no src/peers</fail>
68 <fail unless="have_classes">no src/classes</fail>
69 <fail unless="have_tests">no src/tests</fail>
70 <fail unless="have_examples">no src/examples</fail>
72 <condition property="have_java8">
73 <equals arg1="${ant.java.version}" arg2="1.8"/>
79 <!-- ======================= COMPILE SECTION ============================= -->
81 <!-- public compile -->
82 <target name="compile" depends="-init,-compile-annotations,-compile-main,-compile-peers,-compile-classes,-compile-tests,-compile-examples"
83 description="compile all JPF core sources" >
84 <copy file="build.properties" todir="build/main/gov/nasa/jpf" failonerror="false"/>
87 <target name="-compile-annotations" if="have_annotations">
88 <mkdir dir="build/annotations"/>
89 <javac srcdir="src/annotations" destdir="build/annotations" includeantruntime="false"
90 debug="${debug}" deprecation="${deprecation}" classpath=""/>
93 <target name="-compile-main" if="have_main">
94 <mkdir dir="build/main"/>
95 <javac srcdir="src/main" destdir="build/main" includeantruntime="false"
96 debug="${debug}" deprecation="${deprecation}" classpathref="lib.path">
98 <compilerarg value="-XDenableSunApiLintControl"/>
99 <compilerarg value="-Xlint:all"/>
105 <target name="-compile-peers" if="have_peers" depends="-compile-main" >
106 <mkdir dir="build/peers"/>
107 <javac srcdir="src/peers" destdir="build/peers" includeantruntime="false"
108 debug="${debug}" deprecation="${deprecation}" classpathref="lib.path">
109 <compilerarg value="-XDenableSunApiLintControl"/>
110 <compilerarg value="-Xlint:all,-sunapi,-serial"/>
114 <target name="-compile-classes" if="have_classes" depends="-compile-annotations,-compile-main" >
115 <mkdir dir="build/classes"/>
116 <javac srcdir="src/classes" destdir="build/classes" includeantruntime="false"
117 debug="${debug}" deprecation="${deprecation}">
118 <compilerarg value="-XDenableSunApiLintControl"/>
119 <compilerarg value="-Xlint:all,-sunapi"/>
121 <path refid="lib.path"/>
122 <pathelement location="build/annotations"/>
127 <target name="-compile-tests" if="have_tests" depends="-compile-annotations,-compile-main,-compile-classes">
128 <mkdir dir="build/tests"/>
130 <javac sourcepath="" srcdir="src/tests" destdir="build/tests" includeantruntime="false"
131 debug="${debug}" deprecation="${deprecation}"
132 includes="*,gov/nasa/jpf/**,classloader_specific_tests/**">
133 <compilerarg value="-XDenableSunApiLintControl"/>
134 <compilerarg value="-Xlint:all,-sunapi,-serial,-rawtypes,-unchecked"/>
136 <include name="*gov/nasa/jpf/**"/>
137 <include name="classloader_specific_tests/**"/>
138 <include name="java8/**" if="have_java8"/>
141 <path refid="lib.path"/>
142 <pathelement location="build/annotations"/>
143 <pathelement location="build/classes"/>
148 <target name="-compile-examples" if="have_examples" depends="-compile-annotations,-compile-main">
149 <mkdir dir="build/examples" />
150 <javac srcdir="src/examples" destdir="build/examples" includeantruntime="false"
151 debug="${debug}" deprecation="${deprecation}"
152 classpathref="lib.path"/>
156 <!-- ======================= MISC SECTION ================================ -->
158 <target name="-version" if="have_hg">
159 <exec executable="hg" outputproperty="version" searchpath="true" failonerror="false" failifexecutionfails="false">
160 <arg value="identify"/>
164 <!-- .version is in .hgignore -->
165 <echo message="${version}${line.separator}" file=".version"/>
169 <target name="build" depends="-cond-clean,compile,-version"
170 description="generate the core JPF jar files" >
172 <copy file=".version" todir="build/main/gov/nasa/jpf" failonerror="false"/>
174 <jar jarfile="build/jpf-classes.jar">
175 <fileset dir="build/classes"/>
176 <fileset dir="build/annotations"/>
178 <fileset dir="build/main">
179 <!-- we need this one in case a SUT uses the Verify API -->
180 <include name="gov/nasa/jpf/vm/Verify.class"/>
182 <!-- these are required if we run TestJPF derived test classes -->
183 <include name="gov/nasa/jpf/JPFShell.class"/>
184 <include name="gov/nasa/jpf/util/TypeRef.class"/>
185 <include name="gov/nasa/jpf/util/test/TestJPF.class"/>
186 <include name="gov/nasa/jpf/util/test/TestMultiProcessJPF.class"/>
187 <include name="gov/nasa/jpf/util/test/TestJPFHelper.class"/>
191 <jar jarfile="build/jpf.jar" index="true">
192 <fileset dir="build/main"/>
193 <fileset dir="build/peers"/>
194 <!-- this is redundant, but if JPF is executed from java.class.path it wouldn't find annotations -->
195 <fileset dir="build/annotations"/>
197 <!-- this is for annotations used by JPF regression tests, which can also be executed outside of junit -->
198 <fileset dir="build/classes">
199 <include name="org/junit/*.class"/>
203 <attribute name="Built-By" value="${user.name}"/>
204 <attribute name="Implementation-Vendor" value="NASA Ames Research Center"/>
205 <attribute name="Implementation-Title" value="Java Pathfinder core system"/>
206 <attribute name="Implementation-Version" value="${jpf.version}"/>
210 <!-- optional jar that contains annotations to be used in non-JPF dependent apps -->
211 <jar jarfile="build/jpf-annotations.jar">
212 <fileset dir="build/annotations"/>
215 <!-- this jar is needed to test classloaders, it is used by URLClassLoaderTest -->
216 <jar jarfile="build/classloader_specific_tests.jar">
217 <fileset dir="build/tests">
218 <include name="classloader_specific_tests/*.class"/>
222 <jar jarfile="build/RunJPF.jar">
223 <fileset dir="build/main">
224 <include name="gov/nasa/jpf/tool/Run.class"/>
225 <include name="gov/nasa/jpf/tool/RunJPF.class"/>
226 <include name="gov/nasa/jpf/Config.class"/>
227 <include name="gov/nasa/jpf/ConfigChangeListener.class"/>
228 <include name="gov/nasa/jpf/Config$MissingRequiredKeyException.class"/>
229 <include name="gov/nasa/jpf/JPFClassLoader.class"/>
230 <include name="gov/nasa/jpf/JPFShell.class"/>
231 <include name="gov/nasa/jpf/JPFException.class"/>
232 <include name="gov/nasa/jpf/JPFConfigException.class"/>
233 <include name="gov/nasa/jpf/JPFTargetException.class"/>
234 <include name="gov/nasa/jpf/util/JPFSiteUtils.class"/>
235 <include name="gov/nasa/jpf/util/FileUtils.class"/>
236 <include name="gov/nasa/jpf/util/StringMatcher.class"/>
237 <include name="gov/nasa/jpf/util/Pair.class"/>
241 <attribute name="Built-By" value="${user.name}"/>
242 <attribute name="Implementation-Vendor" value="NASA Ames Research Center"/>
243 <attribute name="Implementation-Title" value="Java Pathfinder core launch system"/>
244 <attribute name="Implementation-Version" value="${jpf.version}"/>
245 <attribute name="Main-Class" value="gov.nasa.jpf.tool.RunJPF"/>
249 <jar jarfile="build/RunTest.jar">
250 <fileset dir="build/main">
251 <include name="gov/nasa/jpf/tool/Run.class"/>
252 <include name="gov/nasa/jpf/tool/RunTest.class"/>
253 <include name="gov/nasa/jpf/tool/RunTest$Failed.class"/>
254 <include name="gov/nasa/jpf/Config.class"/>
255 <include name="gov/nasa/jpf/ConfigChangeListener.class"/>
256 <include name="gov/nasa/jpf/Config$MissingRequiredKeyException.class"/>
257 <include name="gov/nasa/jpf/JPFClassLoader.class"/>
258 <include name="gov/nasa/jpf/JPFException.class"/>
259 <include name="gov/nasa/jpf/JPFConfigException.class"/>
260 <include name="gov/nasa/jpf/util/JPFSiteUtils.class"/>
261 <include name="gov/nasa/jpf/util/FileUtils.class"/>
262 <include name="gov/nasa/jpf/util/StringMatcher.class"/>
263 <include name="gov/nasa/jpf/util/DevNullPrintStream.class"/>
266 <attribute name="Built-By" value="${user.name}"/>
267 <attribute name="Implementation-Vendor" value="NASA Ames Research Center"/>
268 <attribute name="Implementation-Title" value="Java Pathfinder test launch system"/>
269 <attribute name="Implementation-Version" value="${jpf.version}"/>
270 <attribute name="Main-Class" value="gov.nasa.jpf.tool.RunTest"/>
277 <!-- public clean: cleanup from previous tasks/builds -->
279 description="remove all build artifacts and temporary files">
280 <delete dir="build" failonerror="false"/>
281 <delete dir="tmp" failonerror="false"/>
283 <fileset dir="." includes="**/*~" defaultexcludes="no" />
284 <fileset dir="." includes="**/*.bak" defaultexcludes="no" />
285 <fileset dir="." includes="**/error.xml" />
289 <target name="-cond-clean" unless="build_uptodate"
290 description="remove all build artifacts and temporaries if build.properties has been changed">
291 <antcall target="clean"/>
295 <!-- generate buildinfo file -->
296 <target name="buildinfo" description="create buildinfo properties">
298 <!-- make this fail if there are uncommitted changes -->
299 <exec executable="hg" outputproperty="uncommitted_changes" failifexecutionfails="true">
300 <arg value="status"/>
302 <condition property="have_uncommitted_changes">
303 <length string="${uncommitted_changes}" trim="true" when="greater" length="0"/>
306 <fail if="have_uncommitted_changes">hg status shows uncommitted changes:
307 ${uncommitted_changes}
310 <exec executable="hg" outputproperty="hg.tip.id" failifexecutionfails="false">
312 <arg value="--template"/>
313 <arg value="{rev}:{node|short}\n"/>
315 <exec executable="hg" outputproperty="hg.author" failifexecutionfails="false">
317 <arg value="--template"/>
318 <arg value="{author}\n"/>
320 <exec executable="hg" outputproperty="hg.tip.date" failifexecutionfails="false">
322 <arg value="--template"/>
323 <arg value="{date|isodate}\n"/>
325 <exec executable="hg" outputproperty="hg.paths.default" failifexecutionfails="false">
326 <arg value="showconfig"/>
327 <arg value="paths.default"/>
330 <exec executable="hostname" failifexecutionfails="false" outputproperty="env.COMPUTERNAME"/>
331 <property name="hostname" value="${env.COMPUTERNAME}"/> <!-- Windows doesn't have hostname -->
333 <!-- it seems the 'propertyfile' task just appends -->
334 <delete file="build.properties" failonerror="false"/>
336 <propertyfile file="build.properties" comment="JPF core build info">
337 <entry key="revision" value="${hg.tip.id}"/>
338 <entry key="date.tip" value="${hg.tip.date}"/>
340 <entry key="author" value="${hg.author}"/>
341 <entry key="repository" value="file://${hostname}${basedir}"/>
342 <entry key="upstream" value="${hg.paths.default}"/>
344 <entry key="java.version" value="${java.version}"/>
346 <entry key="os.arch" value="${os.arch}"/>
347 <entry key="os.name" value="${os.name}"/>
348 <entry key="os.version" value="${os.version}"/>
349 <entry key="user.country" value="${user.country}"/>
355 <target name="dist" description="build binary distribution">
356 <delete file="build/${ant.project.name}*.zip"/>
358 <exec executable="hg" outputproperty="hg.tip.rev" failifexecutionfails="false">
360 <arg value="--template"/>
361 <arg value="-r{rev}"/>
364 <!-- 2do this seems stupid - there needs to be a better way to re-base (zip basedir fails miserably) -->
365 <zip destfile="build/${ant.project.name}${hg.tip.rev}.zip" update="false" excludes="*">
366 <zipfileset file="jpf.properties" prefix="${ant.project.name}"/>
367 <zipfileset file="build.properties" prefix="${ant.project.name}"/>
368 <zipfileset dir="lib" prefix="${ant.project.name}/lib"/>
369 <zipfileset dir="bin" prefix="${ant.project.name}/bin" filemode="754"/>
370 <zipfileset dir="build" includes="*.jar" prefix="${ant.project.name}/build"/>
374 <target name="src-dist" description="build source distribution">
375 <delete file="build/${ant.project.name}*-src.zip"/>
377 <exec executable="hg" outputproperty="hg.tip.rev" failifexecutionfails="false">
379 <arg value="--template"/>
380 <arg value="-r{rev}"/>
383 <zip destfile="build/${ant.project.name}${hg.tip.rev}-src.zip" update="false" excludes="*" whenempty="skip">
384 <zipfileset file="jpf.properties" prefix="${ant.project.name}"/>
385 <zipfileset file="build.properties" prefix="${ant.project.name}"/>
386 <zipfileset file="build.xml" prefix="${ant.project.name}"/>
387 <zipfileset file="LICENSE-2.0.txt" prefix="${ant.project.name}"/>
388 <zipfileset file="README" prefix="${ant.project.name}"/>
389 <zipfileset dir="src" prefix="${ant.project.name}/src"/>
390 <zipfileset dir="lib" prefix="${ant.project.name}/lib" erroronmissingdir="false"/>
391 <zipfileset dir="bin" prefix="${ant.project.name}/bin" filemode="754"/>
392 <zipfileset dir="tools" prefix="${ant.project.name}/tools" erroronmissingdir="false"/>
394 <!-- IDE related configuration files -->
395 <zipfileset file=".project" prefix="${ant.project.name}"/>
396 <zipfileset file=".classpath" prefix="${ant.project.name}"/>
397 <zipfileset dir="eclipse" prefix="${ant.project.name}/eclipse"/>
399 <zipfileset dir="nbproject" prefix="${ant.project.name}/nbproject"/>
403 <!-- ======================= TEST SECTION ================================ -->
407 <target name="test" depends="build"
408 description="run core regression tests" if="have_tests">
410 <!-- note this can be directly set in local.properties, which overrides this setting -->
411 <property name="junit.home" value="${env.JUNIT_HOME}"/>
413 <condition property="junit.usefile">
414 <!-- don't set if this is running from within an IDE that collects output -->
416 <isset property="netbeans.home"/>
420 <junit printsummary="on" showoutput="off"
421 haltonfailure="no" logfailedtests="true" failureproperty="test.failed"
422 dir="${basedir}" fork="yes" forkmode="perTest" maxmemory="1024m" outputtoformatters="true">
423 <formatter type="plain" usefile="${junit.usefile}"/>
430 <path refid="lib.path"/>
431 <pathelement location="build/tests"/>
432 <pathelement location="build/classes"/>
433 <pathelement location="build/annotations"/>
435 <fileset dir="${junit.home}">
436 <include name="**/*.jar"/>
440 <batchtest todir="build/tests">
441 <fileset dir="build/tests">
442 <exclude name="**/JPF_*.class"/>
443 <include name="**/*Test.class"/>
445 <exclude name="**/SplitInputStreamTest.class"/>
451 <fail if="test.failed" />