From 05cb0533780fd181e2cd5e4fdf9c61f586f30935 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Sat, 30 Nov 2013 02:22:26 -0800 Subject: [PATCH] Save GWT compile time by avoiding javac GWT only needs the rebind code for CSS and ServerLinker to be precompiled as bytecode. Save build time by passing no source files to the java_library() used by gwt_module(). For a full draft build of ui_safari this cuts the refresh time down from 32.015s to 26.158s on my MacBook. Saving 6s on each UI reload adds up during development. The common annotations need to be provided as bytecode, avoiding spurious warnings from GWT when there is a Java syntax error. Change-Id: I37826498650c65c05303e7d4d1177d05781c56f6 --- gerrit-acceptance-tests/BUCK | 1 + gerrit-common/BUCK | 18 ++++++++++++++- .../gerrit/common/auth/SignInRequired.java | 7 +++--- gerrit-gwtexpui/BUCK | 22 ++++++++++--------- gerrit-gwtui/BUCK | 16 ++++++++------ gerrit-httpd/BUCK | 1 + gerrit-lucene/BUCK | 1 + gerrit-openid/BUCK | 1 + gerrit-patch-jgit/BUCK | 2 +- gerrit-pgm/BUCK | 1 + gerrit-plugin-api/BUCK | 1 + gerrit-prettify/BUCK | 4 +++- gerrit-reviewdb/BUCK | 2 +- gerrit-server/BUCK | 2 ++ gerrit-sshd/BUCK | 1 + gerrit-util-cli/BUCK | 1 + tools/default.defs | 11 +++++++--- 17 files changed, 64 insertions(+), 28 deletions(-) diff --git a/gerrit-acceptance-tests/BUCK b/gerrit-acceptance-tests/BUCK index 60c43318aa..a3a24c7a24 100644 --- a/gerrit-acceptance-tests/BUCK +++ b/gerrit-acceptance-tests/BUCK @@ -4,6 +4,7 @@ java_library( name = 'lib', srcs = glob(['src/test/java/com/google/gerrit/acceptance/*.java']), exported_deps = [ + '//gerrit-common:annotations', '//gerrit-common:server', '//gerrit-extension-api:api', '//gerrit-launcher:launcher', diff --git a/gerrit-common/BUCK b/gerrit-common/BUCK index 94b0a01677..9ed16240e3 100644 --- a/gerrit-common/BUCK +++ b/gerrit-common/BUCK @@ -1,5 +1,17 @@ SRC = 'src/main/java/com/google/gerrit/' +ANNOTATIONS = [ + SRC + 'common/Nullable.java', + SRC + 'common/audit/Audit.java', + SRC + 'common/auth/SignInRequired.java', +] + +java_library( + name = 'annotations', + srcs = ANNOTATIONS, + visibility = ['PUBLIC'], +) + gwt_module( name = 'client', srcs = glob([SRC + 'common/**/*.java']), @@ -8,6 +20,9 @@ gwt_module( '//gerrit-patch-jgit:client', '//gerrit-prettify:client', '//gerrit-reviewdb:client', + ], + compile_deps = [ + ':annotations', '//lib:gwtjsonrpc', '//lib:gwtorm', '//lib/jgit:jgit', @@ -17,8 +32,9 @@ gwt_module( java_library( name = 'server', - srcs = glob([SRC + 'common/**/*.java']), + srcs = glob([SRC + 'common/**/*.java'], excludes = ANNOTATIONS), deps = [ + ':annotations', '//gerrit-patch-jgit:server', '//gerrit-prettify:server', '//gerrit-reviewdb:server', diff --git a/gerrit-common/src/main/java/com/google/gerrit/common/auth/SignInRequired.java b/gerrit-common/src/main/java/com/google/gerrit/common/auth/SignInRequired.java index cd9fa25e92..1b9011a78a 100644 --- a/gerrit-common/src/main/java/com/google/gerrit/common/auth/SignInRequired.java +++ b/gerrit-common/src/main/java/com/google/gerrit/common/auth/SignInRequired.java @@ -14,8 +14,6 @@ package com.google.gerrit.common.auth; -import com.google.gerrit.common.errors.NotSignedInException; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -24,8 +22,9 @@ import java.lang.annotation.Target; /** * Annotation indicating a service method requires a current user. *

- * If there is no current user then {@link NotSignedInException} will be given - * to the callback's onFailure method. + * If there is no current user then + * {@code com.google.gerrit.common.errors.NotSignedInException} will be given to + * the callback's onFailure method. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) diff --git a/gerrit-gwtexpui/BUCK b/gerrit-gwtexpui/BUCK index 105ee7df2e..2936050a89 100644 --- a/gerrit-gwtexpui/BUCK +++ b/gerrit-gwtexpui/BUCK @@ -11,16 +11,18 @@ gwt_module( deps = [ ':SafeHtml', ':UserAgent', + ], + compile_deps = [ '//lib/gwt:user', '//lib:LICENSE-clippy', ], visibility = ['PUBLIC'], ) -gwt_module( +java_library( name = 'CSS', srcs = glob([SRC + 'css/rebind/*.java']), - gwtxml = SRC + 'css/CSS.gwt.xml', + resources = [SRC + 'css/CSS.gwt.xml'], deps = ['//lib/gwt:dev'], visibility = ['PUBLIC'], ) @@ -36,15 +38,15 @@ gwt_module( deps = [ ':SafeHtml', ':UserAgent', - '//lib/gwt:user', ], + compile_deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) -gwt_module( +java_library( name = 'Linker', srcs = glob([SRC + 'linker/rebind/*.java']), - gwtxml = SRC + 'linker/ServerPlannedIFrameLinker.gwt.xml', + resources = [SRC + 'linker/ServerPlannedIFrameLinker.gwt.xml'], deps = ['//lib/gwt:dev'], visibility = ['PUBLIC'], ) @@ -61,7 +63,7 @@ gwt_module( srcs = glob([SRC + 'progress/client/*.java']), gwtxml = SRC + 'progress/Progress.gwt.xml', resources = [SRC + 'progress/client/progress.css'], - deps = ['//lib/gwt:user'], + compile_deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) @@ -70,7 +72,7 @@ gwt_module( srcs = glob([SRC + 'safehtml/client/*.java']), gwtxml = SRC + 'safehtml/SafeHtml.gwt.xml', resources = [SRC + 'safehtml/client/safehtml.css'], - deps = ['//lib/gwt:user'], + compile_deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) @@ -80,19 +82,19 @@ java_test( 'src/test/java/com/google/gwtexpui/safehtml/client/**/*.java', ]), deps = [ - ':SafeHtml', + ':SafeHtml_lib', '//lib:junit', '//lib/gwt:user', '//lib/gwt:dev', ], - source_under_test = [':SafeHtml'], + source_under_test = [':SafeHtml_lib'], ) gwt_module( name = 'UserAgent', srcs = glob([SRC + 'user/client/*.java']), gwtxml = SRC + 'user/User.gwt.xml', - deps = ['//lib/gwt:user'], + compile_deps = ['//lib/gwt:user'], visibility = ['PUBLIC'], ) diff --git a/gerrit-gwtui/BUCK b/gerrit-gwtui/BUCK index 0c873eeb0d..b99bcfad8f 100644 --- a/gerrit-gwtui/BUCK +++ b/gerrit-gwtui/BUCK @@ -56,11 +56,8 @@ gwt_module( gwtxml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'), resources = glob(['src/main/java/**/*'], excludes = DIFFY), deps = [ - ':diffy_logo', '//gerrit-gwtexpui:Clippy', - '//gerrit-gwtexpui:CSS', '//gerrit-gwtexpui:GlobalKey', - '//gerrit-gwtexpui:Linker', '//gerrit-gwtexpui:Progress', '//gerrit-gwtexpui:SafeHtml', '//gerrit-gwtexpui:UserAgent', @@ -69,6 +66,11 @@ gwt_module( '//gerrit-patch-jgit:client', '//gerrit-prettify:client', '//gerrit-reviewdb:client', + ], + compile_deps = [ + ':diffy_logo', + '//gerrit-gwtexpui:CSS', + '//gerrit-gwtexpui:Linker', '//lib:gwtjsonrpc', '//lib:gwtjsonrpc_src', '//lib:gwtorm', @@ -111,16 +113,16 @@ java_test( 'src/main/java/com/google/gerrit/GerritGwtUI.gwt.xml', ], deps = [ - ':ui_module', - '//gerrit-common:client', - '//gerrit-extension-api:client', + ':ui_module_lib', + '//gerrit-common:client_lib', + '//gerrit-extension-api:client_lib', '//lib:junit', '//lib/gwt:dev', '//lib/gwt:user', '//lib/gwt:gwt-test-utils', '//lib/jgit:jgit', ], - source_under_test = [':ui_module'], + source_under_test = [':ui_module_lib'], vm_args = ['-Xmx512m'], visibility = ['//tools/eclipse:classpath'], ) diff --git a/gerrit-httpd/BUCK b/gerrit-httpd/BUCK index c20b589be5..513a29d96d 100644 --- a/gerrit-httpd/BUCK +++ b/gerrit-httpd/BUCK @@ -9,6 +9,7 @@ java_library2( resources = RESOURCES, deps = [ '//gerrit-antlr:query_exception', + '//gerrit-common:annotations', '//gerrit-common:server', '//gerrit-extension-api:api', '//gerrit-gwtexpui:linker_server', diff --git a/gerrit-lucene/BUCK b/gerrit-lucene/BUCK index 5a907ebd6d..2b45d2bca9 100644 --- a/gerrit-lucene/BUCK +++ b/gerrit-lucene/BUCK @@ -22,6 +22,7 @@ java_library( deps = [ ':query_builder', '//gerrit-antlr:query_exception', + '//gerrit-common:annotations', '//gerrit-common:server', '//gerrit-extension-api:api', '//gerrit-reviewdb:server', diff --git a/gerrit-openid/BUCK b/gerrit-openid/BUCK index 8da83c3f25..53604de088 100644 --- a/gerrit-openid/BUCK +++ b/gerrit-openid/BUCK @@ -3,6 +3,7 @@ java_library2( srcs = glob(['src/main/java/**/*.java']), resources = glob(['src/main/resources/**/*']), deps = [ + '//gerrit-common:annotations', '//gerrit-common:server', '//gerrit-extension-api:api', '//gerrit-gwtexpui:server', diff --git a/gerrit-patch-jgit/BUCK b/gerrit-patch-jgit/BUCK index 1e0953f6b8..00b82284e7 100644 --- a/gerrit-patch-jgit/BUCK +++ b/gerrit-patch-jgit/BUCK @@ -7,7 +7,7 @@ gwt_module( SRC + 'diff/ReplaceEdit.java', ], gwtxml = SRC + 'JGit.gwt.xml', - deps = [ + compile_deps = [ '//lib:gwtjsonrpc', '//lib/gwt:user', '//lib/jgit:jgit', diff --git a/gerrit-pgm/BUCK b/gerrit-pgm/BUCK index 67b28ac80a..fdca44a28f 100644 --- a/gerrit-pgm/BUCK +++ b/gerrit-pgm/BUCK @@ -14,6 +14,7 @@ java_library( name = 'init-api', srcs = INIT_API_SRCS, deps = [ + '//gerrit-common:annotations', '//gerrit-common:server', '//gerrit-server:server', '//lib/guice:guice', diff --git a/gerrit-plugin-api/BUCK b/gerrit-plugin-api/BUCK index 669354653d..8498e0d39f 100644 --- a/gerrit-plugin-api/BUCK +++ b/gerrit-plugin-api/BUCK @@ -20,6 +20,7 @@ java_binary( java_library( name = 'lib', exported_deps = PLUGIN_API + [ + '//gerrit-common:annotations', '//gerrit-common:server', '//gerrit-extension-api:api', '//gerrit-reviewdb:server', diff --git a/gerrit-prettify/BUCK b/gerrit-prettify/BUCK index 79dc76010a..e753ad941a 100644 --- a/gerrit-prettify/BUCK +++ b/gerrit-prettify/BUCK @@ -11,10 +11,12 @@ gwt_module( 'src/main/java/com/google/gerrit/prettify/client/*.properties', ]), deps = [ - ':google-code-prettify', '//gerrit-patch-jgit:client', '//gerrit-reviewdb:client', '//gerrit-gwtexpui:SafeHtml', + ], + compile_deps = [ + ':google-code-prettify', '//lib:guava', '//lib:gwtjsonrpc', '//lib/gwt:user', diff --git a/gerrit-reviewdb/BUCK b/gerrit-reviewdb/BUCK index 05674cf1aa..b133f1aaa6 100644 --- a/gerrit-reviewdb/BUCK +++ b/gerrit-reviewdb/BUCK @@ -4,7 +4,7 @@ gwt_module( name = 'client', srcs = glob([SRC + 'client/**/*.java']), gwtxml = SRC + 'ReviewDB.gwt.xml', - deps = [ + compile_deps = [ '//lib:gwtorm', '//lib:gwtorm_src' ], diff --git a/gerrit-server/BUCK b/gerrit-server/BUCK index c049cca8c6..ad22d28fe8 100644 --- a/gerrit-server/BUCK +++ b/gerrit-server/BUCK @@ -25,6 +25,7 @@ java_library2( ':constants', '//gerrit-antlr:query_exception', '//gerrit-antlr:query_parser', + '//gerrit-common:annotations', '//gerrit-common:server', '//gerrit-extension-api:api', '//gerrit-patch-commonsnet:commons-net', @@ -148,6 +149,7 @@ java_test( ':testutil', '//gerrit-antlr:query_exception', '//gerrit-antlr:query_parser', + '//gerrit-common:annotations', '//gerrit-common:server', '//gerrit-extension-api:api', '//gerrit-reviewdb:server', diff --git a/gerrit-sshd/BUCK b/gerrit-sshd/BUCK index 93a3ef74e9..679072b2b1 100644 --- a/gerrit-sshd/BUCK +++ b/gerrit-sshd/BUCK @@ -6,6 +6,7 @@ java_library2( deps = [ '//gerrit-extension-api:api', '//gerrit-cache-h2:cache-h2', + '//gerrit-common:annotations', '//gerrit-common:server', '//gerrit-patch-jgit:server', '//gerrit-reviewdb:server', diff --git a/gerrit-util-cli/BUCK b/gerrit-util-cli/BUCK index 7e43cc4007..8cdc2dcf57 100644 --- a/gerrit-util-cli/BUCK +++ b/gerrit-util-cli/BUCK @@ -2,6 +2,7 @@ java_library( name = 'cli', srcs = glob(['src/main/java/**/*.java']), deps = [ + '//gerrit-common:annotations', '//gerrit-common:server', '//lib:args4j', '//lib:guava', diff --git a/tools/default.defs b/tools/default.defs index 4d87b5b69e..ff52cb4476 100644 --- a/tools/default.defs +++ b/tools/default.defs @@ -38,15 +38,20 @@ def gwt_module( gwtxml = None, resources = [], deps = [], + compile_deps = [], visibility = []): if gwtxml: resources = resources + [gwtxml] - resources = resources + srcs java_library( name = name, + deps = deps + compile_deps, + resources = srcs + resources, + visibility = visibility, + ) + java_library( + name = name + '_lib', srcs = srcs, - deps = deps, - resources = resources, + deps = [':' + name] + [d + '_lib' for d in deps] + compile_deps, visibility = visibility, )