From c53827816dd11883c4e238934f67a88e625b203d Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Tue, 12 Nov 2013 09:41:18 +0100 Subject: [PATCH] Buck: Add support for gerrit GWT plugins This changes extends gerrit_plugin function with additional gwt_module parameters. When passed, GWT application is created. Assumtion is met, that this application depends on gerrit-plugin-gwtui module. With this change Gerrit GWT plugins can be build with Buck: MODULE = 'com.googlesource.gerrit.plugins.cookbook.HelloForm' gerrit_plugin( name = 'cookbook-plugin', srcs = glob(['src/main/java/**/*.java']), resources = glob(['src/main/**/*']), gwt_module = MODULE, manifest_entries = [ 'Gerrit-PluginName: cookbook', 'Gerrit-Module: com.googlesource.gerrit.plugins.cookbook.Module', 'Gerrit-HttpModule: com.googlesource.gerrit.plugins.cookbook.HttpModule', 'Gerrit-SshModule: com.googlesource.gerrit.plugins.cookbook.SshModule', ] ) Change-Id: I4b131c7c2672675d99457651fcee63bf4f149c2f --- gerrit-gwtui/BUCK | 10 ++-------- tools/default.defs | 34 ++++++++++++++++++++++++++++++++-- tools/gwt-constants.defs | 13 +++++++++++++ 3 files changed, 47 insertions(+), 10 deletions(-) create mode 100644 tools/gwt-constants.defs diff --git a/gerrit-gwtui/BUCK b/gerrit-gwtui/BUCK index ef67d3488a..0c873eeb0d 100644 --- a/gerrit-gwtui/BUCK +++ b/gerrit-gwtui/BUCK @@ -1,4 +1,5 @@ include_defs('//gerrit-gwtui/gwt.defs') +include_defs('//tools/gwt-constants.defs') genrule( name = 'ui_optdbg', @@ -25,14 +26,7 @@ genrule( gwt_application( name = 'ui_opt', module_target = MODULE, - compiler_opts = [ - '-strict', - '-style', 'OBF', - '-optimize', '9', - '-XdisableClassMetadata', - '-XdisableCastChecking', - '-XenableClosureCompiler', - ], + compiler_opts = GWT_COMPILER_OPTS, deps = APP_DEPS, ) diff --git a/tools/default.defs b/tools/default.defs index 4ed5635e38..b7ef6b427c 100644 --- a/tools/default.defs +++ b/tools/default.defs @@ -14,6 +14,8 @@ # Rule definitions loaded by default into every BUCK file. +include_defs('//tools/gwt-constants.defs') + def genantlr( name, srcs, @@ -128,6 +130,7 @@ def gerrit_plugin( deps = [], srcs = [], resources = [], + gwt_module = None, manifest_file = None, manifest_entries = [], type = 'plugin', @@ -149,20 +152,47 @@ def gerrit_plugin( srcs = mf_src, out = 'MANIFEST.MF', ) + gwt_deps = [] + static_jars = [] + if gwt_module: + gwt_deps = GWT_PLUGIN_DEPS + static_jars = [':%s-static-jar' % name] java_library2( name = name + '__plugin', srcs = srcs, resources = resources, deps = deps, - compile_deps = ['//:%s-lib' % type], + compile_deps = ['//:%s-lib' % type] + gwt_deps, ) + if gwt_module: + prebuilt_jar( + name = '%s-static-jar' % name, + binary_jar = genfile('%s-static.zip' % name), + deps = [':%s-static' % name], + ) + genrule( + name = '%s-static' % name, + cmd = 'mkdir -p $TMP/static' + + ';unzip -qd $TMP/static $(location %s)' % + ':%s__gwt_application' % name + + ';cd $TMP' + + ';zip -qr $OUT .', + out = '%s-static.zip' % name, + deps = [':%s__gwt_application' % name] + ) + gwt_application( + name = name + '__gwt_application', + module_target = gwt_module, + compiler_opts = GWT_COMPILER_OPTS, + deps = [':%s__plugin' % name] + gwt_deps, + ) java_binary( name = name, manifest_file = genfile('MANIFEST.MF'), deps = [ ':%s__plugin' % name, ':%s__manifest' % name, - ], + ] + static_jars, visibility = visibility, ) diff --git a/tools/gwt-constants.defs b/tools/gwt-constants.defs new file mode 100644 index 0000000000..56978e77ef --- /dev/null +++ b/tools/gwt-constants.defs @@ -0,0 +1,13 @@ +GWT_COMPILER_OPTS = [ + '-strict', + '-style', 'OBF', + '-optimize', '9', + '-XdisableClassMetadata', + '-XdisableCastChecking', + '-XenableClosureCompiler', +] + +GWT_PLUGIN_DEPS = [ + '//gerrit-plugin-gwtui:client', + '//lib/gwt:user', +]