Merge changes from topic 'bazel-build'

* changes:
  Bazel: Build gerrit WAR with GWT UI
  Bazel: Build GWT UI
  Implement Bazel build for gerrit-gwtui project
  Implement Bazel build for codemirror library
  Bazel: Produce headless war
  Implement Bazel build for gerrit-war project
  Implement Bazel build for gerrit-main project
  Bazel: add java_doc rule
  Bazel: Create sources for plugin API
This commit is contained in:
David Ostrovsky 2016-09-20 11:57:47 +00:00 committed by Gerrit Code Review
commit 071060903b
18 changed files with 1023 additions and 2 deletions

14
BUILD Normal file
View File

@ -0,0 +1,14 @@
load('//tools/bzl:genrule2.bzl', 'genrule2')
load('//tools/bzl:pkg_war.bzl', 'pkg_war')
genrule2(
name = 'version',
srcs = ['VERSION'],
cmd = "grep GERRIT_VERSION $< | cut -d \"'\" -f 2 >$@",
out = 'version.txt',
visibility = ['//visibility:public'],
)
pkg_war(name = 'gerrit')
pkg_war(name = 'headless', ui = None)

View File

@ -118,6 +118,12 @@ maven_jar(
sha1 = 'cdb2dcb4e22b83d6b32b93095f644c3462739e82',
)
http_jar(
name = "javax_validation_src",
url = "http://repo1.maven.org/maven2/javax/validation/validation-api/1.0.0.GA/validation-api-1.0.0.GA-sources.jar",
sha256 = 'a394d52a9b7fe2bb14f0718d2b3c8308ffe8f37e911956012398d55c9f9f9b54',
)
JGIT_VERS = '4.4.1.201607150455-r.118-g1096652'
maven_jar(
@ -746,3 +752,29 @@ maven_jar(
artifact = 'xerces:xercesImpl:2.8.1',
sha1 = '25101e37ec0c907db6f0612cbf106ee519c1aef1',
)
maven_jar(
name = 'postgresql',
artifact = 'postgresql:postgresql:9.1-901-1.jdbc4',
sha1 = '9bfabe48876ec38f6cbaa6931bad05c64a9ea942',
)
CM_VERSION = '5.18.2'
maven_jar(
name = 'codemirror_minified',
artifact = 'org.webjars.npm:codemirror-minified:' + CM_VERSION,
sha1 = '6755af157a7eaf2401468906bef67bbacc3c97f6',
)
maven_jar(
name = 'codemirror_original',
artifact = 'org.webjars.npm:codemirror:' + CM_VERSION,
sha1 = '18c721ae88eed27cddb458c42f5d221fa3d9713e',
)
maven_jar(
name = 'diff_match_patch',
artifact = 'org.webjars:google-diff-match-patch:20121119-1',
sha1 = '0cf1782dbcb8359d95070da9176059a5a9d37709',
)

View File

@ -59,3 +59,12 @@ java_library2(
],
visibility = ['//visibility:public'],
)
load('//tools/bzl:javadoc.bzl', 'java_doc')
java_doc(
name = 'acceptance-framework-javadoc',
title = 'Gerrit Acceptance Test Framework Documentation',
libs = [':lib'],
pkgs = ['com.google.gerrit.acceptance'],
)

View File

@ -44,3 +44,12 @@ java_library(
],
visibility = ['//visibility:public'],
)
load('//tools/bzl:javadoc.bzl', 'java_doc')
java_doc(
name = 'extension-api-javadoc',
title = 'Gerrit Review Extension API Documentation',
libs = [':api'],
pkgs = ['com.google.gerrit.extensions'],
)

69
gerrit-gwtui-common/BUILD Normal file
View File

