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
This commit is contained in:
Shawn Pearce 2013-11-30 02:22:26 -08:00
parent ab2319061d
commit 05cb053378
17 changed files with 64 additions and 28 deletions

View File

@ -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',

View File

@ -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',

View File

@ -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.
* <p>
* 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)

View File

@ -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'],
)

View File

@ -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'],
)

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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'
],

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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,
)