forked from adsabs/montysolr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
769 lines (609 loc) · 28 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
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
<project name="montysolr" default="usage">
<description>Java extensions for Invenio - Java search engine made python-friendly</description>
<!--
==================================================================
Configuration section
==================================================================
-->
<property name="montysolr.home" location="." />
<property name="src.dir.java" location="src/java" />
<property name="src.dir.python" location="src/python" />
<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" />
<!-- these are now defined in the properties file
<property name="jcc" value="jcc.__main__" />
<property name="solr_home" value="/x/dev/workspace/apache-solr-1.4.1"/>
<property name="python" value="python"/>
//-->
<property name="solr.home" location="${solr_home}"/>
<property name="webdist.home" location="${webdist}" />
<property name="lib.dir" value="lib" />
<property name="app.name" value="montysolr_java" />
<property name="app.version" value="0.1" />
<property name="jar.suffix" value="${app.name}-${app.version}.jar" />
<property name="app.solr.name" value="solr_java" />
<property name="app.solr.version" value="0.1" />
<property name="ddash" value="--" />
<!-- standard arguments for running the Solr -->
<property name="run.solr.jvmargs" value="-d64 -Xmx1024m -Dmontysolr.max_workers=4 -Dmontysolr.max_threads=200" />
<property name="run.solr.args" value="" />
<!-- these will be used when running tests and command line montysolr
you can set them as:
export MONTYSOLR_JVMARGS=-Djava.util.logging.config.file=./example/etc/test.logging.properties
If you are using python c-extensions, make sure they are compatible with the
java - if your java starts in 64bit mode, also the extensions must be available in 64bit
//-->
<property environment="env"/>
<property name="subant.jvmargs" value="" />
<property name="subant.args" value="" />
<property name="subant.newenvironment" value="true" />
<property name="env.MONTYSOLR_JVMARGS" value="${subant.jvmargs}"/>
<property name="env.MONTYSOLR_ARGS" value="${subant.args}"/>
<property name="env.MONTYSOLR_NEWENVIRONMENT" value="${subant.newenvironment}"/>
<property name="env.PYTHONPATH" value="${dist.dir}${path.separator}${src.dir.python}${path.separator}"/>
<!--
these classes must be made available/known to JCC when we compile the wrapper
They will be made visible to Python, but are also used for generation of the jars.
-->
<property name="montysolr.classes" value="
invenio.montysolr.jni.MontySolrBridge
invenio.montysolr.jni.MontySolrVM
invenio.montysolr.jni.PythonBridge
invenio.montysolr.jni.PythonMessage
" />
<property name="jcc.build" value="${montysolr.classes}" />
<property name="jcc.packages" value="
--package ch.cern.invenio.utils
"/>
<!--
_build variables are there to add extra classes to the wrapper - some packages (either in lucene or for montysolr)
are not usable/visible, unless also these classes are present. So this is here to add these extra components to the build.
I tried registerining packages only, but it didn't work for v2.9, so i am listing classes directly
java.util.ArrayList
-->
<property name="jcc.build_also" value="
java.lang.Float
java.lang.System
java.lang.String
org.apache.solr.request.SolrQueryRequest
org.apache.solr.request.SolrQueryResponse" />
<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 stuff
==================================================================
-->
<target name="compile-test" depends="compile,common.compile-test" />
<target name="config" depends="init">
<property name="my.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 prepare demos." />
<echo message="Use 'ant run-example' to run the example." />
<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 build' to compile only MontySolr as a Python module." />
<echo message="Use 'ant build-solr' to compile only Solr as a Python module." />
<echo message="TODOs:" />
<echo message="Use 'ant automatic-install' to install everything incl dependencies." />
<echo message="Use 'ant package' to generate zip, tgz, and maven artifacts for distribution." />
<echo message="Use 'ant test' 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" />
<exec executable="${python}" failonerror="false" errorproperty="test_import_errors" >
<arg value="-c"/>
<arg value="import jcc; import lucene" />
</exec>
<condition property="import_ok">
<equals arg1="${test_import_errors}" arg2=""/>
</condition>
<fail unless="import_ok" message="${test_import_errors}${line.separator}Please install the required Python modules first (jcc, lucene)" />
<exec executable="${python}" failonerror="true" outputproperty="webdist.webapp" logerror="true">
<arg value="-c"/>
<arg value="import os;d='${webdist.home}';print os.path.exists(d+'/webapps/solr.war') and d+'/webapps/solr.war' or d+'/webapps'" />
</exec>
<!-- retrieves the location of the jcc and stores in inside jcc_egg -->
<exec executable="${python}" failonerror="true" outputproperty="jcc_egg" logerror="true">
<arg value="-c"/>
<arg value="import os, jcc; print os.path.dirname(os.path.dirname(jcc.__file__))" />
</exec>
</target>
<target name="check_properties">
<condition property="propertiesOK">
<and>
<isset property="solr_home" />
<isset property="webdist" />
<isset property="python" />
<isset property="jcc" />
</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" >
<delete dir="${build.dir}" />
<delete dir="${classes.dir}" />
<mkdir dir="${classes.dir}"/>
</target>
<target name="default">
</target>
<!--
==================================================================
Compilation section for jars
==================================================================
-->
<!-- this is needed for building targets -->
<target name="config-build" depends="config,check-solr-location,check-lucene-jars,set-jar-paths,write-properties" >
<property name="_properties.written" value="true" />
</target>
<target name="set-jar-paths">
<!--
The part below will discover all the paths inside the directory (for the
given pattern) and the property with .path end element will look like
path1 [dash][dash]jar path2 [dash][dash]jar path3....
However, this is suboptimal for cases, when there are two versions of the
jar file in the folder, for example:
solr-core-1.4.1.jar
solr-core-1.4.2-dev.jar
We include them all. TODO: pick the newest file only
-->
<path id="solr.core.path">
<fileset dir="${solr.real.location}/dist" id="solr.core.jar" >
<filename name="*solr-core-*.jar"/>
</fileset>
</path>
<pathconvert property="solr.core.jar.string" pathsep=" --jar ">
<path refid="solr.core.path" />
</pathconvert>
<path id="solr.sorlj.path">
<fileset dir="${solr.real.location}/dist" id="solr.solrj.jar" >
<filename name="*solr-solrj-*.jar"/>
</fileset>
</path>
<pathconvert property="solr.solrj.jar.string" pathsep=" --jar ">
<path refid="solr.sorlj.path" />
</pathconvert>
<path id="montysolr.classpath">
<fileset dir="${build.dir}" includes="montysolr*.jar" />
<fileset dir="${solr.real.location}/dist" includes="**/*.jar" />
<fileset dir="${solr.real.location}" includes="lib/**/*.jar" />
<fileset dir="${solr.real.location}" includes="example/lib/**/*.jar" />
<fileset dir="${webdist.home}" includes="lib/**/*.jar" />
<fileset dir="${lib.dir}" includes="**/*.jar" />
</path>
</target>
<!-- Compiles all java classes -->
<target name="compile" depends="config-build">
<compile srcdir="${src.dir.java}" destdir="${classes.dir}">
<classpath path="${jcc_egg}/jcc/classes"/>
<classpath refid="montysolr.classpath"/>
</compile>
</target>
<target name="test" depends="write-properties">
<antcall target="common.test" inheritall="true" inheritrefs="true"/>
</target>
<target name="test-all" depends="test,test-contrib" description="Run tests for core and contrib"/>
<!-- 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.home=${solr.home}
solr.real.location=${solr.real.location}
jcc=${jcc}
jcc_egg=${jcc_egg}
webdist=${webdist}
webdist.home=${webdist.home}
python=${python}
solr.version=${solr.version}
lucene.version=${lucene.version}
</echo>
</target>
<!--
==================================================================
Jetty (JavaVM) embedded in Python - this becomes obsolete, but
does not need be. The same code works in Python (and in fact,
is used when we run python unittests). But I do concentrate on
the Python-inside-Java mode now.
==================================================================
-->
<!-- Builds jar and also compile Java-Pyhon wrapper - this is all you need to run Solr inside Python; cleans everything before starting -->
<target name="montysolr-jetty-build-clean"
depends="clean,montysolr-jetty-build"/>
<!-- Builds jar and also compile Java-Pyhon wrapper - this is all you need to run Solr inside Python -->
<target name="montysolr-jetty-build"
depends="config-build,jar,montysolr-jetty-egg-compilation,unzip-egg">
</target>
<target name="montysolr-jetty-egg-compilation" depends="jar">
<mkdir dir="${build.dir}" />
<delete dir="${build.dir}/build" failonerror="no" />
<exec executable="${python}" dir="${build.dir}" failonerror="true" logerror="true">
<arg line="${jcc}" />
<arg value="${ddash}shared" />
<!--<arg value="${ddash}no-generics" />-->
<arg line="${jcc.build_also}" />
<arg line="${jcc.build}" />
<arg value="${ddash}python" />
<arg value="${app.name}" />
<arg value="${ddash}build" />
<arg value="${ddash}classpath" />
<arg value="${toString:montysolr.classpath}${path.separator}../${my.montysolr.jar}" />
<arg value="${ddash}include" />
<arg value="../${my.montysolr.jar}" />
<arg value="${ddash}bdist" />
<arg value="${ddash}version" />
<arg value="${app.version}" />
</exec>
</target>
<!--
==================================================================
Testing Python Eggs
==================================================================
-->
<target name="before-unzip">
<delete dir="${build.dir}/${app.name}.egg-info" failonerror="no" />
<delete dir="${build.dir}/EGG-INFO" failonerror="no" />
</target>
<!-- Unzip the egg into python-test to be loadable -->
<target name="unzip-egg" depends="config-build,before-unzip">
<delete dir="${dist.dir}/${app.name}" failonerror="yes" />
<unzip dest="${dist.dir}" overwrite="yes">
<fileset dir="${dist.dir}">
<include name="${app.name}*.egg" />
</fileset>
</unzip>
<move file="${dist.dir}/EGG-INFO" tofile="${dist.dir}/${app.name}.egg-info" />
<!-- write the current classpath into a text file -->
<echo file="${dist.dir}/${app.name}/classpath">${toString:montysolr.classpath}</echo>
</target>
<!-- Just a basic test to verify that our montysolr package is correctly compiled and contains the necessary classes -->
<target name="test-egg" depends="config-build">
<exec executable="${python}" dir="${dist.dir}" failonerror="true" logerror="true">
<arg value="-c" />
<arg value="import ${app.name} as X;X.initVM(X.CLASSPATH+'${path.separator}${toString:montysolr.classpath}',vmargs='-Dsolr.solr.home=/x/dev/workspace/test-solr/solr,-Dsolr.data.dir=/x/dev/workspace/test-solr/solr/data');assert (X.__file__ == 'montysolr/__init__.pyc')" />
</exec>
</target>
<!--
==================================================================
Embedding Python VM in Java VM
==================================================================
-->
<target name="build-all" depends="example,build-solr,build,build-contrib"
description="Build Python egg for Solr, and sorlpie egg to be embedded inside Java VM, this is what you need to run Invenio inside Solr"/>
<target name="build" depends="config-build,compile-montysolr-egg,unzip-egg"
description="Build MontySolr separately"/>
<!-- Compile egg for embedding into Java VM -->
<target name="compile-montysolr-egg" depends="compile,jar">
<mkdir dir="${build.dir}" />
<delete dir="${build.dir}/build" failonerror="no" />
<exec executable="${python}" dir="${build.dir}" failonerror="true" logerror="true">
<env key="PYTHONPATH" value="${src.dir.python}${path.separator}../${dist.dir}${path.separator}${env.PYTHONPATH}" />
<!-- this is mac specific, i will yet have to find out how to make it os-specific -->
<env key="JCC_LFLAGS" value="-framework${path.separator}JavaVM${path.separator}-framework${path.separator}Python" />
<arg line="${jcc}" />
<arg value="${ddash}shared" />
<arg value="${ddash}version" />
<arg value="${app.version}" />
<arg line="${jcc.build}" />
<arg line="${jcc.build_also}" />
<arg value="${ddash}import"/>
<arg value="lucene" />
<arg value="${ddash}import" />
<arg value="${app.solr.name}" />
<!--
<arg value="${ddash}jar" />
<arg value="../${my.montysolr.jar}" />
-->
<arg line="${jcc.packages}" />
<arg value="${ddash}package" />
<!--<arg line="org.apache.solr.request ${ddash}package java.lang" />-->
<arg line="org.apache.solr.request" />
<arg value="${ddash}classpath" />
<arg value="${toString:montysolr.classpath}${path.separator}../${my.montysolr.jar}:${path.separator}${jcc_egg}/jcc/classes/" />
<arg value="${ddash}include" />
<arg value="${my.montysolr.jar}" />
<arg value="${ddash}python" />
<arg value="${app.name}" />
<arg value="${ddash}build" />
<arg value="${ddash}bdist" />
<!-- this can be activated if i want to distribute python together with the jcc, python code
will be copied into the extension folder
<arg value="${ddash}module" />
<arg value="${src.dir.python}" />
-->
</exec>
</target>
<target name="build-solr" depends="config-build,compile-solr-egg,unzip-solr"
description="Build separately the Python egg of Solr"/>
<target name="build-contrib" >
<apply executable="ant" parallel="false" failonerror="true">
<arg line="build-all"/>
<arg value="-f"/>
<fileset dir="${common.dir}/contrib">
<include name="**/anlrqueryparser/build.xml"/>
<include name="**/invenio/build.xml"/>
<include name="**/newseman/build.xml"/>
<include name="**/adsabs/build.xml"/>
<include name="**/examples/build.xml"/>
</fileset>
</apply>
</target>
<target name="test-contrib" >
<apply executable="ant" parallel="false" failonerror="true">
<arg line="test"/>
<arg value="-f"/>
<fileset dir="${common.dir}/contrib">
<include name="**/anlrqueryparser/build.xml"/>
<include name="**/invenio/build.xml"/>
<include name="**/newseman/build.xml"/>
<include name="**/adsabs/build.xml"/>
<include name="**/examples/build.xml"/>
</fileset>
</apply>
</target>
<target name="compile-solr-egg" depends="config-build">
<mkdir dir="${build.dir}" />
<delete dir="${build.dir}/build" failonerror="no" />
<echo message="You can watch Monty Python, this takes a while..." />
<exec executable="${python}" dir="${build.dir}" failonerror="true" logerror="true">
<env key="PYTHONPATH" value="${src.dir.python}${path.separator}${env.PYTHONPATH}" />
<!-- this is mac specific, i will yet have to find out how to make it os-specific,
but it makes no problems to Ubuntu/SLC linux os'es so far -->
<env key="JCC_LFLAGS" value="-framework${path.separator}JavaVM${path.separator}-framework${path.separator}Python" />
<arg line="${jcc}" />
<arg value="${ddash}shared" />
<arg value="${ddash}version" />
<arg value="${app.solr.version}" />
<arg value="${ddash}import"/>
<arg value="lucene" />
<arg line="${ddash}jar ${solr.core.jar.string}" />
<arg line="${ddash}jar ${solr.solrj.jar.string}" />
<arg value="${ddash}classpath" />
<arg value="${toString:montysolr.classpath}${path.separator}${jcc_egg}/jcc/classes/" />
<arg value="${ddash}package" />
<arg value="java.lang" />
<arg value="${ddash}python" />
<arg value="${app.solr.name}" />
<arg value="${ddash}build" />
<arg value="${ddash}bdist" />
<!-- We exclude the embedded classes because they are Jetty specific -->
<arg line="${ddash}exclude org.apache.solr.search.FunctionQParser
${ddash}exclude org.apache.solr.client.solrj.embedded.NoLog
${ddash}exclude org.apache.solr.client.solrj.embedded.JettySolrRunner
" />
</exec>
</target>
<target name="unzip-solr">
<!-- retrieves the location of the jcc -->
<exec executable="${python}" failonerror="true" outputproperty="_tmp_solr_err" dir="${build.dir}/dist" logerror="true">
<arg value="-c"/>
<arg value="import os,glob; print os.path.abspath(glob.glob('./${app.solr.name}*.egg')[0])" />
</exec>
<delete dir="${dist.dir}/${app.solr.name}.egg-info" failonerror="no" />
<delete dir="${dist.dir}/${app.solr.name}" failonerror="no" />
<unzip dest="${dist.dir}" overwrite="yes">
<fileset dir="${dist.dir}">
<include name="${app.solr.name}*.egg" />
</fileset>
</unzip>
<move file="${dist.dir}/EGG-INFO" tofile="${dist.dir}/${app.solr.name}.egg-info" />
</target>
<!--
====================================================================
Installation goodies
====================================================================
-->
<target name="example"
depends="check-solr-location,download-solr,build-solr-example">
</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/start.jar"/>
<available file="${solr.home}/lib/README.committers.txt"/>
</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/start.jar"/>
<available file="${build.dir}/solr-download/apache-solr-${solr.version}/solr/lib/README.committers.txt"/>
</and>
</condition>
<echo message="Did we find solr location? Path=${solr.real.location}"/>
</target>
<!-- Download the solr binary distribution, unless it was already downloaded (if solr.real.location is
set, then we know solr was already downloaded/exists) -->
<target name="download-solr"
unless="solr.real.location" depends="get-solr-mirror">
<!-- can't rely on the init target -->
<mkdir dir="${build.dir}/solr-download/"/>
<echo>Downloading Solr, please wait... (but if it takes too long, then run me again and I'll use a different mirror)</echo>
<get src="${solr.mirror}/${solr.version}/apache-solr-${solr.version}-src.tgz" dest="${build.dir}/solr-download/${solr.version}-src.tgz"
verbose="true" ignoreerrors="true"/>
<condition property="_download.using.apache.mirror" value="true">
<not>
<available file="${build.dir}/solr-download/${solr.version}-src.tgz"/>
</not>
</condition>
<antcall target="download-using-apache-mirror" />
<antcall target="untar-solr" />
<!-- set the property, it may be used by other targets (see check-solr-location target) -->
<property name="solr.real.location" value="${build.dir}/solr-download/apache-solr-${solr.version}/solr"/>
</target>
<target name="download-using-apache-mirror" if="_download.using.apache.mirror">
<echo>This is used only when the download using mirror site fails</echo>
<get src="http://archive.apache.org/dist/lucene/solr/${solr.version}/apache-solr-${solr.version}-src.tgz" dest="${build.dir}/solr-download/${solr.version}-src.tgz"
verbose="true" ignoreerrors="false"/>
</target>
<target name="untar-solr" >
<untar dest="${build.dir}/solr-download" src="${build.dir}/solr-download/${solr.version}-src.tgz" compression="gzip"/>
</target>
<target name="build-solr-example" depends="check-solr-location">
<echo>Building the Solr example</echo>
<!--
Unfortunately, the ant task is having some problems with the basedir (ant 1.7)
<ant target="example"
dir="${build.dir}/solr-download/apache-solr-${solr.version}/"
inheritall="false"
/>
-->
<exec executable="ant" dir="${solr.real.location}" logerror="true">
<env key="PATH" value="${ant.home}/bin${path.separator}${env.PATH}" />
<arg value="example" />
</exec>
</target>
<target name="try-lucene-jars" depends="check-solr-location" >
<!-- since on old ant we cannot ignore it -->
<mkdir dir="${solr.real.location}/dist" />
<path id="montysolr.classpath.testing">
<fileset dir="${solr.real.location}/dist" includes="**/*.jar" />
</path>
<condition property="lucene.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? ${lucene.jars.exist}" level="verbose" />
</target>
<target name="check-lucene-jars" depends="try-lucene-jars" unless="lucene.jars.exist">
<delete dir="${solr.real.location}/dist/montysolr-extracted" />
<mkdir dir="${solr.real.location}/dist/montysolr-extracted" />
<unzip dest="${solr.real.location}/dist/montysolr-extracted" overwrite="yes">
<fileset dir="${solr.real.location}/dist">
<include name="apache-solr*.war" />
</fileset>
</unzip>
<move todir="${solr.real.location}/dist/montysolr-extracted">
<fileset dir="${solr.real.location}/dist/montysolr-extracted/WEB-INF/lib">
<include name="**/**.jar"/>
</fileset>
</move>
<delete dir="${solr.real.location}/dist/montysolr-extracted" includeemptydirs="true">
<exclude name="**/**.jar"/>
</delete>
</target>
<target name="run-example"
description="Assembles Invenio 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 run-configured -Dename=invenio -Dprofile=normal.profile" />
</exec>
</target>
<target name="get-solr-mirror" depends="init" unless="solr.real.location">
<exec executable="${python}" outputproperty="solr.mirror" failonerror="true" logerror="true">
<arg value="-c" />
<arg value="import urllib;t = urllib.urlopen('http://www.apache.org/dyn/closer.cgi/lucene/solr/').read();l = filter(lambda x: 'lucene/solr' in x, map(lambda x: x.split('"')[0], filter(lambda x: x[:4] == 'http', t.split('href="'))));print l[0]"/>
</exec>
<echo>We will use the mirror: ${solr.mirror}</echo>
</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 combineaccessrules="false" kind="src" path="/jetty-6.1.4"/>
<classpathentry kind="output" path="bin"/>
</classpath>
]]> </echo>
</target>
<target name="get-solr-home" >
<echo>@${solr_home}@</echo>
</target>
<target name="test-python">
<run-python-unittests python="${python}" python-path="${env.PYTHONPATH}${path.separator}${dist.dir}${path.separator}${src.dir.python}"
srcdir="${common.dir}/src/python"
/>
</target>
</project>