-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbuild.xml
491 lines (385 loc) · 17.3 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
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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
<?xml version="1.0"?>
<project name="montysolr" default="usage">
<description>Java extensions for Python - Java search engine made python-friendly</description>
<!--
==================================================================
Configuration section
==================================================================
-->
<property name="montysolr.home" location="." />
<property name="src.dir.java" location="src/java" />
<property name="build.dir" location="build" />
<property name="dist.dir" value="build/dist" />
<property name="classes.dir" value="build/classes/java" />
<property file="build.properties" />
<property name="solr.home" location="${build.dir}/solr-download/apache-solr-${solr.version}"/>
<property name="webdist.home" location="${webdist}" />
<property name="lib.dir" value="lib" />
<property name="app.name" value="montysolr_java" />
<property name="app.solr.name" value="solr_java" />
<property name="app.version" value="${solr.version}.${montysolr.version}" />
<property name="jar.suffix" value="${app.name}-${app.version}.jar" />
<property name="ddash" value="--" />
<property environment="env"/>
<property name="solr.branch" value="branch_7_7" />
<import file="common-build.xml"/>
<path id="classpath">
<path refid="common.classpath"/>
</path>
<path id="test.classpath">
<path refid="common.test.classpath"/>
</path>
<path id="junit.classpath">
<path refid="common.junit.classpath"/>
</path>
<!--
==================================================================
Initialization & maintenance
==================================================================
-->
<target name="compile-test" depends="compile,common.compile-test" />
<target name="config" depends="init">
<property name="montysolr.jar" value="${build.dir}/${final.name}.jar" />
</target>
<!-- Default target: usage. Prints out instructions. -->
<target name="usage"
description="Prints out instructions">
<echo message="Welcome to the MontySolr project!" />
<echo message="Use 'ant build-all' to compile MontySolr and all its modules" />
<echo message="Use 'ant build-example' to prepare standalone distribution." />
<echo message="And for developers:"/>
<echo message="Use 'ant clean' to clean compiled files." />
<echo message="Use 'ant compile' to compile the Java source code." />
<echo message="Use 'ant test-all' to run unit tests." />
</target>
<!-- this is needed for all targets -->
<target name="init" depends="check_properties,die_unless_propertiesOK,check-solr-location">
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${classes.dir}" />
<mkdir dir="${build.dir}/jar" />
</target>
<target name="check_properties">
<condition property="propertiesOK">
<and>
<isset property="montysolr.version" />
<isset property="solr.version" />
</and>
</condition>
</target>
<target name="die_unless_propertiesOK" unless="propertiesOK">
<echo>The properties of the project are not set correctly. Copy "build.properties.default" -> "build.properties" and edit the new file if necessary.</echo>
<fail />
</target>
<target name="clean" depends="unlink-contrib">
<delete dir="${build.dir}"/>
<delete dir="${classes.dir}"/>
<mkdir dir="${classes.dir}"/>
</target>
<target name="default" depends="usage" />
<!--
==================================================================
Compilation section for jars
==================================================================
-->
<!-- this is needed for building targets -->
<target name="config-build" depends="config,check-solr-location,write-properties" >
<property name="_properties.written" value="true" />
</target>
<target name="test" depends="write-properties" description="Run tests for core and contrib">
<antcall target="common.test" inheritall="true" inheritrefs="true"/>
<antcall target="test-contrib" inheritall="true" inheritrefs="true"/>
</target>
<!-- obsolete: redirecting to test -->
<target name="test-all" depends="test" />
<!-- writes into a simple format various config variables, they can be used by unittests/java -->
<target name="write-properties" depends="config">
<echo file="${build.dir}/build.properties">
message=Automatically generated by ant during compilation of MontySolr, do not change!
solr.home=${solr.home}
solr.real.location=${solr.real.location}
lucene.real.location=${lucene.real.location}
montysolr.version=${montysolr.version}
solr.version=${solr.version}
</echo>
<!-- necessary only on windows (git bash) -->
<replaceregexp file="${build.dir}/build.properties"
match="\\"
replace="/"
flags="g"/>
</target>
<!--
==================================================================
Commands for a lazy developer
==================================================================
-->
<target name="build" description="Builds MontySOLR" depends="get-solr,write-properties,jar,build-contrib" />
<target name="build-contrib" description="Builds just the contrib parts">
<sequential>
<ant target="build-all" antfile="build.xml" dir="${common.dir}/contrib/antlrqueryparser" inheritall="false" />
<ant target="build-all" antfile="build.xml" dir="${common.dir}/contrib/adsabs" inheritall="false" />
<ant target="build-all" antfile="build.xml" dir="${common.dir}/contrib/examples" inheritall="false" />
</sequential>
</target>
<target name="build-all" description="Builds Montysolr + the distribution" depends="build">
<ant target="release" dir="${common.dir}/contrib/examples" inheritall="false" />
</target>
<target name="release" description="To build github release" depends="build">
<ant target="release" dir="${common.dir}/contrib/examples" inheritall="false" />
<move file="${build.dir}/contrib/examples/adsabs.zip" tofile="${build.dir}/contrib/examples/montysolr.zip" />
<!-- TODO: automatically bump the release in the source and upload the binary file to github -->
</target>
<target name="test-contrib" description="Tests contrib parts">
<ant target="test" dir="${common.dir}/contrib/antlrqueryparser" inheritall="false" />
<ant target="test" dir="${common.dir}/contrib/adsabs" inheritall="false" />
<ant target="test" dir="${common.dir}/contrib/examples" inheritall="false" />
</target>
<target name="unlink-contrib" >
<ant target="unlink-upstream" dir="${common.dir}/contrib/antlrqueryparser" inheritall="false" />
<ant target="unlink-upstream" dir="${common.dir}/contrib/adsabs" inheritall="false" />
<ant target="unlink-upstream" dir="${common.dir}/contrib/examples" inheritall="false" />
</target>
<target name="link-contrib" >
<ant target="link-upstream" dir="${common.dir}/contrib/antlrqueryparser" inheritall="false" />
<ant target="link-upstream" dir="${common.dir}/contrib/adsabs" inheritall="false" />
</target>
<!--
====================================================================
Installation goodies
====================================================================
-->
<target name="get-solr"
depends="get-solr-source-code,check-solr-location,build-solr-example,extract-solr-jars">
</target>
<!-- this is for development purposes - especially when lucene/solr stable releases are not yet there -->
<target name="get-solr-source-code">
<mkdir dir="${solr.home}"/>
<exec executable="git" failifexecutionfails="false" dir="${solr.home}">
<arg value="clone" />
<arg value="https://github.com/apache/lucene-solr.git" />
<arg value="${solr.home}" />
</exec>
<exec executable="git" failifexecutionfails="true" dir="${solr.home}">
<arg value="checkout" />
<arg value="${solr.branch}" />
</exec>
<echo>Fixing https://maven.restlet.com expired SSL certificate and domain change</echo>
<replace file="${solr.home}/lucene/default-nested-ivy-settings.xml" token="maven.restlet.com" value="maven.restlet.talend.com"/>
<antcall target="check-solr-location" />
</target>
<!--
this target sets the location of the solr, if not present, we'll assume
build/solr-download/apache-solr-${solr.version}/solr
The property may also be set by a download-solr task
-->
<target name="check-solr-location" >
<condition property="solr.real.location" value="${solr.home}">
<and>
<available file="${solr.home}/example/README.txt"/>
<available file="${solr.home}/contrib/contrib-build.xml"/>
</and>
</condition>
<condition property="solr.real.location" value="${solr.home}/solr">
<and>
<available file="${solr.home}/solr/example/README.txt"/>
<available file="${solr.home}/solr/contrib/contrib-build.xml"/>
</and>
</condition>
<condition property="solr.real.location" value="${build.dir}/solr-download/apache-solr-${solr.version}/solr">
<and>
<available file="${build.dir}/solr-download/apache-solr-${solr.version}/solr/example/README.txt"/>
<available file="${build.dir}/solr-download/apache-solr-${solr.version}/solr/contrib/contrib-build.xml"/>
</and>
</condition>
<echo message="Did we find solr location? Path=${solr.real.location}"/>
<property name="lucene.real.location" location="${solr.real.location}/../lucene" />
</target>
<target name="build-solr-example" depends="check-solr-location">
<echo>Fixing log4j version</echo>
<replace file="${lucene.real.location}/ivy-versions.properties"
token="org.apache.logging.log4j.version = 2.11.0"
value="org.apache.logging.log4j.version = 2.17.0"
>
</replace>
<echo>Building the Solr example </echo>
<exec executable="${ant}" dir="${solr.real.location}" logerror="true">
<env key="PATH" value="${ant.home}/bin${path.separator}${env.PATH}" />
<arg value="server" />
</exec>
</target>
<target name="build-montysolr-dependencies" depends="check-solr-location">
<ant target="build-modules" dir="${lucene.real.location}" inheritall="false" />
<ant target="dist-contrib" dir="${solr.real.location}" inheritall="false" />
<ant target="dist-test-framework" dir="${solr.real.location}" inheritall="false" />
</target>
<target name="check-solr-jars-exist" depends="build-montysolr-dependencies" >
<!-- since on old ant we cannot ignore it -->
<mkdir dir="${solr.real.location}/dist" />
<mkdir dir="${build.dir}/solrjars-extracted" />
<path id="montysolr.classpath.testing">
<fileset dir="${build.dir}/solrjars-extracted" includes="**/*.jar" />
</path>
<condition property="solr.jars.exist" value="true">
<and>
<available classname="org.apache.lucene.spatial.tier.InvalidGeoException" classpath="${toString:montysolr.classpath.testing}" />
</and>
</condition>
<echo message="Are lucene jars available? ${solr.jars.exist}" level="verbose" />
</target>
<!-- copy all useful (for development useful) jars from solr to our project -->
<target name="extract-solr-jars" depends="check-solr-jars-exist" unless="solr.jars.exist">
<delete dir="${build.dir}/solrjars-extracted" />
<!-- copy lucene jars -->
<copy todir="${build.dir}/solrjars-extracted/lucene" flatten="true">
<fileset dir="${lucene.real.location}/build">
<include name="**/**.jar"/>
</fileset>
</copy>
<!-- copy solr jars -->
<copy todir="${build.dir}/solrjars-extracted/solr">
<fileset dir="${solr.real.location}/dist">
<include name="**/**.jar"/>
</fileset>
</copy>
<!-- copy solr/webapp jars -->
<mkdir dir="${solr.real.location}/server/solr-webapp/webapp/WEB-INF/lib" />
<copy todir="${build.dir}/solrjars-extracted/solr">
<fileset dir="${solr.real.location}/server/solr-webapp/webapp/WEB-INF/lib">
<include name="**/**.jar"/>
</fileset>
</copy>
<!-- copy jetty jars -->
<copy todir="${build.dir}/solrjars-extracted/jetty">
<fileset dir="${solr.real.location}/server/lib">
<include name="**/**.jar"/>
</fileset>
</copy>
<!-- cleanup -->
<delete dir="${build.dir}/solrjars-extracted" includeemptydirs="true">
<exclude name="**/**.jar"/>
</delete>
</target>
<target name="dist"
description="Assembles ADSABS example and starts MontySolr (don't forget to do build-all first)"
depends="">
<exec executable="ant" dir="${common.dir}/contrib/examples" logerror="true" newenvironment="true">
<arg line="build-one -Dename=adsabs -Dprofile=normal" />
</exec>
</target>
<target name="install-eclipse-project-files" depends="init" >
<property name="_home" location="." />
<exec executable="${python}" failonerror="true" outputproperty="_top_folder" logerror="true">
<arg value="-c"/>
<arg value="import os;print os.path.basename(os.path.abspath('.'))" />
</exec>
<exec executable="${python}" failonerror="true" outputproperty="_python_ver" logerror="true">
<arg value="-c"/>
<arg value="import sys;print '%s.%s' % sys.version_info[:2]" />
</exec>
<echo file=".project">
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>]]></echo>
<echo file=".project" append="true">${_top_folder}</echo>
<echo file=".project" append="true">
<![CDATA[</name>
<comment>
</comment>
<projects>
<project>lucene_solr_3_1</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
]]> </echo>
<echo file=".pydevproject">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?eclipse-pydev version="1.0"?>
<pydev_project>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python ${_python_ver}</pydev_property>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/${_top_folder}/src/python</path>
</pydev_pathproperty>
<pydev_pathproperty name="org.python.pydev.PROJECT_EXTERNAL_SOURCE_PATH">
<path>${_home}/build/dist</path>
</pydev_pathproperty>
</pydev_project>
</echo>
<echo file=".classpath">
<![CDATA[
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/java"/>
<classpathentry kind="src" path="test/java"/>
<classpathentry kind="lib" path="lib/junit-3.8.2.jar"/>
<classpathentry kind="lib" path="lib/jzlib-1.0.7.jar"/>
<classpathentry kind="lib" path="lib/commons-io-1.4.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.5.5.jar"/>
<classpathentry kind="lib" path="lib/slf4j-jdk14-1.5.5.jar"/>
<classpathentry kind="lib" path="]]></echo>
<echo file=".classpath" append="true">${jcc_egg}/jcc/classes</echo>
<echo file=".classpath" append="true"><![CDATA["/>
<classpathentry combineaccessrules="false" kind="src" path="/lucene_solr_3_1"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
]]> </echo>
</target>
<!-- to setup dev environment -->
<target name="eclipse" description="Sets up the dev project for Eclipse" depends="check-solr-location">
<subant target="ivy-bootstrap" inheritall="false" failonerror="true" buildpath="${solr.real.location}/..">
<fileset dir="${solr.real.location}/../lucene" includes="build.xml" />
</subant>
<!-- this will set the project for lucene/ we'll just copy the files and modify them-->
<subant target="eclipse" inheritall="false" failonerror="true" buildpath="${solr.real.location}/..">
<fileset dir="${solr.real.location}/.." includes="build.xml" />
</subant>
<copy file="${solr.real.location}/../.project" tofile=".project" overwrite="false"/>
<copy file="${solr.real.location}/../.classpath" tofile=".classpath" overwrite="true"/>
<mkdir dir=".settings"/>
<copy todir=".settings/" overwrite="true">
<fileset dir="${solr.real.location}/../.settings" includes="*.prefs" />
</copy>
</target>
<target name="modify-eclipse" depends="check-solr-location">
<copy file="${solr.real.location}/../.classpath" tofile=".classpath" overwrite="true"/>
<!-- change path to point to the local solr checkout -->
<property name="_before" value="${solr.real.location}"/>
<property name="_up" location="${solr.real.location}/.."/>
<property name="_root" location="."/>
<script language="javascript">
<![CDATA[
var before = project.getProperty("_before");
var r = project.getProperty("_root");
var u = project.getProperty("_up");
var m = before.substring(0, u.length()).substring(r.length()+1).replace("\\", "/") + "/";
project.setProperty("solr.relative.location", m);
]]>
</script>
<replace file=".classpath">
<replacefilter token="path="" value="path="${solr.relative.location}"/>
<replacefilter token="output="" value="output="${solr.relative.location}"/>
</replace>
</target>
<target name="ex" depends="check-solr-location">
<ant target="example"
dir="${solr.real.location}"
inheritall="false" />
</target>
</project>