-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
265 lines (241 loc) · 10.2 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="GHIRL2" default="all" basedir=".">
<property file="build.properties"/>
<description>
GHIRL: Graph Hierarchy Information Retrieval Language?
</description>
<target name="init" depends="" description="Initialize environment">
<tstamp>
<format property="jartime" pattern="MMM-dd-yyyy-HH:mm"/>
</tstamp>
<!-- Grab "for" task from ant-contrib -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
<!-- Configure paths -->
<property name="path.src" value="src"/>
<property name="path.lib" value="lib"/>
<property name="path.devlib" value="dev-lib"/>
<property name="path.build" value="build"/>
<property name="path.dist" value="dist"/>
<property name="path.tmp" value="tmp"/>
<property name="path.test" value="test"/>
<property name="path.javadoc" value="doc"/>
<!-- Configure compilation parameters -->
<property name="compile.debug" value="true"/>
<property name="compile.deprecation" value="true"/>
<property name="compile.jdk-version.source" value="1.6"/>
<property name="compile.jdk-version.target" value="1.6"/>
<property name="compile.optimize" value="true"/>
<property name="compile.compiler" value="javac1.6"/>
<path id="compile.classpath">
<fileset dir="${path.lib}">
<include name="*.jar"/>
</fileset>
<fileset dir="${path.devlib}">
<include name="*.jar"/>
</fileset>
<pathelement path="${path.src}"/>
<pathelement path="${path.build}"/>
</path>
<patternset id="no-tests">
<exclude name="**/test/*.*"/> <!-- leave test cases behind -->
<exclude name="**/test"/>
</patternset>
</target>
<target name="make_directories" description="Creates all project directories" depends="init">
<mkdir dir="${path.dist}"/>
<mkdir dir="${path.tmp}"/>
<mkdir dir="${path.build}"/>
<mkdir dir="${path.lib}"/>
<mkdir dir="${path.devlib}"/>
<mkdir dir="${path.src}"/>
</target>
<target name="prepare" depends="init, make_directories" description="Prepare build directory"/>
<target name="compile" depends="prepare" description="Compile Java sources">
<javac debug="${compile.debug}"
deprecation="${compile.deprecation}"
destdir="${path.build}"
optimize="${compile.optimize}"
srcdir="${path.src}">
<classpath refid="compile.classpath"/>
</javac>
<copy todir="${path.build}">
<fileset dir="${path.src}">
<exclude name="**/*.java"/>
<exclude name="**/*.cpp"/>
<exclude name="**/*.h"/>
<exclude name="**/*.c"/>
<exclude name="**/*.cc"/>
</fileset>
</copy>
</target>
<target name="clean" depends="init" description="Wipe out all generated files">
<delete>
<fileset dir="${path.build}/">
<include name="*/"/>
</fileset>
<fileset dir="${path.tmp}/">
<include name="*/"/>
</fileset>
</delete>
</target>
<target name="all" depends="clean, compile" description="Clean and compile all components"/>
<target name="dist-lib-solo" depends="compile" description="Jar up GHIRL for distribution (NO dependencies, just GHIRL; does not include tests)">
<jar destfile="${path.dist}/ghirl2-${DSTAMP}.jar">
<fileset dir="${path.build}">
<patternset refid="no-tests"/>
</fileset>
</jar>
</target>
<target name="pack-lib">
<echo>Packing ${jarfile}...</echo>
<zip destfile="${path.tmp}/${lib.zip}" update="true">
<zipfileset src="${jarfile}"/>
</zip>
</target>
<target name="pack-all-libs">
<property name="lib.zip" value="lib.zip"/>
<foreach target="pack-lib" param="jarfile" inheritall="true">
<path>
<fileset dir="${path.lib}" includes="*.jar"/>
</path>
</foreach>
<echo>Lib packing complete.</echo>
</target>
<target name="pack-tomcat-libs">
<property name="lib.zip" value="tomcat-libs.zip"/>
<foreach target="pack-lib" param="jarfile" inheritall="true">
<path>
<fileset dir="${path.lib}" includes="*.jar">
<exclude name="tokyocabinet.jar"/>
</fileset>
</path>
</foreach>
<echo>Lib packing complete.</echo>
</target>
<target name="dist-lib-full" depends="compile,pack-all-libs" description="Jar up GHIRL for distribution (includes all dependencies; does not include tests)">
<jar destfile="${path.dist}/ghirl2-full-${DSTAMP}.jar">
<fileset dir="${path.build}"><patternset refid="no-tests"/></fileset>
<zipfileset src="${path.tmp}/${lib.zip}"/>
</jar>
</target>
<target name="copy-sharedlibs">
<copy todir="${path.dist}">
<fileset dir="${path.lib}" includes="tokyocabinet.jar"/>
</copy>
</target>
<target name="dist-lib-tomcat" depends="compile,pack-tomcat-libs,copy-sharedlibs" description="Jar up GHIRL for distribution to a tomcat container (includes all dependencies EXCEPT tokyocabinet.jar, which must be transferred to $CATALINA_HOME/shared/lib separately)">
<jar destfile="${path.dist}/ghirl2-tomcat-${DSTAMP}.jar">
<fileset dir="${path.build}"><patternset refid="no-tests"/></fileset>
<zipfileset src="${path.tmp}/${lib.zip}"/>
</jar>
</target>
<target name="dist-lib-full-withtests" depends="compile,pack-all-libs" description="Jar up GHIRL for distribution (includes all dependencies and tests)">
<jar destfile="${path.dist}/ghirl2-full-tests-${DSTAMP}.jar">
<fileset dir="${path.build}"/>
<zipfileset src="${path.tmp}/${lib.zip}"/>
<zipfileset src="${path.devlib}/junit-4.7.jar"/>
</jar>
</target>
<target name="dist-srcjar" depends="compile,pack-all-libs" description="Jar up GHIRL for distribution, including source, dependencies, and tests)">
<copy todir="${path.build}">
<fileset dir="${path.src}">
<include name="**/*.java"/>
<include name="**/*.cpp"/>
<include name="**/*.h"/>
<include name="**/*.c"/>
<include name="**/*.cc"/>
</fileset>
</copy>
<jar destfile="${path.dist}/ghirl2-srcjar-${DSTAMP}.jar">
<fileset dir="${path.build}"/>
<zipfileset src="${path.tmp}/${lib.zip}"/>
</jar>
</target>
<target name="dist-custom" depends="compile" description="Like dist-lib-full but create an executable jar using a custom Main file (specify using -Dmainclass=package.path.to.class.name)">
<jar destfile="${path.dist}/ghirl2-custom-${mainclass}.jar">
<fileset dir="${path.build}"><patternset refid="no-tests"/></fileset>
<zipfileset src="${path.tmp}/${lib.zip}"/>
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Main-Class" value="${mainclass}"/>
<!-- The way you're *really* supposed to handle external libraries in a .jar file is as follows:
OUTSIDE the <jar> element, do:
<path id="dist.classpath">
<fileset dir="${path.lib}" includes="**/*.jar, **/*.zip" />
</path>
<manifestclasspath property="dist.manifest.classpath" jarfile="${path.dist}/ghirl-argh-${mainclass}.jar">
<classpath refid="dist.classpath" />
</manifestclasspath>
then INSIDE the <manifest> element, do:
<attribute name="Class-Path" value="${dist.manifest.classpath}"/>
This, however, requires you to send your jar along with a lib directory so that the local paths inluded in Class-Path remain the same. There's no all-in-one-file way to do it other than unpacking and repacking as we're doing with zipfileset above. :(
-->
</manifest>
</jar>
</target>
<!-- These targets are for hexastore: -->
<target name="jnilibs" depends="bdbstore,memstore"/>
<target name="bbdb" depends="init" description="Compile the BB DB components (CPP)">
<exec executable="${cxx.compiler}" failonerror="true">
<arg line="${cxx.cflags}"/>
<arg line="${cxx.includes}"/>
<arg line="-o ${path.build}/ghirl/persistance/mydb.o"/>
<arg line="-c ${path.src}/ghirl/persistance/bdbhash/BDB/mydb.cpp"/>
</exec>
</target>
<target name="bdbstore" depends="bbdb" description="Compile the BDB store CPP components">
<exec executable="${cxx.compiler}" failonerror="true">
<arg line="${cxx.cflags}"/>
<arg line="${cxx.includes}"/>
<arg line="${cxx.lflags}"/>
<arg line="${cxx.ldflags}"/>
<arg value="${path.build}/ghirl/persistance/mydb.o"/>
<arg line="-o ${path.build}/ghirl/persistance/libhexastore.${cxx.libext}"/>
<arg value="${path.src}/ghirl/persistance/hexastore.cc"/>
</exec>
</target>
<target name="memstore" depends="init" description="Compile the memstore CPP components">
<exec executable="${cxx.compiler}" failonerror="true">
<arg line="${cxx.cflags}"/>
<arg line="${cxx.includes}"/>
<arg line="-o ${path.build}/ghirl/persistance/libmemstore.${cxx.libext}"/>
<arg value="${path.src}/ghirl/persistance/memstore.cc"/>
</exec>
</target>
<!-- end hexastore targets -->
<target name="javadoc" depends="init" description="build javadoc API documentation">
<delete dir="${path.javadoc}"/>
<mkdir dir="${path.javadoc}"/>
<javadoc sourcepath="${path.src}" destdir="${path.javadoc}" classpathref="compile.classpath" packagenames="*">
</javadoc>
</target>
<target name="verify" depends="prepare,compile" description="Run all verification tests">
<junit printsummary="off" failureproperty="hasFailedTests" fork="on">
<jvmarg value="-Djava.library.path=${tokyo.java.library.path}"/>
<formatter type="brief"/>
<classpath refid="compile.classpath"/>
<batchtest>
<fileset dir="${path.build}" id="verificationTests">
<include name="ghirl/test/verify/Test*.class"/>
<exclude name="**/*$*.class"/>
</fileset>
</batchtest>
</junit>
<fail if="hasFailedTests" message="See TEST-*.txt files for details on the failed tests noted above."/>
<resourcecount property="verificationTestCount" refid="verificationTests"/>
<echo>${verificationTestCount} verification tests passed.</echo>
</target>
<target name="test-class" depends="init" description="Run a single named (-DtestClass=fully.qualified.class.name) test">
<fail message="Command-line switch testClass not defined. Re-run with -DtestClass=your.fully.qualified.test.class">
<condition><not><isset property="testClass"/></not></condition>
</fail>
<junit printsummary="withOutAndErr" failureproperty="hasFailedTests" fork="on">
<jvmarg value="-Djava.library.path=${tokyo.java.library.path}"/>
<formatter type="brief"/>
<classpath refid="compile.classpath"/>
<test name="${testClass}"/>
</junit>
<fail if="hasFailedTests" message="Test failed!"/>
<echo>Test passed.</echo>
</target>
</project>