Buck: Create javadoc from source archive

javadoc accepts source archive and we need to create one anyway. So
instead of trying to use the sources in the tree and guess the root
project directory, just use the source archive. We extact the archive
in temporary directory to make javadoc work.

Change-Id: Ib605f6cdab4742a23789da8fbc9c963c83e5b6d9
This commit is contained in:
David Ostrovsky
2016-08-27 10:28:20 +02:00
parent bf9634f1df
commit c13d8feb30
5 changed files with 12 additions and 21 deletions

View File

@@ -77,7 +77,7 @@ java_doc(
name = 'acceptance-framework-javadoc',
title = 'Gerrit Acceptance Test Framework Documentation',
pkgs = [' com.google.gerrit.acceptance'],
paths = ['src/test/java'],
source_jar = ':acceptance-framework-src',
srcs = SRCS,
deps = DEPS + PROVIDED + [
'//lib:guava',

View File

@@ -71,7 +71,7 @@ java_doc(
name = 'extension-api-javadoc',
title = 'Gerrit Review Extension API Documentation',
pkgs = ['com.google.gerrit.extensions'],
paths = ['src/main/java'],
source_jar = ':extension-api-src',
srcs = SRCS,
deps = [
'//lib:guava',

View File

@@ -83,7 +83,7 @@ java_doc(
name = 'plugin-api-javadoc',
title = 'Gerrit Review Plugin API Documentation',
pkgs = ['com.google.gerrit'],
paths = [n for n in SRCS],
source_jar = ':plugin-api-src',
srcs = glob([n + '**/*.java' for n in SRCS]),
deps = [
':plugin-api',
@@ -92,5 +92,4 @@ java_doc(
'//lib/bouncycastle:bcpkix',
],
visibility = ['PUBLIC'],
do_it_wrong = True,
)

View File

@@ -1,8 +1,4 @@
COMMON = ['gerrit-gwtui-common/src/main/java/']
GWTEXPUI = ['gerrit-gwtexpui/src/main/java/']
SRC = 'src/main/java/com/google/gerrit/'
SRCS = glob([SRC + '**/*.java'])
SRCS = glob(['src/main/java/com/google/gerrit/**/*.java'])
DEPS = ['//lib/gwt:user']
java_binary(
@@ -50,7 +46,7 @@ java_doc(
'com.google.gwtexpui.safehtml',
'com.google.gwtexpui.user',
],
paths = COMMON + GWTEXPUI,
source_jar = ':gwtui-api-src',
srcs = SRCS,
deps = DEPS + [
'//lib:gwtjsonrpc',
@@ -61,5 +57,4 @@ java_doc(
'//gerrit-reviewdb:client',
],
visibility = ['PUBLIC'],
do_it_wrong = True,
)

View File

@@ -2,20 +2,18 @@ def java_doc(
name,
title,
pkgs,
paths,
source_jar,
srcs = [],
deps = [],
visibility = [],
do_it_wrong = False,
):
if do_it_wrong:
sourcepath = paths
else:
sourcepath = ['$SRCDIR/' + n for n in paths]
# TODO(davido): Actually we shouldn't need to extract the source
# archive, javadoc should just work with provided archive.
genrule(
name = name,
cmd = ' '.join([
'while ! test -f .buckconfig; do cd ..; done;',
'mkdir $TMP/sourcepath &&',
'unzip $(location %s) -d $TMP/sourcepath &&' % source_jar,
'javadoc',
'-quiet',
'-protected',
@@ -26,8 +24,7 @@ def java_doc(
'-link http://docs.oracle.com/javase/7/docs/api',
'-subpackages ',
':'.join(pkgs),
'-sourcepath ',
':'.join(sourcepath),
'-sourcepath $TMP/sourcepath',
' -classpath ',
':'.join(['$(classpath %s)' % n for n in deps]),
'-d $TMP',
@@ -35,4 +32,4 @@ def java_doc(
srcs = srcs,
out = name + '.jar',
visibility = visibility,
)
)