@ -0,0 +1,69 @@
load('//tools/bzl:genrule2.bzl', 'genrule2')
load('//tools/bzl:java.bzl', 'java_library2')
load('//tools/bzl:junit.bzl', 'junit_tests')
load('//tools/bzl:gwt.bzl', 'gwt_module')
EXPORTED_DEPS = [
'//gerrit-common:client',
'//gerrit-gwtexpui:Clippy',
'//gerrit-gwtexpui:GlobalKey',
'//gerrit-gwtexpui:Progress',
'//gerrit-gwtexpui:SafeHtml',
'//gerrit-gwtexpui:UserAgent',
]
DEPS = ['//lib/gwt:user']
SRC = 'src/main/java/com/google/gerrit/'
DIFFY = glob(['src/main/resources/com/google/gerrit/client/diffy*.png'])
gwt_module(
name = 'client',
srcs = glob(['src/main/**/*.java']),
gwt_xml = SRC + 'GerritGwtUICommon.gwt.xml',
resources = glob(
['src/main/**/*'],
exclude = [SRC + 'client/**/*.java'] +
[SRC + 'GerritGwtUICommon.gwt.xml']
),
exported_deps = EXPORTED_DEPS,
deps = DEPS,
visibility = ['//visibility:public'],
)
java_library2(
name = 'client-lib',
srcs = glob(['src/main/**/*.java']),
resources = glob(['src/main/**/*']),
exported_deps = EXPORTED_DEPS,
deps = DEPS,
visibility = ['//visibility:public'],
)
java_import(
name = 'diffy_logo',
jars = [':diffy_image_files_ln'],
visibility = ['//visibility:public'],
)
genrule2(
name = 'diffy_image_files_ln',
srcs = [':diffy_image_files'],
cmd = 'ln -s $$ROOT/$(location :diffy_image_files) $@',
out = 'diffy_images.jar',
)
java_library(
name = 'diffy_image_files',
resources = DIFFY,
)
junit_tests(
name = 'client_tests',
srcs = glob(['src/test/java/**/*.java']),
deps = [
':client',
'//lib:junit',
'//lib/gwt:dev',
'//lib/jgit/org.eclipse.jgit:jgit',
],
visibility = ['//visibility:public'],
)

89
gerrit-gwtui/BUILD Normal file
View File

@ -0,0 +1,89 @@
load('//tools/bzl:gwt.bzl', 'gwt_module')
load('//tools/bzl:genrule2.bzl', 'genrule2')
load(':gwt.bzl', 'gwt_binary')
MODULE = 'com.google.gerrit.GerritGwtUI'
GWT_JVM_ARGS = ['-Xmx512m']
GWT_COMPILER_ARGS = [
'-XdisableClassMetadata',
]
GWT_COMPILER_ARGS_RELEASE_MODE = GWT_COMPILER_ARGS + [
'-XdisableCastChecking',
]
GWT_TRANSITIVE_DEPS = [
'//lib/gwt:javax-validation',
'//lib/gwt:javax-validation_src',
'//lib/ow2:ow2-asm',
'//lib/ow2:ow2-asm-analysis',
'//lib/ow2:ow2-asm-commons',
'//lib/ow2:ow2-asm-tree',
'//lib/ow2:ow2-asm-util',
]
DEPS = GWT_TRANSITIVE_DEPS + [
'//gerrit-gwtexpui:CSS',
'//lib:gwtjsonrpc',
'//lib/gwt:dev',
'@jgit_src//file',
]
gwt_module(
name = 'ui_module',
srcs = glob(['src/main/java/**/*.java']),
gwt_xml = 'src/main/java/%s.gwt.xml' % MODULE.replace('.', '/'),
resources = glob(
['src/main/java/**/*'],
exclude = ['src/main/java/**/*.java'] +
['src/main/java/%s.gwt.xml' % MODULE.replace('.', '/')]
),
deps = [
'//gerrit-gwtui-common:diffy_logo',
'//gerrit-gwtui-common:client',
'//gerrit-gwtexpui:CSS',
'//lib/codemirror:codemirror',
'//lib/gwt:user',
],
visibility = ['//visibility:public'],
)
genrule2(
name = 'ui_optdbg',
srcs = [
':ui_dbg',
':ui_opt',
],
cmd = 'cd $$TMP;' +
'unzip -q $$ROOT/$(location :ui_dbg);' +
'mv' +
' gerrit_ui/gerrit_ui.nocache.js' +
' gerrit_ui/dbg_gerrit_ui.nocache.js;' +
'unzip -qo $$ROOT/$(location :ui_opt);' +
'mkdir -p $$(dirname $@);' +
'zip -qr $$ROOT/$@ .',
out = 'ui_optdbg.zip',
visibility = ['//visibility:public'],
)
gwt_binary(
name = 'ui_opt',
modules = [MODULE],
module_deps = [':ui_module'],
deps = DEPS,
compiler_args = GWT_COMPILER_ARGS,
jvm_args = GWT_JVM_ARGS,
)
gwt_binary(
name = 'ui_dbg',
modules = [MODULE],
style = 'PRETTY',
optimize = "0",
module_deps = [':ui_module'],
deps = DEPS,
compiler_args = GWT_COMPILER_ARGS,
jvm_args = GWT_JVM_ARGS,
)

