Browse Source

buck: set Bundle-Version for :jgit_bin

Run git describe during the build to determine the lineage of this
working directory and stamp this information into the binary.

Change-Id: I0ad24125c31e4280ccf900bac4065924087b05aa
stable-4.3
Shawn Pearce 9 years ago
parent
commit
776c3003aa
  1. 31
      org.eclipse.jgit.pgm/BUCK
  2. 9
      tools/git.defs

31
org.eclipse.jgit.pgm/BUCK

@ -1,3 +1,5 @@
include_defs('//tools/git.defs')
java_library( java_library(
name = 'pgm', name = 'pgm',
srcs = glob(['src/**']), srcs = glob(['src/**']),
@ -27,8 +29,14 @@ genrule(
genrule( genrule(
name = 'jgit', name = 'jgit',
cmd = 'cat $SRCDIR/jgit.sh $(location :jgit_jar) >$OUT;' + cmd = ''.join([
'chmod a+x $OUT', 'mkdir $TMP/META-INF &&',
'cp $(location :binary_manifest) $TMP/META-INF/MANIFEST.MF &&',
'cp $(location :jgit_jar) $TMP/jgit.jar &&',
'cd $TMP && zip $TMP/jgit.jar META-INF/MANIFEST.MF &&',
'cat $SRCDIR/jgit.sh $TMP/jgit.jar >$OUT &&',
'chmod a+x $OUT',
]),
srcs = ['jgit.sh'], srcs = ['jgit.sh'],
out = 'jgit', out = 'jgit',
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
@ -36,10 +44,27 @@ genrule(
java_binary( java_binary(
name = 'jgit_jar', name = 'jgit_jar',
main_class = 'org.eclipse.jgit.pgm.Main',
deps = [ deps = [
':pgm', ':pgm',
'//lib:slf4j-simple', '//lib:slf4j-simple',
'//lib:tukaani-xz', '//lib:tukaani-xz',
], ],
blacklist = [
'META-INF/DEPENDENCIES',
'META-INF/maven/.*',
],
)
genrule(
name = 'binary_manifest',
cmd = ';'.join(['echo "%s: %s" >>$OUT' % e for e in [
('Manifest-Version', '1.0'),
('Main-Class', 'org.eclipse.jgit.pgm.Main'),
('Bundle-Version', git_version()),
('Implementation-Title', 'JGit Command Line Interface'),
('Implementation-Vendor', 'Eclipse.org - JGit'),
('Implementation-Vendor-URL', 'http://www.eclipse.org/jgit/'),
('Implementation-Vendor-Id', 'org.eclipse.jgit'),
]] + ['echo >>$OUT']),
out = 'MANIFEST.MF',
) )

9
tools/git.defs

@ -0,0 +1,9 @@
def git_version():
import subprocess
cmd = ['git', 'describe', '--always', '--match', 'v[0-9].*', '--dirty']
p = subprocess.Popen(cmd, stdout = subprocess.PIPE)
v = p.communicate()[0].strip()
r = p.returncode
if r != 0:
raise subprocess.CalledProcessError(r, ' '.join(cmd))
return v
Loading…
Cancel
Save