-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.xml
More file actions
132 lines (118 loc) · 4.59 KB
/
Copy pathbuild.xml
File metadata and controls
132 lines (118 loc) · 4.59 KB
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
<project name="Chess Engine" default="jar" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<description>
A chess engine written in Java
</description>
<!-- global properties -->
<property name="verbose.output" value="false"/>
<property name="src.dir" location="src"/>
<property name="build.dir" location="build"/>
<property name="dist.dir" location="dist"/>
<property name="test.dir" location="test"/>
<property name="classes.dir" location="${build.dir}/classes"/>
<property name="test.classes.dir" value="build/tests"/>
<property name="doc.dir" location="doc"/>
<property name="report.dir" location="report"/>
<property name="Main-Class" value="com.dalton.ChessEngine.Main"/>
<property name="jar.file" location="dist/ChessEngine.jar"/>
<property name="report.dir" location="report" />
<path id="classpath.base">
<pathelement location="${classes.dir}"/>
</path>
<path id="classpath.test">
<pathelement location="${user.home}/.ant/lib/ant-junit.jar"/>
<pathelement location="${user.home}/.ant/lib/junit.jar"/>
<pathelement location="${test.classes.dir}"/>
<path refid="classpath.base"/>
</path>
<condition property="libs.installed">
<and>
<isset property="junit.installed"/>
<isset property="hamcrest.installed"/>
</and>
</condition>
<target name="install-junit" unless="libs.installed" >
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/junit.jar" src="http://search.maven.org/remotecontent?filepath=junit/junit/4.12/junit-4.12.jar" unless:set="junit.installed"/>
<get dest="${user.home}/.ant/lib/ant-junit.jar" src="http://search.maven.org/remotecontent?filepath=org/apache/ant/ant-junit/1.9.6/ant-junit-1.9.6.jar" unless:set="junit.installed"/>
<get dest="${user.home}/.ant/lib/hamcrest-core.jar" src="http://search.maven.org/remotecontent?filepath=org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar" unless:set="hamcrest.installed"/>
<fail message="Required libraries installed. Re-run the build"/>
</target>
<target name="init">
<!-- time stamp -->
<tstamp/>
<!-- Create a build directory -->
<mkdir dir="${build.dir}"/>
<mkdir dir="${report.dir}"/>
<mkdir dir="${dist.dir}"/>
</target>
<target name="javadoc" description="Generate the Javadoc Documentation files">
<javadoc
packagenames="com.dalton.*"
sourcepath="${src.dir}" destdir="${doc.dir}"
author="true" version="true"
windowTitle="${ant.project.name}"
private="true"
linksource="yes">
<bottom><![CDATA[<i>Copyright © Dalton Herrewynen.</i>]]></bottom>
</javadoc>
</target>
<target name="compile" depends="init" description="compile the source">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}"/>
</target>
<target name="jar" depends="compile" description="generate the distributable JAR file">
<mkdir dir="${dist.dir}"/>
<!-- Put everything in ${build} into the ChessEngine.jar file -->
<jar jarfile="${dist.dir}/ChessEngine.jar" basedir="${classes.dir}">
<manifest><attribute name="Main-Class" value="${Main-Class}"/></manifest>
</jar>
<exec executable="cp">
<arg value="./launch.sh"/>
<arg value="${dist.dir}/launch.sh"/>
</exec>
</target>
<target name="run" depends="jar" description="Run the program">
<java jar="${jar.file}" fork="true">
<arg line="${args}"/>
</java>
</target>
<target name="clean-tests">
<delete dir="${test.classes.dir}"/>
</target>
<target name="compile-test" depends="compile">
<mkdir dir="${test.classes.dir}"/>
<javac srcdir="${test.dir}" destdir="${test.classes.dir}" verbose="${verbose.output}" includeantruntime="false" debug="on">
<classpath refid="classpath.test"/>
</javac>
</target>
<target name="run-tests" depends="compile-test">
<junit printsummary="no" haltonfailure="no">
<classpath refid="classpath.test"/>
<batchtest todir="${report.dir}">
<fileset dir="${test.classes.dir}">
<include name="**/*Test*"/>
</fileset>
</batchtest>
<formatter type="xml"/>
<formatter type="brief" usefile="false"/>
</junit>
</target>
<target name="test" depends="clean,run-tests" description="Generate Test Report">
<junitreport todir="${report.dir}">
<fileset dir="${report.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${report.dir}/html"/>
</junitreport>
<delete>
<fileset dir="${report.dir}" includes="TEST*.xml"/>
</delete>
</target>
<target name="clean" description="Clean up, remove build files and documentation">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
<delete dir="${report.dir}"/>
<delete dir="${doc.dir}"/>
<delete dir="out"/>
</target>
</project>