95
gerrit-gwtui/gwt.bzl Normal file
View File

@ -0,0 +1,95 @@
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Port of Buck native gwt_binary() rule. See discussion in context of
# https://github.com/facebook/buck/issues/109
jar_filetype = FileType(['.jar'])
GWT_COMPILER = "com.google.gwt.dev.Compiler"
def _impl(ctx):
output_zip = ctx.outputs.output
output_dir = output_zip.path + '.gwt_output'
deploy_dir = output_zip.path + '.gwt_deploy'
deps = _get_transitive_closure(ctx)
paths = []
for dep in deps:
paths.append(dep.path)
cmd = "external/local_jdk/bin/java %s -Dgwt.normalizeTimestamps=true -cp %s %s -war %s -deploy %s " % (
" ".join(ctx.attr.jvm_args),
":".join(paths),
GWT_COMPILER,
output_dir,
deploy_dir,
)
cmd += " ".join([
"-style %s" % ctx.attr.style,
"-optimize %s" % ctx.attr.optimize,
"-strict",
" ".join(ctx.attr.compiler_args),
" ".join(ctx.attr.modules) + "\n",
"rm -rf %s/gwt-unitCache\n" % output_dir,
"root=`pwd`\n",
"cd %s; $root/%s Cc ../%s $(find .)\n" % (
output_dir,
ctx.executable._zip.path,
output_zip.basename,
)
])
ctx.action(
inputs = list(deps) + ctx.files._jdk + ctx.files._zip,
outputs = [output_zip],
mnemonic = "GwtBinary",
progress_message = "GWT compiling " + output_zip.short_path,
command = "set -e\n" + cmd,
)
def _get_transitive_closure(ctx):
deps = set()
for dep in ctx.attr.module_deps:
deps += dep.java.transitive_runtime_deps
deps += dep.java.transitive_source_jars
for dep in ctx.attr.deps:
if hasattr(dep, 'java'):
deps += dep.java.transitive_runtime_deps
elif hasattr(dep, 'files'):
deps += dep.files
return deps
gwt_binary = rule(
implementation = _impl,
attrs = {
"style": attr.string(default = "OBF"),
"optimize": attr.string(default = "9"),
"deps": attr.label_list(allow_files=jar_filetype),
"modules": attr.string_list(mandatory=True),
"module_deps": attr.label_list(allow_files=jar_filetype),
"compiler_args": attr.string_list(),
"jvm_args": attr.string_list(),
"_jdk": attr.label(
default=Label("//tools/defaults:jdk")),
"_zip": attr.label(
default=Label("@bazel_tools//tools/zip:zipper"),
executable=True,
single_file=True),
},
outputs = {
"output": "%{name}.zip",
},
)

13
gerrit-main/BUILD Normal file
View File

@ -0,0 +1,13 @@
java_binary(
name = 'main_bin',
main_class = 'Main',
runtime_deps = [':main_lib'],
visibility = ['//visibility:public'],
)
java_library(
name = 'main_lib',
srcs = ['src/main/java/Main.java'],
deps = ['//gerrit-launcher:launcher'],
visibility = ['//visibility:public'],
)

