From c13d8feb300edad23122ec7f9971e7f1e329228a Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sat, 27 Aug 2016 10:28:20 +0200 Subject: [PATCH] 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 --- gerrit-acceptance-framework/BUCK | 2 +- gerrit-extension-api/BUCK | 2 +- gerrit-plugin-api/BUCK | 3 +-- gerrit-plugin-gwtui/BUCK | 9 ++------- tools/java_doc.defs | 17 +++++++---------- 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/gerrit-acceptance-framework/BUCK b/gerrit-acceptance-framework/BUCK index f96001096d..4bce902993 100644 --- a/gerrit-acceptance-framework/BUCK +++ b/gerrit-acceptance-framework/BUCK @@ -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', diff --git a/gerrit-extension-api/BUCK b/gerrit-extension-api/BUCK index dda129079c..7a8b67196d 100644 --- a/gerrit-extension-api/BUCK +++ b/gerrit-extension-api/BUCK @@ -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', diff --git a/gerrit-plugin-api/BUCK b/gerrit-plugin-api/BUCK index 70886d583e..7e3872661e 100644 --- a/gerrit-plugin-api/BUCK +++ b/gerrit-plugin-api/BUCK @@ -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, ) diff --git a/gerrit-plugin-gwtui/BUCK b/gerrit-plugin-gwtui/BUCK index 2ee0e19f26..575ebfcb0d 100644 --- a/gerrit-plugin-gwtui/BUCK +++ b/gerrit-plugin-gwtui/BUCK @@ -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, ) diff --git a/tools/java_doc.defs b/tools/java_doc.defs index 65865bb4c4..b8778bb759 100644 --- a/tools/java_doc.defs +++ b/tools/java_doc.defs @@ -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, -) + )