Update Buck

java_library() now accepts provided_deps argument which replaces
our custom use of java_library2().

This change replaces compile_deps with provided_deps parameter in
gerrit_{plugin,extension} rules. Plugins that are using it must be
updated.

Change-Id: I16d53793da567c958267f91ca203e9cae6c4d02f
This commit is contained in:
Shawn Pearce 2014-05-02 13:22:49 -07:00 committed by David Ostrovsky
parent c798b4cc20
commit 334997292c
15 changed files with 52 additions and 73 deletions

View File

@ -1 +1 @@
1ba4496a782b40dec33a42e69a74837afee06177 021695d5e68cde7457c9849fd0a2397f91e6491e

View File

@ -22,9 +22,14 @@ from os import chdir, path
import re import re
from shutil import copyfileobj from shutil import copyfileobj
from subprocess import Popen, PIPE from subprocess import Popen, PIPE
from sys import stdout from sys import stdout, stderr
MAIN = ['//gerrit-pgm:pgm', '//gerrit-gwtui:ui_module'] MAIN = ['//gerrit-pgm:pgm', '//gerrit-gwtui:ui_module']
KNOWN_PROVIDED_DEPS = [
'//lib/bouncycastle:bcpg',
'//lib/bouncycastle:bcpkix',
'//lib/bouncycastle:bcprov',
]
def parse_graph(): def parse_graph():
graph = defaultdict(list) graph = defaultdict(list)
@ -38,7 +43,14 @@ def parse_graph():
if not m: if not m:
continue continue
target, dep = m.group(1), m.group(2) target, dep = m.group(1), m.group(2)
if not target.endswith('__compile'): # Dependencies included in provided_deps set are contained in audit
# classpath and must be sorted out. That's safe thing to do because
# they are not included in the final artifact.
if "DO_NOT_DISTRIBUTE" in dep:
if not target in KNOWN_PROVIDED_DEPS:
print('DO_NOT_DISTRIBUTE license for tagret: %s' % target, file=stderr)
exit(1)
else:
graph[target].append(dep) graph[target].append(dep)
r = p.wait() r = p.wait()
if r != 0: if r != 0:

View File