View File

@ -58,3 +58,38 @@ java_library(
],
visibility = ['//visibility:public'],
)
java_binary(
name = 'plugin-api-sources',
main_class = 'Dummy',
runtime_deps = [
'//gerrit-antlr:libquery_exception-src.jar',
'//gerrit-antlr:libquery_parser-src.jar',
'//gerrit-common:libannotations-src.jar',
'//gerrit-extension-api:libapi-src.jar',
'//gerrit-gwtexpui:libserver-src.jar',
'//gerrit-httpd:libhttpd-src.jar',
'//gerrit-pgm:libinit-api-src.jar',
'//gerrit-reviewdb:libserver-src.jar',
'//gerrit-server:libserver-src.jar',
'//gerrit-sshd:libsshd-src.jar',
],
visibility = ['//visibility:public'],
)
load('//tools/bzl:javadoc.bzl', 'java_doc')
java_doc(
name = 'plugin-api-javadoc',
title = 'Gerrit Review Plugin API Documentation',
pkgs = ['com.google.gerrit'],
libs = PLUGIN_API + [
'//gerrit-antlr:query_exception',
'//gerrit-antlr:query_parser',
'//gerrit-common:annotations',
'//gerrit-common:server',
'//gerrit-extension-api:api',
'//gerrit-gwtexpui:server',
'//gerrit-reviewdb:server',
],
)

View File

@ -208,3 +208,12 @@ junit_tests(
],
visibility = ['//visibility:public'],
)
load('//tools/bzl:javadoc.bzl', 'java_doc')
java_doc(
name = 'doc',
title = 'Gerrit Review Server Documentation',
libs = [':server'],
pkgs = ['com.google.gerrit'],
)

70
gerrit-war/BUILD Normal file
View File

@ -0,0 +1,70 @@
load('//tools/bzl:genrule2.bzl', 'genrule2')
java_library(
name = 'init',
srcs = glob(['src/main/java/**/*.java']),
deps = [
'//gerrit-cache-h2:cache-h2',
'//gerrit-extension-api:api',
'//gerrit-gpg:gpg',
'//gerrit-httpd:httpd',
'//gerrit-lucene:lucene',
'//gerrit-oauth:oauth',
'//gerrit-openid:openid',
'//gerrit-pgm:http',
'//gerrit-pgm:init',
'//gerrit-pgm:init-api',
'//gerrit-pgm:util',
'//gerrit-reviewdb:server',
'//gerrit-server:server',
'//gerrit-server/src/main/prolog:common',
'//gerrit-sshd:sshd',
'//lib:guava',
'//lib:gwtorm',
'//lib:servlet-api-3_1',
'//lib/guice:guice',
'//lib/guice:guice-servlet',
'//lib/jgit/org.eclipse.jgit:jgit',
'//lib/log:api',
],
visibility = ['//visibility:public'],
)
genrule2(
name = 'webapp_assets',
cmd = 'cd gerrit-war/src/main/webapp; zip -qr $$ROOT/$@ .',
srcs = glob(['src/main/webapp/**/*']),
out = 'webapp_assets.zip',
visibility = ['//visibility:public'],
)
java_import(
name = 'log4j-config',
jars = [':log4j-config__jar'],
visibility = ['//visibility:public'],
)
genrule2(
name = 'log4j-config__jar',
cmd = 'cd gerrit-war/src/main/resources && zip -9Dqr $$ROOT/$@ .',
srcs = ['src/main/resources/log4j.properties'],
out = 'log4j-config.jar',
)
java_import(
name = 'version',
jars = [':gen_version'],
visibility = ['//visibility:public'],
)
genrule2(
name = 'gen_version',
cmd = ' && '.join([
'cd $$TMP',
'mkdir -p com/google/gerrit/common',
'cat $$ROOT/$(location //:version) >com/google/gerrit/common/Version',
'zip -9Dqr $$ROOT/$@ .',
]),
tools = ['//:version'],
out = 'gen_version.jar',
)

