forked from adsabs/montysolr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-build.xml
458 lines (362 loc) · 16 KB
/
common-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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="common" xmlns:artifact="antlib:org.apache.maven.artifact.ant"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:junit4="antlib:com.carrotsearch.junit4">
<description>
This file is designed for importing into a main build file, and not intended
for standalone use.
</description>
<!--
======================================================================
Selected properties from lucene/common-build.xml
======================================================================
//-->
<dirname file="${ant.file.common}" property="common.dir"/>
<!-- Give user a chance to override without editing this file
(and without typing -D each time it compiles it -->
<property file="${user.home}/montysolr.build.properties"/>
<property file="${basedir}/build.properties"/>
<property file="${common.dir}/build.properties"/>
<property name="montysolr.dependencies.dir" location="${common.dir}/build/solrjars-extracted" />
<tstamp>
<format property="current.year" pattern="yyyy"/>
<format property="DSTAMP" pattern="yyyy-MM-dd"/>
<format property="TSTAMP" pattern="HH:mm:ss"/>
<!-- datetime format that is safe to treat as part of a dotted version -->
<format property="dateversion" pattern="yyyy.MM.dd.HH.mm.ss" />
</tstamp>
<property name="name" value="${ant.project.name}"/>
<property name="Name" value="MontySolr"/>
<property name="dev.version" value="6.x-SNAPSHOT"/>
<property name="tests.luceneMatchVersion" value="6.0"/>
<property name="version" value="${dev.version}"/>
<property name="spec.version" value="${version}"/>
<property name="year" value="2000-${current.year}"/>
<property name="final.name" value="montysolr-${name}-${version}"/>
<property name="common.classpath.excludes" value="**/*.txt,**/*.template,**/*.sha1" />
<property name="ivy.bootstrap.version" value="2.3.0" />
<property name="ivy.default.configuration" value="*"/>
<property name="ivy.sync" value="true"/>
<property name="junit.jar" value="junit-4.10.jar"/>
<property name="junit-location.jar" value="${common.dir}/lib/${junit.jar}"/>
<path id="junit-path">
<fileset dir="${montysolr.dependencies.dir}/solr/test-framework/lib">
<include name="junit-*.jar" />
<include name="randomizedtesting-runner-*.jar" />
</fileset>
</path>
<path id="ant-path">
<fileset dir="${common.dir}/lib" includes="ant-*.jar"/>
</path>
<!-- default arguments to pass to JVM executing tests -->
<property name="args" value=""/>
<property name="javac.deprecation" value="off"/>
<property name="javac.debug" value="on"/>
<property name="javac.source" value="1.8"/>
<property name="javac.target" value="1.8"/>
<property name="javac.source.backwards" value="1.8"/>
<property name="javac.target.backwards" value="1.8"/>
<property name="javac.args" value="-Xlint -Xlint:-deprecation -Xlint:-serial"/>
<property name="bootclasspath" value=""/>
<property name="project.name" value="site"/>
<property name="build.encoding" value="utf-8"/>
<property name="src.dir" location="src/java"/>
<property name="tests.src.dir" location="src/test"/>
<property name="build.dir" location="build"/>
<!-- Needed in case a module needs the original build, also for compile-tools to be called from a module -->
<property name="common.build.dir" location="${common.dir}/build"/>
<property name="dist.dir" location="${common.dir}/dist"/>
<property name="maven.dist.dir" location="${dist.dir}/maven"/>
<property name="m2.repository.url" value="file://${maven.dist.dir}"/>
<property name="m2.repository.private.key" value="${user.home}/.ssh/id_dsa"/>
<propertyset id="uptodate.and.compiled.properties" dynamic="true">
<propertyref regex=".*\.uptodate$$"/>
<propertyref regex=".*\.compiled$$"/>
</propertyset>
<!-- Default exclude sources and javadoc jars from Ivy fetch to save time and bandwidth -->
<condition property="ivy.exclude.types"
value=""
else="source|javadoc">
<isset property="fetch.sources.javadocs"/>
</condition>
<!-- Check for minimum supported ANT version. -->
<fail message="Minimum supported ANT version is 1.8.2. Yours: ${ant.version}">
<condition>
<not>
<antversion atleast="1.8.2" />
</not>
</condition>
</fail>
<!--
======================================================================
important paths for MontySolr
======================================================================
//-->
<property file="${common.build.dir}/build.properties" prefix="prop"/>
<!-- common classpaths that are shareable across montysolr
in fact, we try hard to find all the solr/lucene libs
as well as setup montysolr project files. Use this in
contrib and in main build.xml for classrefs
-->
<path id="common.classpath">
<pathelement location="${common.dir}/build/classes/java"/>
<!-- montysolr jars -->
<fileset dir="${common.dir}/build/jar">
<include name = "**/*.jar" />
</fileset>
<!-- lucene/solr jars -->
<fileset dir="${common.dir}/build">
<include name = "*solrjars-extracted/lucene/lucene-test*.jar" />
<include name = "*solrjars-extracted/solr/solr-test*.jar" />
</fileset>
<fileset dir="${common.dir}/build">
<include name = "*solrjars-extracted/*.jar" />
<include name = "*solrjars-extracted/lucene/*.jar" />
<include name = "*solrjars-extracted/solr/*.jar" />
<include name = "*solrjars-extracted/solr/solrj-lib/*.jar" />
<include name = "*solrjars-extracted/jetty/ext/*.jar" />
</fileset>
<!-- montysolr lib jars -->
<fileset dir="${common.dir}/lib">
<include name = "**/*.jar" />
</fileset>
</path>
<path id="common.demo.classpath">
<path refid="common.classpath"/>
<pathelement location="${common.dir}/build/classes/demo"/>
</path>
<path id="common.test.classpath">
<path refid="junit-path"/>
<path refid="ant-path"/>
<pathelement location="${common.dir}/build/classes/test"/>
<!-- these classes cannot be found in solr/lucene jars, they are needed
for proper compilation of unittests -->
<fileset dir="${common.dir}/build">
<include name="solrjars-extracted/solr/test-framework/**.jar" />
</fileset>
<path refid="common.classpath"/>
</path>
<path id="common.junit.classpath">
<path refid="common.test.classpath"/>
<path refid="junit-path"/>
<pathelement location="${common.dir}/build/classes/test"/>
<pathelement location="${common.dir}/build/classes/java"/>
<pathelement path="${java.class.path}"/>
</path>
<!-- if testcase is specified let the family be empty (to include all) -->
<condition property="tests.family" value="">
<isset property="testcase" />
</condition>
<condition property="tests.family" value="${testfamily}">
<isset property="testfamily" />
</condition>
<property name="tests.family" value="Test" />
<!--
======================================================================
SELECTED TARGETS FROM lucene/common-build.xml
======================================================================
//-->
<target name="clean"
description="Removes contents of build and dist directories">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
<delete file="velocity.log"/>
</target>
<target name="init" depends="resolve">
<!-- currently empty -->
</target>
<target name="ivy-configure">
<!-- [DW] ivy loses its configuration for some reason. cannot explain this. if
you have an idea, fix it.
unless="ivy.settings.uptodate" -->
<!-- override: just for safety, should be unnecessary -->
<ivy:configure file="${common.dir}/ivy-settings.xml" override="true"/>
<!-- <property name="ivy.settings.uptodate" value="true"/> -->
</target>
<target name="resolve" depends="ivy-availability-check,ivy-configure">
<!-- todo, make this a property or something.
only special cases need bundles -->
<ivy:retrieve type="jar,bundle,test,test-jar,tests" log="download-only"
conf="${ivy.default.configuration}" sync="${ivy.sync}"/>
</target>
<property name="ivy_install_path" location="${user.home}/.ant/lib" />
<property name="ivy_bootstrap_url1" value="http://repo1.maven.org/maven2"/>
<!-- you might need to tweak this from china so it works -->
<property name="ivy_bootstrap_url2" value="http://uk.maven.org/maven2"/>
<property name="ivy_checksum_sha1" value="c5ebf1c253ad4959a29f4acfe696ee48cdd9f473"/>
<target name="ivy-availability-check" unless="ivy.available">
<condition property="ivy.available">
<typefound uri="antlib:org.apache.ivy.ant" name="configure" />
</condition>
<antcall target="ivy-fail" />
</target>
<target name="ivy-fail" unless="ivy.available">
<echo>
This build requires Ivy and Ivy could not be found in your ant classpath.
(Due to classpath issues and the recursive nature of the Lucene/Solr
build system, a local copy of Ivy can not be used an loaded dynamically
by the build.xml)
You can either manually install a copy of Ivy ${ivy.bootstrap.version} in your ant classpath:
http://ant.apache.org/manual/install.html#optionalTasks
Or this build file can do it for you by running the Ivy Bootstrap target:
ant ivy-bootstrap
Either way you will only have to install Ivy one time.
'ant ivy-bootstrap' will install a copy of Ivy into your Ant User Library:
${user.home}/.ant/lib
If you would prefer, you can have it installed into an alternative
directory using the "-Divy_install_path=/some/path/you/choose" option,
but you will have to specify this path every time you build Lucene/Solr
in the future...
ant ivy-bootstrap -Divy_install_path=/some/path/you/choose
...
ant -lib /some/path/you/choose clean compile
...
ant -lib /some/path/you/choose clean compile
If you have already run ivy-bootstrap, and still get this message, please
try using the "--noconfig" option when running ant, or editing your global
ant config to allow the user lib to be loaded. See the wiki for more details:
http://wiki.apache.org/lucene-java/HowToContribute#antivy
</echo>
<fail>Ivy is not available</fail>
</target>
<target name="ivy-bootstrap" description="Download and install Ivy in the users ant lib dir" depends="ivy-bootstrap1,ivy-bootstrap2,ivy-checksum"/>
<!-- try to download from repo1.maven.org -->
<target name="ivy-bootstrap1">
<ivy-download src="${ivy_bootstrap_url1}" dest="${ivy_install_path}"/>
<available file="${ivy_install_path}/ivy-${ivy.bootstrap.version}.jar" property="ivy.bootstrap1.success" />
</target>
<target name="ivy-bootstrap2" unless="ivy.bootstrap1.success">
<ivy-download src="${ivy_bootstrap_url2}" dest="${ivy_install_path}"/>
</target>
<target name="ivy-checksum">
<checksum file="${ivy_install_path}/ivy-${ivy.bootstrap.version}.jar"
property="${ivy_checksum_sha1}"
algorithm="SHA"
verifyproperty="ivy.checksum.success"/>
<fail message="Checksum mismatch for ivy-${ivy.bootstrap.version}.jar. Please download this file manually">
<condition>
<isfalse value="${ivy.checksum.success}"/>
</condition>
</fail>
</target>
<macrodef name="ivy-download">
<attribute name="src"/>
<attribute name="dest"/>
<sequential>
<mkdir dir="@{dest}"/>
<echo message="installing ivy ${ivy.bootstrap.version} to ${ivy_install_path}"/>
<get src="@{src}/org/apache/ivy/ivy/${ivy.bootstrap.version}/ivy-${ivy.bootstrap.version}.jar"
dest="@{dest}/ivy-${ivy.bootstrap.version}.jar" usetimestamp="true" ignoreerrors="true"/>
</sequential>
</macrodef>
<target name="compile-core" depends="init">
<!-- intentionally empty -->
</target>
<target name="compile" depends="compile-core">
<!-- convenience target to compile core -->
</target>
<target name="compile-test" depends="compile-core">
</target>
<target name="test" depends="compile-test"
description="Runs unit tests">
<mkdir dir="${junit.output.dir}"/>
<mkdir dir="${common.dir}/build/junit4"/>
</target>
<target name="jar" depends="">
<!-- convenience target to package core JAR -->
</target>
<target name="default" depends=""/>
<!--+
| M A C R O S
+-->
<macrodef name="compile">
<attribute name="srcdir"/>
<attribute name="destdir"/>
<attribute name="javac.source" default="${javac.source}"/>
<attribute name="javac.target" default="${javac.target}"/>
<element name="nested" implicit="yes" optional="yes"/>
<sequential>
<mkdir dir="@{destdir}"/>
<javac
includeAntRuntime="${javac.includeAntRuntime}"
encoding="${build.encoding}"
srcdir="@{srcdir}"
destdir="@{destdir}"
deprecation="${javac.deprecation}"
debug="${javac.debug}"
source="@{javac.source}"
target="@{javac.target}">
<!-- <compilerarg line="-Xmaxwarns 10000000"/>
<compilerarg line="-Xmaxerrs 10000000"/> -->
<!-- for generics in Java 1.5: -->
<compilerarg line="-Xlint -Xlint:-deprecation -Xlint:-serial"/>
<nested/>
</javac>
</sequential>
</macrodef>
<!-- a cheap unittesting routine that executes all the tests found in the folder and below -->
<macrodef name="run-python-unittests">
<attribute name="srcdir"/>
<attribute name="python"/>
<attribute name="test-file" default=""/>
<attribute name="python-path"/>
<attribute name="failonerror" default="true"/>
<sequential>
<apply executable="@{python}" failonerror="@{failonerror}">
<env key="PYTHONPATH" value="@{python-path}" />
<arg value="-c" />
<arg value="import os,sys,unittest;x=sys.argv.pop();print 'Testing ', x;a,b=os.path.split(x);sys.path.insert(0,a);m=__import__(os.path.basename(b.split('.')[0]));y=unittest.main(m)"/>
<fileset dir="@{srcdir}">
<include name="**/unittest_*.py"/>
</fileset>
</apply>
<!--
<exec executable="@{python}" failonerror="true">
<env key="PYTHONPATH" value="@{python-path}${dist.dir}${path.separator}${env.PYTHONPATH}" />
<arg value="-c" />
<arg value="x='@{test-file}';import os,sys,unittest;a,b=os.path.split(x);sys.path.insert(0,a);m=__import__(os.path.basename(b.split('.')[0]));y=unittest.main(m)" />
</exec>
-->
</sequential>
</macrodef>
<macrodef name="get-lucene-solr-package">
<attribute name="package"/>
<attribute name="ant" default="${prop.ant}"/>
<attribute name="ant-target" default="jar"/>
<attribute name="pattern" default="*.jar"/>
<attribute name="into" default="${build.dir}/lib"/>
<sequential>
<mkdir dir="@{into}"/>
<!-- cal the ant -->
<apply executable="@{ant}" parallel="false" failonerror="true" failifexecutionfails="true">
<arg line="@{ant-target}"/>
<arg value="-f"/>
<fileset dir="${prop.solr.home}">
<include name="lucene/@{package}/build.xml"/>
<include name="solr/contrib/@{package}/build.xml"/>
</fileset>
</apply>
<!-- then copy the result -->
<copy todir="@{into}" overwrite="true" verbose="true" flatten="true">
<fileset dir="${prop.solr.home}">
<include name="lucene/build/@{package}/@{pattern}" />
<include name="solr/build/contrib/solr-@{package}/@{pattern}" />
</fileset>
</copy>
</sequential>
</macrodef>
</project>