-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.xml
195 lines (163 loc) · 7.43 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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?xml version="1.0"?>
<project default="all" name="sbutil" basedir=".">
<property file="build.properties"/>
<property name="release" value="${project.name}-${project.version}" />
<!-- Build deps -->
<property name="compiler.version" value="1.6"/>
<property name="ant.version" value="1.7.0"/>
<!-- Persistent files and directories -->
<property name="src.dir" value="${basedir}/src"/>
<property name="lib.dir" value="${basedir}/lib"/>
<property name="config.dir" value="${basedir}/config"/>
<property name="scripts.dir" value="${basedir}/scripts"/>
<property name="test.src.dir" value="${basedir}/test"/>
<property name="license.file" value="COPYING" />
<!-- Temporary files and directories-->
<property name="build.dir" value="${basedir}/classes"/>
<property name="test.build.dir" value="${basedir}/classes_test"/>
<property name="dist.dir" value="${basedir}/dist"/>
<property name="doc.dir" value="${basedir}/doc"/>
<property name="tmp.dir" value="${basedir}/tmp"/>
<property name="release.src.zip" value="${dist.dir}/${project.name}-${project.version}-src.zip"/>
<property name="release.apidocs.zip" value="${dist.dir}/${project.name}-${project.version}-apidocs.zip"/>
<!-- The libs are used for unit testing only -->
<property name="log4j.version" value="1.2.14" />
<property name="commons-logging.version" value="1.1.1" />
<property name="junit.version" value="4.1" />
<!-- Other properties -->
<property name="main-class" value="dk.statsbiblioteket.percipio.Percipio"/>
<property name="compiler" value="modern"/>
<tstamp>
<format property="build.time" pattern="MM/dd/yyyy HH:mm"/>
</tstamp>
<path id="base.path">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="test.base.path">
<path refid="base.path" />
<pathelement location="${build.dir}" />
<pathelement location="${test.build.dir}" />
<pathelement location="${test.src.dir}" />
</path>
<property name="base" refid="base.path"/>
<property name="test.base" refid="test.base.path"/>
<!--
TARGETS
-->
<!-- Ensure we have correct Java and Ant versions -->
<target name="depends">
<!--TODO-->
</target>
<target name="prepare" depends="depends">
<mkdir dir="${build.dir}"/>
<mkdir dir="${test.build.dir}"/>
<mkdir dir="${dist.dir}"/>
<mkdir dir="${doc.dir}"/>
<mkdir dir="${src.dir}"/>
<mkdir dir="${lib.dir}"/>
<mkdir dir="${config.dir}"/>
<mkdir dir="${scripts.dir}"/>
<mkdir dir="${test.src.dir}"/>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete dir="${test.build.dir}"/>
<delete dir="${dist.dir}"/>
<delete dir="${doc.dir}"/>
<delete dir="${tmp.dir}"/>
</target>
<target name="compile" depends="prepare">
<javac srcdir="${src.dir}" destdir="${build.dir}" encoding="UTF-8"
compiler="${compiler}" optimize="on" debug="on" >
<compilerarg value="-Xlint:unchecked"/>
<classpath refid="base.path" />
</javac>
</target>
<target name="jar" depends="compile">
<copy todir="${build.dir}">
<fileset dir="${src.dir}">
<include name="**/*.xslt"/>
</fileset>
</copy>
<jar basedir="${build.dir}" compress="true" jarfile="${dist.dir}/${release}.jar" >
<manifest>
<attribute name="Main-Class" value="${main-class}" />
</manifest>
</jar>
</target>
<target name="release" depends="clean, jar, .src.zip">
<!-- TODO: Insert build num and date like this:
<replaceregexp file="rep.test" match="\$Id[^\$]*\$" replace="Hello - ${build.time}"/>
-->
<property name="prefix" value="${release}"/>
<zip destfile="${dist.dir}/${release}.zip">
<zipfileset prefix="${prefix}" file="${release}.jar"/>
<zipfileset prefix="${prefix}" file="README"/>
<zipfileset prefix="${prefix}" file="MAINTAINERS"/>
<zipfileset prefix="${prefix}" file="POLICY"/>
<zipfileset prefix="${prefix}" file="COPYING"/>
<zipfileset prefix="${prefix}" file="ChangeLog"/>
<zipfileset prefix="${prefix}" file="NEWS"/>
<zipfileset prefix="${prefix}/doc" includes="**/*" dir="${doc.dir}"/>
<zipfileset prefix="${prefix}" file="${release.src.zip}"/>
<zipfileset prefix="${prefix}" file="${release.apidocs.zip}"/>
</zip>
</target>
<target name="test">
<property name="test.formatter" value="plain"/>
<property name="test.usefile" value="false"/>
<antcall target=".test.run"/>
</target>
<target name="test.xml">
<property name="test.formatter" value="xml"/>
<property name="test.usefile" value="true"/>
<antcall target=".test.run"/>
</target>
<!-- Only run this target indirectly via the test or test.xml targets
It needs the test.formatter and test.usefile properties to be set -->
<target name=".test.run" depends="compile-test">
<!-- We need to fork the JVM and set the java.class.path property
to be able to pick resources from the classpath up (like
resource bundles). JUnit will override the classpath. -->
<junit printsummary="withOutAndErr" haltonfailure="yes"
haltonerror="yes" fork="yes" maxmemory="512m">
<sysproperty key="java.class.path" value="${test.base}"/>
<classpath refid="test.base.path" />
<formatter type="${test.formatter}" usefile="${test.usefile}" />
<!-- add tests here -->
<test name="dk.statsbiblioteket.percipio.BrainTest"/>
</junit>
</target>
<!-- Depends on the 'jar' target to make
sure that we copy over any needed XSLTs-->
<target name="compile-test" depends="jar">
<javac srcdir="${test.src.dir}" destdir="${test.build.dir}" encoding="UTF-8"
compiler="${compiler}" optimize="on" debug="on">
<compilerarg value="-Xlint:unchecked"/>
<classpath refid="test.base.path" />
</javac>
</target>
<target name=".src.zip" depends="prepare">
<property name="prefix" value="${release}"/>
<zip destfile="${release.src.zip}">
<zipfileset prefix="${prefix}/src" dir="${src.dir}"/>
<zipfileset prefix="${prefix}/lib" dir="${lib.dir}"/>
<zipfileset prefix="${prefix}/test" dir="${test.src.dir}"/>
<zipfileset prefix="${prefix}/config" dir="${config.dir}"/>
<zipfileset prefix="${prefix}/scripts" dir="${scripts.dir}"/>
<zipfileset prefix="${prefix}" file="build.xml"/>
<zipfileset prefix="${prefix}" file="LOGGING"/>
<zipfileset prefix="${prefix}" file="README"/>
<zipfileset prefix="${prefix}" file="MAINTAINERS"/>
<zipfileset prefix="${prefix}" file="POLICY"/>
<zipfileset prefix="${prefix}" file="COPYING"/>
<zipfileset prefix="${prefix}" file="ChangeLog"/>
<zipfileset prefix="${prefix}" file="NEWS"/>
<zipfileset prefix="${prefix}" file="sbutil.iml"/>
<zipfileset prefix="${prefix}" file="sbutil.ipr"/>
</zip>
</target>
<target name="all" depends="release"/>
</project>