View File

@ -231,3 +231,9 @@ java_library(
exports = [ '@icu4j//jar' ],
visibility = ['//visibility:public'],
)
java_library(
name = 'postgresql',
exports = ['@postgresql//jar'],
visibility = ['//visibility:public'],
)

2
lib/codemirror/BUILD Normal file
View File

@ -0,0 +1,2 @@
load('//lib/codemirror:cm.bzl', 'pkg_cm')
pkg_cm()

355
lib/codemirror/cm.bzl Normal file
View File

@ -0,0 +1,355 @@
load('//tools/bzl:genrule2.bzl', 'genrule2')
CM_CSS = [
'lib/codemirror.css',
'addon/dialog/dialog.css',
'addon/merge/merge.css',
'addon/scroll/simplescrollbars.css',
'addon/search/matchesonscrollbar.css',
'addon/lint/lint.css',
]
CM_JS = [
'lib/codemirror.js',
'mode/meta.js',
'keymap/emacs.js',
'keymap/sublime.js',
'keymap/vim.js',
]
CM_ADDONS = [
'dialog/dialog.js',
'edit/closebrackets.js',
'edit/matchbrackets.js',
'edit/trailingspace.js',
'scroll/annotatescrollbar.js',
'scroll/simplescrollbars.js',
'search/jump-to-line.js',
'search/matchesonscrollbar.js',
'search/searchcursor.js',
'search/search.js',
'selection/mark-selection.js',
'mode/multiplex.js',
'mode/overlay.js',
'mode/simple.js',
'lint/lint.js',
]
# Available themes must be enumerated here,
# in gerrit-extension-api/src/main/java/com/google/gerrit/extensions/common/Theme.java,
# in gerrit-gwtui/src/main/java/net/codemirror/theme/Themes.java
CM_THEMES = [
'3024-day',
'3024-night',
'abcdef',
'ambiance',
'base16-dark',
'base16-light',
'bespin',
'blackboard',
'cobalt',
'colorforth',
'dracula',
'eclipse',
'elegant',
'erlang-dark',
'hopscotch',
'icecoder',
'isotope',
'lesser-dark',
'liquibyte',
'material',
'mbo',
'mdn-like',
'midnight',
'monokai',
'neat',
'neo',
'night',
'paraiso-dark',
'paraiso-light',
'pastel-on-dark',
'railscasts',
'rubyblue',
'seti',
'solarized',
'the-matrix',
'tomorrow-night-bright',
'tomorrow-night-eighties',
'ttcn',
'twilight',
'vibrant-ink',
'xq-dark',
'xq-light',
'yeti',
'zenburn',
]
# Available modes must be enumerated here,
# in gerrit-gwtui/src/main/java/net/codemirror/mode/Modes.java,
# gerrit-gwtui/src/main/java/net/codemirror/mode/ModeInfo.java,
# and in CodeMirror's own mode/meta.js script.
CM_MODES = [
'apl',
'asciiarmor',
'asn.1',
'asterisk',
'brainfuck',
'clike',
'clojure',
'cmake',
'cobol',
'coffeescript',
'commonlisp',
'crystal',
'css',
'cypher',
'd',
'dart',
'diff',
'django',
'dockerfile',
'dtd',
'dylan',
'ebnf',
'ecl',
'eiffel',
'elm',
'erlang',
'factor',
'fcl',
'forth',
'fortran',
'gas',
'gfm',
'gherkin',
'go',
'groovy',
'haml',
'handlebars',
'haskell-literate',
'haskell',
'haxe',
'htmlembedded',
'htmlmixed',
'http',
'idl',
'javascript',
'jinja2',
'jsx',
'julia',
'livescript',
'lua',
'markdown',
'mathematica',
'mbox',
'mirc',
'mllike',
'modelica',
'mscgen',
'mumps',
'nginx',
'nsis',
'ntriples',
'octave',
'oz',
'pascal',
'pegjs',
'perl',
'php',
'pig',
'powershell',
'properties',
'protobuf',
'pug',
'puppet',
'python',
'q',
'r',
'rpm',
'rst',
'ruby',
'rust',
'sas',
'sass',
'scheme',
'shell',
'sieve',
'slim',
'smalltalk',
'smarty',
'solr',
'soy',
'sparql',
'spreadsheet',
'sql',
'stex',
'stylus',
'swift',
'tcl',
'textile',
'tiddlywiki',
'tiki',
'toml',
'tornado',
'troff',
'ttcn-cfg',
'ttcn',
'turtle',
'twig',
'vb',
'vbscript',
'velocity',
'verilog',
'vhdl',
'vue',
'webidl',
'xml',
'xquery',
'yacas',
'yaml-frontmatter',
'yaml',
'z80',
]
VERSION = '5.18.2'
TOP = 'META-INF/resources/webjars/codemirror/%s' % VERSION
TOP_MINIFIED = 'META-INF/resources/webjars/codemirror-minified/%s' % VERSION
DIFF_MATCH_PATCH_VERSION = '20121119-1'
DIFF_MATCH_PATCH_TOP = ('META-INF/resources/webjars/google-diff-match-patch/%s'
% DIFF_MATCH_PATCH_VERSION)
def pkg_cm():
for archive, suffix, top in [
('@codemirror_original//jar', '', TOP),
('@codemirror_minified//jar', '_r', TOP_MINIFIED)
]:
# Main JavaScript and addons
genrule2(
name = 'cm' + suffix,
cmd = ' && '.join([
"echo '/** @license' >$@",
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top),
"echo '*/' >>$@",
] +
['unzip -p $(location %s) %s/%s >>$@' % (archive, top, n) for n in CM_JS] +
['unzip -p $(location %s) %s/addon/%s >>$@' % (archive, top, n)
for n in CM_ADDONS]
),
tools = [
'@codemirror_original//jar',
'@codemirror_minified//jar',
],
out = 'cm%s.js' % suffix,
)
# Main CSS
genrule2(
name = 'css' + suffix,
cmd = ' && '.join([
"echo '/** @license' >$@",
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top),
"echo '*/' >>$@",
] +
['unzip -p $(location %s) %s/%s >>$@' % (archive, top, n)
for n in CM_CSS]
),
tools = [
'@codemirror_original//jar',
'@codemirror_minified//jar',
],
out = 'cm%s.css' % suffix,
)
# Modes
for n in CM_MODES:
genrule2(
name = 'mode_%s%s' % (n, suffix),
cmd = ' && '.join([
"echo '/** @license' >$@",
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top),
"echo '*/' >>$@",
'unzip -p $(location %s) %s/mode/%s/%s.js >>$@' % (archive, top, n, n),
]
),
tools = [
'@codemirror_original//jar',
'@codemirror_minified//jar',
],
out = 'mode_%s%s.js' % (n, suffix),
)
# Themes
for n in CM_THEMES:
genrule2(
name = 'theme_%s%s' % (n, suffix),
cmd = ' && '.join([
"echo '/** @license' >$@",
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top),
"echo '*/' >>$@",
'unzip -p $(location %s) %s/theme/%s.css >>$@' % (archive, top, n)
]
),
tools = [
'@codemirror_original//jar',
'@codemirror_minified//jar',
],
out = 'theme_%s%s.css' % (n, suffix),
)
# Merge Addon bundled with diff-match-patch
genrule2(
name = 'addon_merge%s' % suffix,
cmd = ' && '.join([
"echo '/** @license' >$@",
'unzip -p $(location %s) %s/LICENSE >>$@' % (archive, top),
"echo '*/\n' >>$@",
"echo '// The google-diff-match-patch library is from https://google-diff-match-patch.googlecode.com/svn-history/r106/trunk/javascript/diff_match_patch.js\n' >> $@",
"echo '/** @license' >>$@",
"echo 'LICENSE-Apache2.0' >>$@",
"echo '*/' >>$@",
'unzip -p $(location @diff_match_patch//jar) %s/diff_match_patch.js >>$@' % DIFF_MATCH_PATCH_TOP,
"echo ';' >> $@",
'unzip -p $(location %s) %s/addon/merge/merge.js >>$@' % (archive, top)
]
),
tools = [
'@diff_match_patch//jar',
'@codemirror_original//jar',
'@codemirror_minified//jar',
],
out = 'addon_merge%s.js' % suffix,
)
# Jar packaging
genrule2(
name = 'jar' + suffix,
cmd = ' && '.join([
'cd $$TMP',
'mkdir -p net/codemirror/{addon,lib,mode,theme}',
'cp $$ROOT/$(location :css%s) net/codemirror/lib/cm.css' % suffix,
'cp $$ROOT/$(location :cm%s) net/codemirror/lib/cm.js' % suffix]
+ ['cp $$ROOT/$(location :mode_%s%s) net/codemirror/mode/%s.js' % (n, suffix, n)
for n in CM_MODES]
+ ['cp $$ROOT/$(location :theme_%s%s) net/codemirror/theme/%s.css' % (n, suffix, n)
for n in CM_THEMES]
+ ['cp $$ROOT/$(location :addon_merge%s) net/codemirror/addon/merge_bundled.js' % suffix]
+ ['zip -qr $$ROOT/$@ net/codemirror/{addon,lib,mode,theme}']),
tools = [
':addon_merge%s' % suffix,
':cm%s' % suffix,
':css%s' % suffix,
] + [
':mode_%s%s' % (n, suffix) for n in CM_MODES
] + [
':theme_%s%s' % (n, suffix) for n in CM_THEMES
],
out = 'codemirror%s.jar' % suffix,
)
native.java_import(
name = 'codemirror' + suffix,
jars = [':jar%s' % suffix],
visibility = ['//visibility:public'],
)

