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
from shutil import copyfileobj
from subprocess import Popen, PIPE
from sys import stdout
from sys import stdout, stderr
MAIN = ['//gerrit-pgm:pgm', '//gerrit-gwtui:ui_module']
KNOWN_PROVIDED_DEPS = [
'//lib/bouncycastle:bcpg',
'//lib/bouncycastle:bcpkix',
'//lib/bouncycastle:bcprov',
]
def parse_graph():
graph = defaultdict(list)
@ -38,7 +43,14 @@ def parse_graph():
if not m:
continue
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)
r = p.wait()
if r != 0:

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
java_library2(
java_library(
name = 'openid',
srcs = glob(['src/main/java/**/*.java']),
resources = glob(['src/main/resources/**/*']),
@ -18,6 +18,6 @@ java_library2(
'//lib/log:api',
'//lib/openid:consumer',
],
compile_deps = ['//lib:servlet-api-3_1'],
provided_deps = ['//lib:servlet-api-3_1'],
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']
java_library2(
java_library(
name = 'init-base',
srcs = INIT_BASE_SRCS,
resources = INIT_BASE_RSRCS,
@ -73,14 +73,14 @@ java_library2(
'//lib:gwtorm',
'//lib/log:api',
],
compile_deps = ['//gerrit-launcher:launcher'],
provided_deps = ['//gerrit-launcher:launcher'],
visibility = [
'//gerrit-war:',
'//gerrit-acceptance-tests/...',
],
)
java_library2(
java_library(
name = 'pgm',
srcs = glob(
['src/main/java/**/*.java'],
@ -122,7 +122,7 @@ java_library2(
'//lib/lucene:core',
'//lib/prolog:prolog-cafe',
],
compile_deps = ['//gerrit-launcher:launcher'],
provided_deps = ['//gerrit-launcher:launcher'],
visibility = [
'//:',
'//gerrit-acceptance-tests/...',

View File

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

View File

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

View File

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

View File

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

View File

@ -33,7 +33,7 @@ def scan_plugins():
deps = []
for n in os.listdir('plugins'):
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
def war(

View File

@ -74,47 +74,10 @@ def gwt_application(
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(
name,
deps = [],
compile_deps = [],
provided_deps = [],
srcs = [],
resources = [],
manifest_file = None,
@ -123,7 +86,7 @@ def gerrit_extension(
gerrit_plugin(
name = name,
deps = deps,
compile_deps = compile_deps,
provided_deps = provided_deps,
srcs = srcs,
resources = resources,
manifest_file = manifest_file,
@ -135,7 +98,7 @@ def gerrit_extension(
def gerrit_plugin(
name,
deps = [],
compile_deps = [],
provided_deps = [],
srcs = [],
resources = [],
gwt_module = None,
@ -167,12 +130,13 @@ def gerrit_plugin(
if gwt_module:
gwt_deps = GWT_PLUGIN_DEPS
static_jars = [':%s-static-jar' % name]
java_library2(
java_library(
name = name + '__plugin',
srcs = srcs,
resources = resources,
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:
prebuilt_jar(

View File

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