This repository has been archived by the owner on Jun 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.xml
329 lines (295 loc) · 13.1 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<project name="plexi.database" default="build" basedir=".">
<description>Connector for Databases</description>
<tstamp/>
<property name="src.dir" location="src"/>
<property name="test.dir" location="test"/>
<property name="test.class" value="*Test"/>
<property name="build.dir" location="build"/>
<property name="build-src.dir" location="${build.dir}/src"/>
<property name="build-test.dir" location="${build.dir}/test"/>
<property name="build-instrument.dir" location="${build.dir}/instrument"/>
<property name="adaptor.clone.dir" location="lib/plexi"/>
<!-- Used for checking if adaptor.jar has been changed. -->
<property name="adaptor.jar.default"
value="${adaptor.clone.dir}/build/dist/adaptor/adaptor-withlib.jar"/>
<property name="adaptor.jar" value="${adaptor.jar.default}"/>
<property name="dist.dir" location="dist"/>
<property name="javadoc.dir" location="${build.dir}/javadoc"/>
<property name="resource.dir" location="resources"/>
<property name="lib.dir" location="lib"/>
<property name="h2.jar" location="${lib.dir}/h2-1.3.176.jar"/>
<property name="adaptor.class"
value="com.google.enterprise.adaptor.database.DatabaseAdaptor"/>
<property name="adaptor.args" value=""/>
<property name="cobertura.dir" value="${basedir}/../cobertura/"/>
<!-- Load build environment specific properties. -->
<property file="build.properties"/>
<property name="compile.java.version" value="7"/>
<property name="compile.java.bootclasspath" value="${build.bootclasspath}"/>
<!-- The build.bootclasspath property, if set, must match the Java version
set in compile.java.version. To detect errors in build.bootclasspath,
set compile.java.newerClassname to a class that was added in
the immediately following release of Java. For example, for
"7", pick a class added in Java 8. -->
<property name="compile.java.newerClassname"
value="java.lang.FunctionalInterface"/>
<!-- Use add-modules with Java 9 and higher. -->
<condition property="java.modules"
value="" else="--add-modules java.xml.bind">
<matches string="${ant.java.version}" pattern="^1\.[678]$"/>
</condition>
<path id="adaptor.build.classpath">
<pathelement location="${adaptor.jar}"/>
</path>
<path id="adaptor.run.classpath">
<path refid="adaptor.build.classpath"/>
<pathelement location="${resource.dir}"/>
<pathelement path="${jdbc.classpath}"/>
</path>
<path id="junit.classpath">
<fileset dir="${lib.dir}">
<include name="junit-4.11.jar"/>
<include name="hamcrest-core-1.3.jar"/>
</fileset>
</path>
<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}" erroronmissingdir="false">
<include name="cobertura.jar"/>
<include name="lib/**/*.jar"/>
</fileset>
</path>
<target name="-check-instrument-uptodate">
<uptodate property="instrument.uptodate"
targetfile="${build-instrument.dir}/cobertura.ser">
<srcfiles dir="${build-src.dir}"/>
</uptodate>
</target>
<target name="build"
depends="-real-build,-check-instrument-uptodate,clean-instrument"
description="Build source"/>
<target name="-plexi-check-submodule">
<condition property="plexi.is-not-submodule">
<not>
<equals arg1="${adaptor.jar.default}" arg2="${adaptor.jar}"/>
</not>
</condition>
<condition property="tmp.plexi.valid-setup">
<or>
<isset property="plexi.is-not-submodule"/>
<available file="${adaptor.clone.dir}/.git"/>
</or>
</condition>
<fail unless="tmp.plexi.valid-setup">Invalid setup:
No lib/plexi submodule and using default adaptor.jar property.
You need to run "git submodule init; git submodule update" to initialize the
lib/plexi submodule or add the the command line argument
-Dadaptor.jar=path/to/adaptor-withlib.jar to point to the adaptor library.
</fail>
</target>
<target name="-plexi-test-uptodate" depends="-plexi-check-submodule">
<condition property="plexi.uptodate">
<or>
<isset property="plexi.is-not-submodule"/>
<uptodate targetfile="${adaptor.jar}">
<srcfiles dir="${adaptor.clone.dir}"
excludes=".git/** build/** dist/** **.swp"/>
</uptodate>
</or>
</condition>
</target>
<target name="-plexi-build" depends="-plexi-test-uptodate"
unless="plexi.uptodate">
<echo message="Detected Plexi changes. Re-packaging Plexi..."/>
<ant antfile="${adaptor.clone.dir}/build.xml" dir="${adaptor.clone.dir}"
target="package" inheritAll="false">
<property name="adaptorlib.suffix" value=""/>
</ant>
</target>
<target name="-real-build" depends="-plexi-build">
<mkdir dir="${build-src.dir}"/>
<!-- Make sure that the build.bootclasspath isn't newer than expected. -->
<available property="compile.java.isNewer"
classname="${compile.java.newerClassname}"
classpath="${compile.java.bootclasspath}" ignoresystemclasses="true"/>
<fail if="compile.java.isNewer">
Error: build.bootclasspath is newer than JDK ${compile.java.version}.
</fail>
<javac srcdir="${src.dir}" destdir="${build-src.dir}" debug="true"
includeantruntime="false" encoding="utf-8"
source="${compile.java.version}" target="${compile.java.version}">
<bootclasspath path="${compile.java.bootclasspath}"/>
<compilerarg value="-Xlint"/>
<classpath refid="adaptor.build.classpath"/>
</javac>
<mkdir dir="${build-test.dir}"/>
<!-- Compile JUnit helper -->
<javac srcdir="${lib.dir}" destdir="${build-test.dir}" debug="true"
includeantruntime="true" encoding="utf-8"
source="${compile.java.version}" target="${compile.java.version}">
<bootclasspath path="${compile.java.bootclasspath}"/>
<compilerarg value="-Xlint"/>
<classpath refid="junit.classpath"/>
<include name="JUnitLogFixFormatter.java"/>
</javac>
<!-- Compile tests, excluding example tests. -->
<javac srcdir="${test.dir}" destdir="${build-test.dir}" debug="true"
includeantruntime="false" encoding="utf-8"
source="${compile.java.version}" target="${compile.java.version}">
<bootclasspath path="${compile.java.bootclasspath}"/>
<compilerarg value="-Xlint"/>
<classpath refid="adaptor.build.classpath"/>
<classpath location="${build-src.dir}"/>
<classpath refid="junit.classpath"/>
<classpath location="${h2.jar}"/>
</javac>
</target>
<target name="-discover-version" unless="adaptor.version">
<exec executable="git" outputproperty="adaptor.version"
logError="true" failifexecutionfails="false">
<arg value="describe"/>
<arg value="--always"/>
</exec>
<!-- Set version if git describe failed. -->
<property name="adaptor.version" value="unknown-${DSTAMP}"/>
</target>
<target name="dist" description="Generate distribution binaries"
depends="clean,test,package"/>
<target name="package" description="Generate binaries"
depends="build,javadoc,-discover-version">
<property name="dist.staging.dir" value="${build.dir}/dist/staging"/>
<delete dir="${build.dir}/dist"/>
<delete dir="${dist.dir}"/>
<mkdir dir="${build.dir}/dist"/>
<mkdir dir="${build.dir}/dist/staging"/>
<mkdir dir="${dist.dir}"/>
<!-- Set the file name suffix from the version. Add a leading dash,
and strip a leading "v" prefix if it is followed by a digit. -->
<loadresource property="adaptor.suffix">
<propertyresource name="adaptor.version"/>
<filterchain>
<replaceregex pattern="^(v(?=\d))?" replace="-"/>
</filterchain>
</loadresource>
<!-- Concatenate dependent JARs together into a comma-delimited list. -->
<pathconvert pathsep=" " refid="adaptor.run.classpath"
property="tmp.adaptor.classpath">
<mapper type="flatten"/>
<map from="" to="lib/"/>
</pathconvert>
<jar destfile="${dist.staging.dir}/adaptor-database${adaptor.suffix}.jar"
basedir="${build-src.dir}">
<manifest>
<attribute name="Main-Class" value="${adaptor.class}"/>
<attribute name="Class-Path" value="${tmp.adaptor.classpath}"/>
<section name="com/google/enterprise/adaptor/database/">
<attribute name="Implementation-Title"
value="Google Search Appliance Connector for Databases"/>
<attribute name="Implementation-Vendor" value="Google Inc."/>
<attribute name="Implementation-Version"
value="${adaptor.version}"/>
</section>
</manifest>
<fileset dir="${resource.dir}"/>
</jar>
<!-- lib/ -->
<!-- Concatenate dependent JARs together into a comma-delimited list. -->
<pathconvert pathsep="," refid="adaptor.run.classpath"
property="tmp.adaptor.fileset">
<!-- We remove the lib.dir from the paths to prevent trouble with comma
and space in lib.dir. It also makes it nicer <echo>ing
tmp.adaptorlib.fileset. -->
<map from="${lib.dir}/" to=""/>
</pathconvert>
<copy todir="${dist.staging.dir}/lib" flatten="true">
<fileset dir="${lib.dir}" includes="${tmp.adaptor.fileset}"/>
</copy>
<!-- adaptor-database-withlib.jar -->
<jar filesetmanifest="mergewithoutmain"
destfile="${dist.staging.dir}/adaptor-database${adaptor.suffix}-withlib.jar">
<zipfileset
src="${dist.staging.dir}/adaptor-database${adaptor.suffix}.jar"/>
<zipgroupfileset dir="${dist.staging.dir}/lib"/>
<manifest>
<attribute name="Main-Class" value="${adaptor.class}"/>
</manifest>
</jar>
<!-- adaptor-bin.zip -->
<move file="${dist.staging.dir}"
tofile="${build.dir}/dist/adaptor-database${adaptor.suffix}"/>
<zip destfile="${dist.dir}/adaptor-database${adaptor.suffix}-bin.zip"
basedir="${build.dir}/dist/adaptor-database${adaptor.suffix}"/>
</target>
<target name="clean" description="Remove build output">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="javadoc" description="Build JavaDocs">
<javadoc sourcepath="${src.dir}" destdir="${javadoc.dir}">
<classpath refid="adaptor.build.classpath"/>
<arg value="-quiet"/>
<arg value="-notimestamp"/>
</javadoc>
</target>
<target name="run" depends="build" description="Run adaptor">
<java classpath="${build-src.dir}" fork="true" classname="${adaptor.class}">
<jvmarg line="${java.modules}"/>
<classpath refid="adaptor.run.classpath"/>
<sysproperty key="java.util.logging.config.file"
value="logging.properties"/>
<sysproperty key="javax.net.ssl.keyStore" file="keys.jks"/>
<sysproperty key="javax.net.ssl.keyStoreType" value="jks"/>
<sysproperty key="javax.net.ssl.keyStorePassword" value="changeit"/>
<sysproperty key="javax.net.ssl.trustStore" file="cacerts.jks"/>
<sysproperty key="javax.net.ssl.trustStoreType" value="jks"/>
<sysproperty key="javax.net.ssl.trustStorePassword" value="changeit"/>
<arg line="${adaptor.args}"/>
</java>
</target>
<target name="coverage" depends="instrument,test,coverage-report"
description="Run instrumented tests and generate coverage report"/>
<target name="test" depends="build" description="Run JUnit tests">
<property name="build.haltonfailure" value="off"/>
<junit printsummary="yes"
haltonfailure="${build.haltonfailure}" failureproperty="build.failure"
forkmode="once" fork="true" dir="${basedir}" maxmemory="512m">
<jvmarg line="${java.modules}"/>
<sysproperty key="net.sourceforge.cobertura.datafile"
file="${build-instrument.dir}/cobertura.ser"/>
<sysproperty key="build.properties" file="build.properties"/>
<classpath refid="adaptor.run.classpath"/>
<classpath refid="cobertura.classpath"/>
<classpath refid="junit.classpath"/>
<classpath location="${h2.jar}"/>
<classpath location="${build-instrument.dir}"/>
<classpath location="${build-src.dir}"/>
<classpath location="${build-test.dir}"/>
<formatter type="plain" usefile="false"/>
<formatter classname="JUnitLogFixFormatter" usefile="false"/>
<batchtest>
<fileset dir="${test.dir}">
<include name="**/${test.class}.java"/>
</fileset>
</batchtest>
</junit>
<fail if="build.failure" message="Test failure"/>
</target>
<target name="instrument" depends="build" description="Instrument classes">
<taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
<cobertura-instrument datafile="${build-instrument.dir}/cobertura.ser"
todir="${build-instrument.dir}">
<auxClassPath>
<path refid="adaptor.build.classpath" />
</auxClassPath>
<fileset dir="${build-src.dir}"/>
</cobertura-instrument>
</target>
<target name="clean-instrument" unless="instrument.uptodate"
description="Delete instrumented classes">
<delete dir="${build-instrument.dir}"/>
</target>
<target name="coverage-report" description="Generates code coverage report">
<taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
<cobertura-report datafile="${build-instrument.dir}/cobertura.ser"
srcdir="${src.dir}" destdir="${build.dir}/coverage"/>
</target>
</project>