View File

@ -7,3 +7,9 @@
'dev',
'user',
]]
java_library(
name = 'javax-validation_src',
exports = ['@javax_validation_src//jar'],
visibility = ['//visibility:public'],
)

View File

@ -19,8 +19,6 @@ load('//tools/bzl:java.bzl', 'java_library2')
def gwt_module(gwt_xml=None, resources=[], srcs=[], **kwargs):
if gwt_xml:
resources += [gwt_xml]
if srcs:
resources += srcs
java_library2(
srcs = srcs,

71
tools/bzl/javadoc.bzl Normal file
View File

@ -0,0 +1,71 @@
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Javadoc rule.
def _impl(ctx):
zip_output = ctx.outputs.zip
transitive_jar_set = set()
source_jars = set()
for l in ctx.attr.libs:
source_jars += l.java.source_jars
transitive_jar_set += l.java.transitive_deps
transitive_jar_paths = [j.path for j in transitive_jar_set]
dir = ctx.outputs.zip.path + ".dir"
source = ctx.outputs.zip.path + ".source"
cmd = [
"mkdir %s" % source,
" && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars]),
"mkdir %s" % dir,
" ".join([
ctx.file._javadoc.path,
"-protected",
"-encoding UTF-8",
"-charset UTF-8",
"-notimestamp",
"-quiet",
"-windowtitle '%s'" % ctx.attr.title,
"-link", "http://docs.oracle.com/javase/7/docs/api",
"-sourcepath %s" % source,
"-subpackages ",
":".join(ctx.attr.pkgs),
" -classpath ",
":".join(transitive_jar_paths),
"-d %s" % dir]),
"find %s -exec touch -t 198001010000 '{}' ';'" % dir,
"(cd %s && zip -qr ../%s *)" % (dir, ctx.outputs.zip.basename),
]
ctx.action(
inputs = list(transitive_jar_set) + list(source_jars) + ctx.files._jdk,
outputs = [zip_output],
command = " && ".join(cmd))
java_doc = rule(
attrs = {
"libs": attr.label_list(allow_files = False),
"pkgs": attr.string_list(),
"title": attr.string(),
"_javadoc": attr.label(
default = Label("@local_jdk//:bin/javadoc"),
single_file = True,
allow_files = True),
"_jdk": attr.label(
default = Label("@local_jdk//:jdk-default"),
allow_files = True),
},
implementation = _impl,
outputs = {"zip" : "%{name}.zip"},
)

139
tools/bzl/pkg_war.bzl Normal file
View File

@ -0,0 +1,139 @@
# Copyright (C) 2016 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# War packaging.
jar_filetype = FileType(['.jar'])
LIBS = [
'//gerrit-war:init',
'//gerrit-war:log4j-config',
'//gerrit-war:version',
'//lib:postgresql',
'//lib/log:impl_log4j',
]
PGMLIBS = [
'//gerrit-pgm:pgm'
]
def _add_context(in_file, output):
input_path = in_file.path
return [
'unzip -qd %s %s' % (output, input_path)
]
def _add_file(in_file, output):
output_path = output
input_path = in_file.path
short_path = in_file.short_path
n = in_file.basename
# TODO(davido): Drop this when provided_deps added to java_library
if n.find('-jdk15on-') != -1:
return []
if short_path.startswith('gerrit-'):
n = short_path.split('/')[0] + '-' + n
output_path += n
return [
'test -L %s || ln -s $(pwd)/%s %s' % (output_path, input_path, output_path)
]
def _make_war(input_dir, output):
return ''.join([
'(root=$(pwd) && ',
'cd %s && ' % input_dir,
'zip -9qr ${root}/%s .)' % (output.path),
])
def _war_impl(ctx):
war = ctx.outputs.war
build_output = war.path + '.build_output'
inputs = []
# Create war layout
cmd = [
'set -e;rm -rf ' + build_output,
'mkdir -p ' + build_output,
'mkdir -p %s/WEB-INF/lib' % build_output,
'mkdir -p %s/WEB-INF/pgm-lib' % build_output,
]
# Add lib
transitive_lib_deps = set()
for l in ctx.attr.libs:
transitive_lib_deps += l.java.transitive_runtime_deps
for dep in transitive_lib_deps:
cmd += _add_file(dep, build_output + '/WEB-INF/lib/')
inputs.append(dep)
# Add pgm lib
transitive_pgmlib_deps = set()
for l in ctx.attr.pgmlibs:
transitive_pgmlib_deps += l.java.transitive_runtime_deps
for dep in transitive_pgmlib_deps:
if dep not in inputs:
cmd += _add_file(dep, build_output + '/WEB-INF/pgm-lib/')
inputs.append(dep)
# Add context
transitive_context_deps = set()
if ctx.attr.context:
for jar in ctx.attr.context:
if hasattr(jar, 'java'):
transitive_context_deps += jar.java.transitive_runtime_deps
elif hasattr(jar, 'files'):
transitive_context_deps += jar.files
for dep in transitive_context_deps:
cmd += _add_context(dep, build_output)
inputs.append(dep)
# Add zip war
cmd.append(_make_war(build_output, war))
ctx.action(
inputs = inputs,
outputs = [war],
mnemonic = 'WAR',
command = '\n'.join(cmd),
use_default_shell_env = True,
)
_pkg_war = rule(
attrs = {
'context': attr.label_list(allow_files = True),
'libs': attr.label_list(allow_files = jar_filetype),
'pgmlibs': attr.label_list(allow_files = False),
},
implementation = _war_impl,
outputs = {'war' : '%{name}.war'},
)
def pkg_war(name, ui = 'ui_optdbg'):
ui_deps = []
if ui:
ui_deps.append('//gerrit-gwtui:%s' % ui)
_pkg_war(
name = name,
libs = LIBS,
pgmlibs = PGMLIBS,
context = ui_deps + [
'//gerrit-main:main_bin_deploy.jar',
'//gerrit-war:webapp_assets',
],
)