Move version.jar to gerrit-war

This saves about 70ms when running targets like
//gerrit-gwtui:ui_chrome that reference a JAR in
gerrit-common but do not need the Version file.

Change-Id: Iab7377f3c5e1ce82cc3dc3ddcb3b1e4f9f12a8b7
This commit is contained in:
Shawn Pearce 2013-07-29 13:26:47 -07:00
parent da16183775
commit 1e6c3639f7
3 changed files with 31 additions and 32 deletions

View File

@ -31,35 +31,6 @@ java_library(
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )
prebuilt_jar(
name = 'version',
binary_jar = genfile('version.jar'),
deps = [':gen_version'],
visibility = ['PUBLIC'],
)
# TODO(sop): Move git describe into an uncacheable genrule()
def git_describe():
import subprocess
cmd = ['git', 'describe', '--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
genrule(
name = 'gen_version',
cmd = ';'.join([
'cd $TMP',
'mkdir -p com/google/gerrit/common',
'echo "%s" >com/google/gerrit/common/Version' % git_describe(),
'zip -9Dqr $OUT .',
]),
out = 'version.jar',
)
java_test( java_test(
name = 'client_tests', name = 'client_tests',
srcs = glob(['src/test/java/**/*.java']), srcs = glob(['src/test/java/**/*.java']),

View File

@ -51,3 +51,32 @@ prebuilt_jar(
'//tools/eclipse:classpath', '//tools/eclipse:classpath',
], ],
) )
prebuilt_jar(
name = 'version',
binary_jar = genfile('version.jar'),
deps = [':gen_version'],
visibility = ['//:'],
)
# TODO(sop): Move git describe into an uncacheable genrule()
def git_describe():
import subprocess
cmd = ['git', 'describe', '--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
genrule(
name = 'gen_version',
cmd = ';'.join([
'cd $TMP',
'mkdir -p com/google/gerrit/common',
'echo "%s" >com/google/gerrit/common/Version' % git_describe(),
'zip -9Dqr $OUT .',
]),
out = 'version.jar',
)

View File

@ -15,9 +15,8 @@ include_defs('//VERSION')
DOCS = ['//Documentation:html.zip'] DOCS = ['//Documentation:html.zip']
LIBS = [ LIBS = [
'//gerrit-common:version',
'//gerrit-war:init',
'//gerrit-war:log4j-config', '//gerrit-war:log4j-config',
'//gerrit-war:init',
'//lib:postgresql', '//lib:postgresql',
'//lib/log:impl_log4j', '//lib/log:impl_log4j',
] ]
@ -70,7 +69,7 @@ def war(
def gerrit_war(name, ui = 'ui_optdbg', context = []): def gerrit_war(name, ui = 'ui_optdbg', context = []):
war( war(
name = name, name = name,
libs = LIBS, libs = LIBS + ['//gerrit-war:version'],
pgmlibs = PGMLIBS, pgmlibs = PGMLIBS,
context = [ context = [
'//gerrit-main:main_bin.jar', '//gerrit-main:main_bin.jar',