OnJava8-Examples/Ant-Common.xml
Bruce Eckel e413ad9a83 tweak
2015-05-05 11:13:35 -07:00

133 lines
4.7 KiB
XML

<project>
<property name="chapter" value="CHAPTER?"/>
<property name="antoutput" value="../Ant-output.txt"/>
<description>
Ant build.xml for the source code for chapter ${chapter}
Thinking in Java Director's Cut by Bruce Eckel
Code available at http://www.MindView.net
See installation instructions in README.md
See copyright notice in CopyRight.txt
Ant available from http://ant.apache.org
To see options, type: ant -p
</description>
<macrodef name="jrun">
<attribute name="cls" default="NOT SET"/>
<attribute name="dirpath" default=""/>
<attribute name="arguments" default=""/>
<attribute name="failOnError" default="true"/>
<attribute name="timeOut" default="15000"/>
<attribute name="msg" default=""/>
<sequential>
<echo>Running: ${chapter} @{cls}&#13;</echo>
<echo file="${antoutput}" append="true">Running: ${chapter} @{cls}&#13;</echo>
<java
classname="@{cls}"
classpath="${java.class.path};${basedir};${basedir}/.."
dir="@{dirpath}"
failonerror="@{failOnError}"
fork="true"
timeout="@{timeOut}"
output="${antoutput}" append="true">
<arg line="@{arguments}"/>
</java>
<echo file="${antoutput}" append="true">Finished: ${chapter} @{cls}&#13;</echo>
<echo file="${antoutput}" append="true">@{msg}&#13;</echo>
<echo file="${antoutput}" append="true">--------------------------------&#13;</echo>
</sequential>
</macrodef>
<macrodef name="jrunconsole">
<attribute name="cls" default="NOT SET"/>
<attribute name="dirpath" default=""/>
<attribute name="arguments" default=""/>
<attribute name="failOnError" default="true"/>
<attribute name="timeOut" default="15000"/>
<attribute name="msg" default=""/>
<sequential>
<echo>Running: ${chapter} @{cls}&#13;</echo>
<echo append="true">Running: ${chapter} @{cls}&#13;</echo>
<java
classname="@{cls}"
classpath="${java.class.path};${basedir};${basedir}/.."
dir="@{dirpath}"
failonerror="@{failOnError}"
fork="true"
timeout="@{timeOut}"
>
<arg line="@{arguments}"/>
</java>
<echo append="true">Finished: ${chapter} @{cls}&#13;</echo>
<echo append="true">@{msg}&#13;</echo>
<echo append="true">--------------------------------&#13;</echo>
</sequential>
</macrodef>
<condition property="version1.8">
<equals arg1="1.8" arg2="${ant.java.version}"/>
</condition>
<target name="base">
<javac includeantruntime="false"
classpath="${java.class.path};${basedir};${basedir}/.."
srcdir="${basedir}/../net/mindview/">
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
<javac includeantruntime="false"
classpath="${java.class.path};${basedir};${basedir}/.."
srcdir="${basedir}/../typeinfo/pets/">
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
<javac includeantruntime="false"
classpath="${java.class.path};${basedir};${basedir}/.."
srcdir="${basedir}/../generics/coffee/">
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
</target>
<target
depends="base"
description="Build all classes in this directory"
name="build">
<fail message="Java 8 required" unless="version1.8"/>
<echo message="Building '${chapter}'&#13;"/>
<echo file="${antoutput}" append="true" message="Building '${chapter}'&#13;"/>
<javac includeantruntime="false"
classpath="${java.class.path};${basedir};${basedir}/.."
debug="true"
excludes="${excludedfiles}"
srcdir="${basedir}">
<compilerarg value="-Xmaxerrs"/>
<compilerarg value="10"/>
</javac>
<echo message="Build '${chapter}' succeeded&#13;"/>
<echo file="${antoutput}" append="true" message="Build '${chapter}' succeeded&#13;"/>
</target>
<target description="delete all byproducts" name="clean">
<delete>
<fileset dir="${basedir}" casesensitive="yes">
<include name="**/*.class" />
<include name="**/*Output.txt" />
<include name="**/log.txt" />
<include name="failures test.txt test2.txt" />
<exclude name="*.java"/>
<exclude name="DogsAndRobots.py PythonLists.py"/>
<exclude name="Copyright.txt Templates.cpp InstantiateGenericType.cpp Mixins.cpp"/>
<exclude name="DogsAndRobots.cpp VendingMachineInput.txt Trash.dat DDTrash.dat VTrash.dat log.prop"/>
<exclude name="Face*.gif"/>
<exclude name="build.xml"/>
</fileset>
</delete>
<echo message="clean successful"/>
</target>
</project>