-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.xml
150 lines (138 loc) · 5.49 KB
/
build.xml
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
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="run" name="PioTxt" basedir=".">
<!-- - - - - - - - - - - - - - - - - -
config: properties & filesets
- - - - - - - - - - - - - - - - - -->
<property name="dir.lib" value="lib" />
<property name="dir.resources" value="resources" />
<property name="dir.build" value="build" />
<property name="jar.runnable" value="piotxt.jar" />
<property name="dir.src" value="src" />
<property name="dir.src.src" value="${dir.src}/source" />
<property name="dir.src.test" value="${dir.src}/test" />
<property name="dir.target" value="target" />
<property name="dir.target.src" value="${dir.target}/source" />
<property name="dir.target.test" value="${dir.target}/test" />
<fileset id="set.libraries" dir="${dir.lib}">
<exclude name="junit*.jar"/>
<include name="*.jar" />
</fileset>
<!-- - - - - - - - - - - - - - - - - -
config: classpaths
- - - - - - - - - - - - - - - - - -->
<path id="classpath.compile">
<fileset refid="set.libraries" />
</path>
<path id="classpath.test">
<fileset refid="set.libraries" />
<fileset dir=".">
<include name="${dir.lib}/junit*.jar" />
</fileset>
<pathelement path="${dir.target.src}" />
<pathelement path="${dir.target.test}" />
</path>
<!-- - - - - - - - - - - - - - - - - -
target: debug
- - - - - - - - - - - - - - - - - -->
<target name="debug" description="print out ant properties as needed">
<property name="print" refid="classpath.test"/>
<echo message="files = ${print}"/>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: clean
- - - - - - - - - - - - - - - - - -->
<target name="clean" description="remove ${dir.target}">
<delete dir="${dir.target}" />
<delete dir="${dir.build}" />
</target>
<!-- - - - - - - - - - - - - - - - - -
target: compile-source
- - - - - - - - - - - - - - - - - -->
<target name="compile-source" description="compile all .java files in ${dir.src.src}">
<mkdir dir="${dir.target}" />
<mkdir dir="${dir.target.src}" />
<javac destdir="${dir.target.src}" srcdir="${dir.src.src}" includeAntRuntime="true">
<classpath refid="classpath.compile" />
</javac>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: compile
- - - - - - - - - - - - - - - - - -->
<target name="compile" description="compile all .java files in ${dir.src}">
<mkdir dir="${dir.target}" />
<mkdir dir="${dir.target.src}" />
<javac destdir="${dir.target.src}" srcdir="${dir.src.src}" includeAntRuntime="true">
<classpath refid="classpath.compile" />
</javac>
<mkdir dir="${dir.target.test}" />
<javac destdir="${dir.target.test}" srcdir="${dir.src.test}" includeAntRuntime="true">
<classpath refid="classpath.test" />
</javac>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: test
- - - - - - - - - - - - - - - - - -->
<target name="test" depends="compile" description="run all junit test cases">
<junit printsummary="true" haltonfailure="false">
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="${dir.target.test}" includes="**/*Test.class" />
</batchtest>
</junit>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: build
- - - - - - - - - - - - - - - - - -->
<target name="build" depends="clean,compile-source" description="create runnable .jar">
<!-- Genertate DSTAMP, TSTAMP, and TODAY -->
<tstamp />
<!-- Extract git metadata to properties. -->
<exec executable="git" outputproperty="git.commit">
<arg value="log" />
<arg value="-1" />
<arg value="--format=%H" />
</exec>
<!-- Delete old build and rebuild framework. -->
<delete dir="${dir.build}" />
<mkdir dir="${dir.build}" />
<mkdir dir="${dir.build}/${dir.resources}" />
<!-- Copy resources over. -->
<copy todir="${dir.build}/${dir.resources}">
<fileset dir="${dir.resources}">
<include name="**/*" />
</fileset>
</copy>
<!-- Copy libraries over. -->
<!-- Using jar-in-jar-loader for a single executeable instead of
having libraries in the build dir. Bring this back later?
<copy todir="${dir.build}/${dir.lib}">
<fileset refid="set.libraries" />
</copy> -->
<!-- Establish manifest classpath. -->
<manifestclasspath property="classpath.manifest" jarfile="${jar.runnable}">
<classpath refid="classpath.compile" />
</manifestclasspath>
<!-- Create runnable jar. -->
<jar destfile="${dir.build}/${jar.runnable}">
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Built-Date" value="${TODAY}" />
<attribute name="Git-Commit" value="${git.commit}" />
<attribute name="Main-Class" value="org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader"/>
<attribute name="Rsrc-Main-Class" value="core.PioText"/>
<attribute name="Class-Path" value="."/>
<attribute name="Rsrc-Class-Path" value="./ ${classpath.manifest}"/>
</manifest>
<fileset dir="${dir.target.src}" />
<zipfileset refid="set.libraries" prefix="${dir.lib}"/>
<zipfileset src="${dir.lib}/jar-in-jar-loader.zip"/>
</jar>
</target>
<!-- - - - - - - - - - - - - - - - - -
target: run
- - - - - - - - - - - - - - - - - -->
<target name="run">
<java jar="${dir.build}/${jar.runnable}" fork="true" />
</target>
</project>