@ -31,10 +31,10 @@ java_library(
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )
java_library2( java_library(
name = 'api', name = 'api',
srcs = glob([SRC + '**/*.java']), srcs = glob([SRC + '**/*.java']),
compile_deps = ['//lib/guice:guice'], provided_deps = ['//lib/guice:guice'],
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )

View File

@ -43,10 +43,10 @@ gwt_module(
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )
java_library2( java_library(
name = 'linker_server', name = 'linker_server',
srcs = glob([SRC + 'linker/server/*.java']), srcs = glob([SRC + 'linker/server/*.java']),
compile_deps = ['//lib:servlet-api-3_1'], provided_deps = ['//lib:servlet-api-3_1'],
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )
@ -90,9 +90,9 @@ gwt_module(
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )
java_library2( java_library(
name = 'server', name = 'server',
srcs = glob([SRC + 'server/*.java']), srcs = glob([SRC + 'server/*.java']),
compile_deps = ['//lib:servlet-api-3_1'], provided_deps = ['//lib:servlet-api-3_1'],
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )

View File

@ -14,11 +14,11 @@ java_library(
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )
java_library2( java_library(
name = 'client-lib2', name = 'client-lib2',
srcs = glob(['src/main/**/*.java']), srcs = glob(['src/main/**/*.java']),
resources = glob(['src/main/**/*']), resources = glob(['src/main/**/*']),
compile_deps = ['//lib/gwt:user'], provided_deps = ['//lib/gwt:user'],
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )

View File

@ -3,7 +3,7 @@ SRCS = glob(
) )
RESOURCES = glob(['src/main/resources/**/*']) RESOURCES = glob(['src/main/resources/**/*'])
java_library2( java_library(
name = 'httpd', name = 'httpd',
srcs = SRCS, srcs = SRCS,
resources = RESOURCES, resources = RESOURCES,
@ -34,7 +34,7 @@ java_library2(
'//lib/log:api', '//lib/log:api',
'//lib/lucene:core', '//lib/lucene:core',
], ],
compile_deps = ['//lib:servlet-api-3_1'], provided_deps = ['//lib:servlet-api-3_1'],
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )

View File

@ -1,4 +1,4 @@
java_library2( java_library(
name = 'openid', name = 'openid',
srcs = glob(['src/main/java/**/*.java']), srcs = glob(['src/main/java/**/*.java']),
resources = glob(['src/main/resources/**/*']), resources = glob(['src/main/resources/**/*']),
@ -18,6 +18,6 @@ java_library2(
'//lib/log:api', '//lib/log:api',
'//lib/openid:consumer', '//lib/openid:consumer',
], ],
compile_deps = ['//lib:servlet-api-3_1'], provided_deps = ['//lib:servlet-api-3_1'],
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )

View File

@ -50,7 +50,7 @@ INIT_BASE_SRCS = [SRCS + 'BaseInit.java'] + glob(
INIT_BASE_RSRCS = ['src/main/resources/com/google/gerrit/pgm/libraries.config'] INIT_BASE_RSRCS = ['src/main/resources/com/google/gerrit/pgm/libraries.config']
java_library2( java_library(
name = 'init-base', name = 'init-base',
srcs = INIT_BASE_SRCS, srcs = INIT_BASE_SRCS,
resources = INIT_BASE_RSRCS, resources = INIT_BASE_RSRCS,
@ -73,14 +73,14 @@ java_library2(
'//lib:gwtorm', '//lib:gwtorm',
'//lib/log:api', '//lib/log:api',
], ],
compile_deps = ['//gerrit-launcher:launcher'], provided_deps = ['//gerrit-launcher:launcher'],
visibility = [ visibility = [
'//gerrit-war:', '//gerrit-war:',
'//gerrit-acceptance-tests/...', '//gerrit-acceptance-tests/...',
], ],
) )
java_library2( java_library(
name = 'pgm', name = 'pgm',
srcs = glob( srcs = glob(
['src/main/java/**/*.java'], ['src/main/java/**/*.java'],
@ -122,7 +122,7 @@ java_library2(
'//lib/lucene:core', '//lib/lucene:core',
'//lib/prolog:prolog-cafe', '//lib/prolog:prolog-cafe',
], ],
compile_deps = ['//gerrit-launcher:launcher'], provided_deps = ['//gerrit-launcher:launcher'],
visibility = [ visibility = [
'//:', '//:',
'//gerrit-acceptance-tests/...', '//gerrit-acceptance-tests/...',

View File

@ -22,12 +22,12 @@ java_library(
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )
java_library2( java_library(
name = 'gwtui-api-lib2', name = 'gwtui-api-lib2',
srcs = SRCS, srcs = SRCS,
resources = glob(['src/main/**/*']), resources = glob(['src/main/**/*']),
deps = ['//gerrit-gwtui-common:client-lib2'], deps = ['//gerrit-gwtui-common:client-lib2'],
compile_deps = DEPS, provided_deps = DEPS,
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )

View File

@ -8,14 +8,14 @@ SRCS = glob(
) )
RESOURCES = glob(['src/main/resources/**/*']) RESOURCES = glob(['src/main/resources/**/*'])
java_library2( java_library(
name = 'constants', name = 'constants',
srcs = CONSTANTS_SRC, srcs = CONSTANTS_SRC,
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )
# TODO(sop) break up gerrit-server java_library(), its too big # TODO(sop) break up gerrit-server java_library(), its too big
java_library2( java_library(
name = 'server', name = 'server',
srcs = SRCS, srcs = SRCS,
resources = RESOURCES, resources = RESOURCES,
@ -67,7 +67,7 @@ java_library2(
'//lib/lucene:core', '//lib/lucene:core',
'//lib/lucene:query-parser', '//lib/lucene:query-parser',
], ],
compile_deps = [ provided_deps = [
'//lib/bouncycastle:bcprov', '//lib/bouncycastle:bcprov',
'//lib/bouncycastle:bcpg', '//lib/bouncycastle:bcpg',
'//lib/bouncycastle:bcpkix', '//lib/bouncycastle:bcpkix',

View File

@ -1,6 +1,6 @@
SRCS = glob(['src/main/java/**/*.java']) SRCS = glob(['src/main/java/**/*.java'])
java_library2( java_library(
name = 'sshd', name = 'sshd',
srcs = SRCS, srcs = SRCS,
deps = [ deps = [
@ -27,7 +27,7 @@ java_library2(
'//lib/mina:sshd', '//lib/mina:sshd',
'//lib/jgit:jgit', '//lib/jgit:jgit',
], ],
compile_deps = [ provided_deps = [
'//lib/bouncycastle:bcprov', '//lib/bouncycastle:bcprov',
], ],
visibility = ['PUBLIC'], visibility = ['PUBLIC'],

View File

@ -1,6 +1,6 @@
include_defs('//tools/git.defs') include_defs('//tools/git.defs')
java_library2( java_library(
name = 'init', name = 'init',
srcs = glob(['src/main/java/**/*.java']), srcs = glob(['src/main/java/**/*.java']),
deps = [ deps = [
@ -23,7 +23,7 @@ java_library2(
'//lib/log:api', '//lib/log:api',
'//lib/jgit:jgit', '//lib/jgit:jgit',
], ],
compile_deps = ['//lib:servlet-api-3_1'], provided_deps = ['//lib:servlet-api-3_1'],
visibility = [ visibility = [
'//:', '//:',
'//gerrit-gwtdebug:gwtdebug', '//gerrit-gwtdebug:gwtdebug',

View File

@ -33,7 +33,7 @@ def scan_plugins():
deps = [] deps = []
for n in os.listdir('plugins'): for n in os.listdir('plugins'):
if os.path.exists(os.path.join('plugins', n, 'BUCK')): if os.path.exists(os.path.join('plugins', n, 'BUCK')):
deps.append('//plugins/%s:%s__plugin__compile' % (n, n)) deps.append('//plugins/%s:%s__plugin' % (n, n))
return deps return deps
def war( def war(

View File

@ -74,47 +74,10 @@ def gwt_application(
visibility = visibility, visibility = visibility,
) )
# Compiles a Java library with additional compile-time dependencies
# that do not show up as transitive dependencies to java_library()
# or java_binary() rule that depends on this library.
def java_library2(
name,
srcs = [],
resources = [],
deps = [],
compile_deps = [],
visibility = []):
c = name + '__compile'
t = name + '__link'
j = 'lib__%s__output/%s.jar' % (c, c)
o = 'lib__%s__output/%s.jar' % (name, name)
java_library(
name = c,
srcs = srcs,
resources = resources,
deps = deps + compile_deps,
visibility = ['//tools/eclipse:classpath'],
)
# Break the dependency chain by passing the newly built
# JAR to consumers through a prebuilt_jar().
genrule(
name = t,
cmd = 'mkdir -p $(dirname $OUT);ln -s $SRCS $OUT',
srcs = [genfile(j)],
deps = [':' + c],
out = o,
)
prebuilt_jar(
name = name,
binary_jar = genfile(o),
deps = deps + [':' + t],
visibility = visibility,
)
def gerrit_extension( def gerrit_extension(
name, name,
deps = [], deps = [],
compile_deps = [], provided_deps = [],
srcs = [], srcs = [],
resources = [], resources = [],
manifest_file = None, manifest_file = None,
@ -123,7 +86,7 @@ def gerrit_extension(
gerrit_plugin( gerrit_plugin(
name = name, name = name,
deps = deps, deps = deps,
compile_deps = compile_deps, provided_deps = provided_deps,
srcs = srcs, srcs = srcs,
resources = resources, resources = resources,
manifest_file = manifest_file, manifest_file = manifest_file,
@ -135,7 +98,7 @@ def gerrit_extension(
def gerrit_plugin( def gerrit_plugin(
name, name,
deps = [], deps = [],
compile_deps = [], provided_deps = [],
srcs = [], srcs = [],
resources = [], resources = [],
gwt_module = None, gwt_module = None,
@ -167,12 +130,13 @@ def gerrit_plugin(
if gwt_module: if gwt_module:
gwt_deps = GWT_PLUGIN_DEPS gwt_deps = GWT_PLUGIN_DEPS
static_jars = [':%s-static-jar' % name] static_jars = [':%s-static-jar' % name]
java_library2( java_library(
name = name + '__plugin', name = name + '__plugin',
srcs = srcs, srcs = srcs,
resources = resources, resources = resources,
deps = deps, deps = deps,
compile_deps = ['//gerrit-%s-api:lib' % type] + compile_deps + gwt_deps, provided_deps = ['//gerrit-%s-api:lib' % type] + provided_deps + gwt_deps,
visibility = ['//tools/eclipse:classpath'],
) )
if gwt_module: if gwt_module:
prebuilt_jar( prebuilt_jar(

View File

@ -10,11 +10,14 @@ java_library(
'//gerrit-httpd:httpd_tests', '//gerrit-httpd:httpd_tests',
'//gerrit-main:main_lib', '//gerrit-main:main_lib',
'//gerrit-patch-jgit:jgit_patch_tests', '//gerrit-patch-jgit:jgit_patch_tests',
'//gerrit-plugin-gwtui:gwtui-api', '//gerrit-plugin-gwtui:gwtui-api-lib',
'//gerrit-server:server__compile', '//gerrit-server:server',
'//gerrit-server:server_tests', '//gerrit-server:server_tests',
'//lib/asciidoctor:asciidoc_lib', '//lib/asciidoctor:asciidoc_lib',
'//lib/asciidoctor:doc_indexer_lib', '//lib/asciidoctor:doc_indexer_lib',
'//lib/bouncycastle:bcprov',
'//lib/bouncycastle:bcpg',
'//lib/bouncycastle:bcpkix',
'//lib/jetty:webapp', '//lib/jetty:webapp',
'//lib/prolog:compiler_lib', '//lib/prolog:compiler_lib',
'//Documentation:index_lib', '//Documentation:index_lib',