27
27
]
28
28
29
29
LUCENE_VERSION = '6.2.0-SNAPSHOT'
30
- LUCENE_SERVER_VERSION = '0.1.0-SNAPSHOT'
30
+ LUCENE_SERVER_BASE_VERSION = '0.1.0'
31
+ LUCENE_SERVER_VERSION = '%s-SNAPSHOT' % LUCENE_SERVER_BASE_VERSION
31
32
32
33
luceneDeps = ('core' ,
33
34
'analyzers-common' ,
@@ -353,7 +354,7 @@ def getFlag(option):
353
354
else :
354
355
return False
355
356
356
- def compileSourcesAndDeps ():
357
+ def compileSourcesAndDeps (jarVersion ):
357
358
if not os .path .exists ('lib' ):
358
359
print ('init: create ./lib directory...' )
359
360
os .makedirs ('lib' )
@@ -374,15 +375,38 @@ def compileSourcesAndDeps():
374
375
compileLuceneModules (luceneDeps )
375
376
376
377
# compile luceneserver sources
377
- jarFileName = 'build/luceneserver-%s.jar' % LUCENE_SERVER_VERSION
378
+ jarFileName = 'build/luceneserver-%s.jar' % jarVersion
378
379
379
380
l = getCompileClassPath ()
380
381
l .append ('build/classes/java' )
381
382
compileChangedSources ('src/java' , 'build/classes/java' , l )
382
383
383
384
if anyChanges ('build/classes/java' , jarFileName ):
384
385
print ('build %s' % jarFileName )
385
- run ('jar cf %s -C build/classes/java .' % jarFileName )
386
+ gitHash = os .popen ('git rev-parse --short HEAD' ).readline ().strip ()
387
+ modifiedFileCount = 0
388
+ with os .popen ('git ls-files -m' ) as p :
389
+ while True :
390
+ line = p .readline ()
391
+ if line == '' :
392
+ break
393
+ modifiedFileCount += 1
394
+
395
+ with open ('build/manifest.mf' , 'w' ) as f :
396
+ f .write ('Extension-Name: org.apache.lucene.server\n ' )
397
+ f .write ('Specification-Title: Thin HTTP/REST server wrapper for Apache Lucene\n ' )
398
+ f .write ('Specification-Vendor: Mike McCandless\n ' )
399
+ f .write ('Specification-Version: %s\n ' % LUCENE_SERVER_BASE_VERSION )
400
+ f .write ('Implementation-Title: org.apache.lucene.server\n ' )
401
+ f .write ('Implementation-Vendor: Mike McCandless\n ' )
402
+ if modifiedFileCount > 0 :
403
+ if '-SNAPSHOT' not in jarVersion :
404
+ raise RuntimeError ('there are modified sources; cannot build releasable JAR' )
405
+ f .write ('Implementation-Version: %s %s; %d source files modified\n ' % (jarVersion , gitHash , modifiedFileCount ))
406
+ else :
407
+ f .write ('Implementation-Version: %s %s\n ' % (jarVersion , gitHash ))
408
+
409
+ run ('jar cefm org.apache.lucene.server.Server %s build/manifest.mf -C build/classes/java .' % jarFileName )
386
410
387
411
return jarFileName
388
412
@@ -403,14 +427,18 @@ def main():
403
427
run ('ant clean' )
404
428
os .chdir (ROOT_DIR )
405
429
elif what == 'package' :
430
+
431
+ jarVersion = getArg ('-version' )
432
+ if jarVersion is None :
433
+ jarVersion = LUCENE_SERVER_VERSION
406
434
407
- jarFileName = compileSourcesAndDeps ()
435
+ jarFileName = compileSourcesAndDeps (jarVersion )
408
436
409
- destFileName = 'build/luceneserver-%s.zip' % LUCENE_SERVER_VERSION
410
- rootDirName = 'luceneserver-%s' % LUCENE_SERVER_VERSION
437
+ destFileName = 'build/luceneserver-%s.zip' % jarVersion
438
+ rootDirName = 'luceneserver-%s' % jarVersion
411
439
412
440
with zipfile .ZipFile (destFileName , 'w' ) as z :
413
- z .write (jarFileName , '%s/lib/luceneserver-%s.jar' % (rootDirName , LUCENE_SERVER_VERSION ))
441
+ z .write (jarFileName , '%s/lib/luceneserver-%s.jar' % (rootDirName , jarVersion ))
414
442
for org , name , version in deps :
415
443
z .write ('lib/%s-%s.jar' % (name , version ), '%s/lib/%s-%s.jar' % (rootDirName , name , version ))
416
444
for dep in luceneDeps :
0 commit comments