Merge branch 'stable-2.15' into stable-2.16

* stable-2.15:
  Bazel: Automatically fix lint errors with buildifier 0.20.0
  Bazel: Fix more buildifier warnings
  Bazel: Automatically fix lint errors with buildifier 0.20.0
  Fix typo in documentation of edit preferences
  Bazel: Automatically fix lint errors with buildifier

Change-Id: I3400928e4dca65264715dca3c29729237934f042
This commit is contained in:
David Pursehouse
2019-01-10 21:44:13 +09:00
32 changed files with 116 additions and 131 deletions

10
BUILD
View File

@@ -1,11 +1,9 @@
package(default_visibility = ["//visibility:public"])
load("//tools/bzl:genrule2.bzl", "genrule2")
load("//tools/bzl:pkg_war.bzl", "pkg_war")
load( load(
"@bazel_tools//tools/jdk:default_java_toolchain.bzl", "@bazel_tools//tools/jdk:default_java_toolchain.bzl",
"default_java_toolchain", "default_java_toolchain",
) )
load("//tools/bzl:genrule2.bzl", "genrule2")
load("//tools/bzl:pkg_war.bzl", "pkg_war")
config_setting( config_setting(
name = "java9", name = "java9",
@@ -35,8 +33,8 @@ config_setting(
java_runtime( java_runtime(
name = "absolute_javabase", name = "absolute_javabase",
java_home = select({ java_home = select({
":use_absolute_javabase": "$(ABSOLUTE_JAVABASE)",
"//conditions:default": "", "//conditions:default": "",
":use_absolute_javabase": "$(ABSOLUTE_JAVABASE)",
}), }),
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
@@ -51,6 +49,8 @@ default_java_toolchain(
jvm_opts = [], jvm_opts = [],
) )
package(default_visibility = ["//visibility:public"])
genrule( genrule(
name = "gen_version", name = "gen_version",
outs = ["version.txt"], outs = ["version.txt"],

View File

@@ -1,10 +1,8 @@
package(default_visibility = ["//visibility:public"]) load("//tools/bzl:asciidoc.bzl", "documentation_attributes", "genasciidoc", "genasciidoc_zip")
load("//tools/bzl:asciidoc.bzl", "documentation_attributes")
load("//tools/bzl:asciidoc.bzl", "genasciidoc")
load("//tools/bzl:asciidoc.bzl", "genasciidoc_zip")
load("//tools/bzl:license.bzl", "license_map") load("//tools/bzl:license.bzl", "license_map")
package(default_visibility = ["//visibility:public"])
exports_files([ exports_files([
"replace_macros.py", "replace_macros.py",
]) ])

View File

@@ -200,7 +200,7 @@ The parameter names match the names that are used in the preferences REST API:
* link:rest-api-accounts.html#edit-preferences-info[Edit Preferences] * link:rest-api-accounts.html#edit-preferences-info[Edit Preferences]
If the value for a preference is the same as the default value for this If the value for a preference is the same as the default value for this
preference, it can be omitted in the `preference.config` file. preference, it can be omitted in the `preferences.config` file.
Defaults for preferences that apply for all accounts can be configured Defaults for preferences that apply for all accounts can be configured
in the `refs/users/default` branch in the `All-Users` repository. in the `refs/users/default` branch in the `All-Users` repository.

View File

@@ -1,6 +1,6 @@
load("//tools/bzl:gwt.bzl", "gwt_module")
load("//tools/bzl:java.bzl", "java_library2") load("//tools/bzl:java.bzl", "java_library2")
load("//tools/bzl:junit.bzl", "junit_tests") load("//tools/bzl:junit.bzl", "junit_tests")
load("//tools/bzl:gwt.bzl", "gwt_module")
EXPORTED_DEPS = [ EXPORTED_DEPS = [
"//java/com/google/gerrit/common:client", "//java/com/google/gerrit/common:client",

View File

@@ -4,12 +4,12 @@ load(
"gwt_genrule", "gwt_genrule",
"gwt_user_agent_permutations", "gwt_user_agent_permutations",
) )
load("//tools/bzl:license.bzl", "license_test")
load("//tools/bzl:junit.bzl", "junit_tests") load("//tools/bzl:junit.bzl", "junit_tests")
load("//tools/bzl:license.bzl", "license_test")
gwt_genrule() gwt_genrule()
gwt_genrule("_r") gwt_genrule(suffix = "_r")
gen_ui_module(name = "ui_module") gen_ui_module(name = "ui_module")

View File

@@ -1,6 +1,7 @@
package(default_visibility = ["//visibility:public"])
load("//tools/bzl:java.bzl", "java_library2") load("//tools/bzl:java.bzl", "java_library2")
load("//tools/bzl:javadoc.bzl", "java_doc")
package(default_visibility = ["//visibility:public"])
SRCS = glob(["src/main/java/com/google/gerrit/**/*.java"]) SRCS = glob(["src/main/java/com/google/gerrit/**/*.java"])
@@ -60,8 +61,6 @@ java_binary(
], ],
) )
load("//tools/bzl:javadoc.bzl", "java_doc")
java_doc( java_doc(
name = "gwtui-api-javadoc", name = "gwtui-api-javadoc",
libs = DEPS + [ libs = DEPS + [

View File

@@ -1,4 +1,5 @@
load("//tools/bzl:java.bzl", "java_library2") load("//tools/bzl:java.bzl", "java_library2")
load("//tools/bzl:javadoc.bzl", "java_doc")
java_library( java_library(
name = "lib", name = "lib",
@@ -125,8 +126,6 @@ java_library2(
], ],
) )
load("//tools/bzl:javadoc.bzl", "java_doc")
java_doc( java_doc(
name = "framework-javadoc", name = "framework-javadoc",
testonly = True, testonly = True,

View File

@@ -1,4 +1,3 @@
load("//tools/bzl:genrule2.bzl", "genrule2")
load("//tools/bzl:gwt.bzl", "gwt_module") load("//tools/bzl:gwt.bzl", "gwt_module")
ANNOTATIONS = [ ANNOTATIONS = [

View File

@@ -1,6 +1,7 @@
load("//lib:guava.bzl", "GUAVA_DOC_URL")
load("//lib/jgit:jgit.bzl", "JGIT_DOC_URL") load("//lib/jgit:jgit.bzl", "JGIT_DOC_URL")
load("//lib:guava.bzl", "GUAVA_DOC_URL")
load("//tools/bzl:gwt.bzl", "gwt_module") load("//tools/bzl:gwt.bzl", "gwt_module")
load("//tools/bzl:javadoc.bzl", "java_doc")
EXT_API_SRCS = glob(["client/*.java"]) EXT_API_SRCS = glob(["client/*.java"])
@@ -44,8 +45,6 @@ java_library(
], ],
) )
load("//tools/bzl:javadoc.bzl", "java_doc")
java_doc( java_doc(
name = "extension-api-javadoc", name = "extension-api-javadoc",
external_docs = [ external_docs = [

View File

@@ -1,5 +1,3 @@
load("//tools/bzl:genrule2.bzl", "genrule2")
QUERY_PARSE_EXCEPTION_SRCS = [ QUERY_PARSE_EXCEPTION_SRCS = [
"query/QueryParseException.java", "query/QueryParseException.java",
"query/QueryRequiresAuthException.java", "query/QueryRequiresAuthException.java",

View File

@@ -1,9 +1,9 @@
load("//tools/bzl:gwt.bzl", "gwt_module")
package( package(
default_visibility = ["//visibility:public"], default_visibility = ["//visibility:public"],
) )
load("//tools/bzl:gwt.bzl", "gwt_module")
gwt_module( gwt_module(
name = "client", name = "client",
srcs = glob(["client/**/*.java"]), srcs = glob(["client/**/*.java"]),

View File

@@ -1,3 +1,5 @@
load("//tools/bzl:javadoc.bzl", "java_doc")
CONSTANTS_SRC = [ CONSTANTS_SRC = [
"documentation/Constants.java", "documentation/Constants.java",
] ]
@@ -141,8 +143,6 @@ java_library(
], ],
) )
load("//tools/bzl:javadoc.bzl", "java_doc")
java_doc( java_doc(
name = "doc", name = "doc",
libs = [":server"], libs = [":server"],

View File

@@ -1,5 +1,3 @@
load("//tools/bzl:gwt.bzl", "gwt_module")
java_library( java_library(
name = "css", name = "css",
srcs = glob(["rebind/*.java"]), srcs = glob(["rebind/*.java"]),

View File

@@ -1,7 +1,6 @@
load("//tools/bzl:genrule2.bzl", "genrule2")
# Roboto Mono. Version 2.136 # Roboto Mono. Version 2.136
# https://github.com/google/roboto/releases/tag/v2.136 # https://github.com/google/roboto/releases/tag/v2.136
filegroup( filegroup(
name = "robotofonts", name = "robotofonts",
srcs = [ srcs = [

View File

@@ -1,4 +1,4 @@
load("//tools/bzl:maven_jar.bzl", "GERRIT", "MAVEN_CENTRAL", "MAVEN_LOCAL", "maven_jar") load("//tools/bzl:maven_jar.bzl", "MAVEN_CENTRAL", "maven_jar")
_JGIT_VERS = "5.1.3.201810200350-r" _JGIT_VERS = "5.1.3.201810200350-r"
@@ -67,11 +67,11 @@ def jgit_maven_repos():
def jgit_dep(name): def jgit_dep(name):
mapping = { mapping = {
"@jgit-junit//jar": "@jgit//org.eclipse.jgit.junit:junit",
"@jgit-lib//jar:src": "@jgit//org.eclipse.jgit:libjgit-src.jar",
"@jgit-lib//jar": "@jgit//org.eclipse.jgit:jgit",
"@jgit-servlet//jar": "@jgit//org.eclipse.jgit.http.server:jgit-servlet",
"@jgit-archive//jar": "@jgit//org.eclipse.jgit.archive:jgit-archive", "@jgit-archive//jar": "@jgit//org.eclipse.jgit.archive:jgit-archive",
"@jgit-junit//jar": "@jgit//org.eclipse.jgit.junit:junit",
"@jgit-lib//jar": "@jgit//org.eclipse.jgit:jgit",
"@jgit-lib//jar:src": "@jgit//org.eclipse.jgit:libjgit-src.jar",
"@jgit-servlet//jar": "@jgit//org.eclipse.jgit.http.server:jgit-servlet",
} }
if LOCAL_JGIT_REPO: if LOCAL_JGIT_REPO:

View File

@@ -1,7 +1,8 @@
package(default_visibility = ["//visibility:public"]) load("//lib/js:bower_components.bzl", "define_bower_components")
load("//tools/bzl:js.bzl", "bower_component", "js_component") load("//tools/bzl:js.bzl", "bower_component", "js_component")
package(default_visibility = ["//visibility:public"])
# For importing new versions of existing bower packages, # For importing new versions of existing bower packages,
# #
# 1) edit the versions of 'seed' components in WORKSPACE as desired # 1) edit the versions of 'seed' components in WORKSPACE as desired
@@ -20,8 +21,6 @@ load("//tools/bzl:js.bzl", "bower_component", "js_component")
# 4) remove bower_component(name="my_new_dependency", .. ) here # 4) remove bower_component(name="my_new_dependency", .. ) here
# #
load("//lib/js:bower_components.bzl", "define_bower_components")
define_bower_components() define_bower_components()
js_component( js_component(

View File

@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])
load("//tools/bzl:maven.bzl", "merge_maven_jars") load("//tools/bzl:maven.bzl", "merge_maven_jars")
package(default_visibility = ["//visibility:public"])
# core and backward-codecs both provide # core and backward-codecs both provide
# META-INF/services/org.apache.lucene.codecs.Codec, so they must be merged. # META-INF/services/org.apache.lucene.codecs.Codec, so they must be merged.
merge_maven_jars( merge_maven_jars(

View File

@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library") load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
package(default_visibility = ["//visibility:public"])
closure_js_library( closure_js_library(
name = "polymer_closure", name = "polymer_closure",
srcs = ["@polymer_closure//file"], srcs = ["@polymer_closure//file"],

View File

@@ -1,4 +1,5 @@
load("//tools/bzl:genrule2.bzl", "genrule2") load("//tools/bzl:genrule2.bzl", "genrule2")
load("//tools/bzl:javadoc.bzl", "java_doc")
load( load(
"//tools/bzl:plugins.bzl", "//tools/bzl:plugins.bzl",
"CORE_PLUGINS", "CORE_PLUGINS",
@@ -121,8 +122,6 @@ java_binary(
], ],
) )
load("//tools/bzl:javadoc.bzl", "java_doc")
java_doc( java_doc(
name = "plugin-api-javadoc", name = "plugin-api-javadoc",
libs = PLUGIN_API + [ libs = PLUGIN_API + [

View File

@@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_go//go:def.bzl", "go_binary") load("@io_bazel_rules_go//go:def.bzl", "go_binary")
load("//tools/bzl:js.bzl", "bower_component_bundle")
load("//tools/bzl:genrule2.bzl", "genrule2") load("//tools/bzl:genrule2.bzl", "genrule2")
load("//tools/bzl:js.bzl", "bower_component_bundle")
package(default_visibility = ["//visibility:public"])
bower_component_bundle( bower_component_bundle(
name = "polygerrit_components.bower_components", name = "polygerrit_components.bower_components",

View File

@@ -1,8 +1,8 @@
package(default_visibility = ["//visibility:public"])
load(":rules.bzl", "polygerrit_bundle")
load("//tools/bzl:genrule2.bzl", "genrule2") load("//tools/bzl:genrule2.bzl", "genrule2")
load("//tools/bzl:js.bzl", "bower_component_bundle") load("//tools/bzl:js.bzl", "bower_component_bundle")
load(":rules.bzl", "polygerrit_bundle")
package(default_visibility = ["//visibility:public"])
polygerrit_bundle( polygerrit_bundle(
name = "polygerrit_ui", name = "polygerrit_ui",

View File

@@ -12,12 +12,12 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
package( package(
default_visibility = ["//visibility:public"], default_visibility = ["//visibility:public"],
) )
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_library")
closure_js_library( closure_js_library(
name = "plugin", name = "plugin",
srcs = ["plugin.js"], srcs = ["plugin.js"],

View File

@@ -1,10 +1,8 @@
load("//tools/bzl:genrule2.bzl", "genrule2")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary", "closure_js_library") load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary", "closure_js_library")
load("//tools/bzl:genrule2.bzl", "genrule2")
load( load(
"//tools/bzl:js.bzl", "//tools/bzl:js.bzl",
"bower_component",
"bundle_assets", "bundle_assets",
"js_component",
) )
def polygerrit_bundle(name, srcs, outs, app): def polygerrit_bundle(name, srcs, outs, app):

View File

@@ -41,17 +41,17 @@ def _replace_macros_impl(ctx):
_replace_macros = rule( _replace_macros = rule(
attrs = { attrs = {
"_exe": attr.label(
default = Label("//Documentation:replace_macros.py"),
allow_single_file = True,
),
"src": attr.label( "src": attr.label(
mandatory = True, mandatory = True,
allow_single_file = [".txt"], allow_single_file = [".txt"],
), ),
"suffix": attr.string(mandatory = True),
"searchbox": attr.bool(default = True),
"out": attr.output(mandatory = True), "out": attr.output(mandatory = True),
"searchbox": attr.bool(default = True),
"suffix": attr.string(mandatory = True),
"_exe": attr.label(
default = Label("//Documentation:replace_macros.py"),
allow_single_file = True,
),
}, },
implementation = _replace_macros_impl, implementation = _replace_macros_impl,
) )
@@ -108,23 +108,23 @@ def _asciidoc_impl(ctx):
) )
_asciidoc_attrs = { _asciidoc_attrs = {
"srcs": attr.label_list(
mandatory = True,
allow_files = True,
),
"attributes": attr.string_list(),
"backend": attr.string(),
"suffix": attr.string(mandatory = True),
"version": attr.label(
default = Label("//:version.txt"),
allow_single_file = True,
),
"_exe": attr.label( "_exe": attr.label(
default = Label("//java/com/google/gerrit/asciidoctor:asciidoc"), default = Label("//java/com/google/gerrit/asciidoctor:asciidoc"),
cfg = "host", cfg = "host",
allow_files = True, allow_files = True,
executable = True, executable = True,
), ),
"srcs": attr.label_list(
mandatory = True,
allow_files = True,
),
"version": attr.label(
default = Label("//:version.txt"),
allow_single_file = True,
),
"suffix": attr.string(mandatory = True),
"backend": attr.string(),
"attributes": attr.string_list(),
} }
_asciidoc = rule( _asciidoc = rule(
@@ -279,11 +279,11 @@ _asciidoc_zip = rule(
mandatory = True, mandatory = True,
allow_single_file = [".zip"], allow_single_file = [".zip"],
), ),
"directory": attr.string(mandatory = True),
"resources": attr.label_list( "resources": attr.label_list(
mandatory = True, mandatory = True,
allow_files = True, allow_files = True,
), ),
"directory": attr.string(mandatory = True),
}, },
outputs = { outputs = {
"out": "%{name}.zip", "out": "%{name}.zip",

View File

@@ -8,8 +8,8 @@ def _classpath_collector(ctx):
elif hasattr(d, "files"): elif hasattr(d, "files"):
all += d.files all += d.files
as_strs = [c.path for c in all] as_strs = [c.path for c in all.to_list()]
ctx.file_action( ctx.actions.write(
output = ctx.outputs.runtime, output = ctx.outputs.runtime,
content = "\n".join(sorted(as_strs)), content = "\n".join(sorted(as_strs)),
) )

View File

@@ -31,9 +31,9 @@ BROWSERS = [
ALIASES = { ALIASES = {
"chrome": "safari", "chrome": "safari",
"edge": "gecko1_8",
"firefox": "gecko1_8", "firefox": "gecko1_8",
"msie": "ie10", "msie": "ie10",
"edge": "gecko1_8",
} }
MODULE = "com.google.gerrit.GerritGwtUI" MODULE = "com.google.gerrit.GerritGwtUI"
@@ -111,14 +111,14 @@ def _gwt_user_agent_module(ctx):
impl = ALIASES[ua] impl = ALIASES[ua]
# intermediate artifact: user agent speific GWT xml file # intermediate artifact: user agent speific GWT xml file
gwt_user_agent_xml = ctx.new_file(ctx.label.name + "_gwt.xml") gwt_user_agent_xml = ctx.actions.declare_file(ctx.label.name + "_gwt.xml")
ctx.file_action( ctx.actions.write(
output = gwt_user_agent_xml, output = gwt_user_agent_xml,
content = USER_AGENT_XML % (MODULE, impl), content = USER_AGENT_XML % (MODULE, impl),
) )
# intermediate artifact: user agent specific zip with GWT module # intermediate artifact: user agent specific zip with GWT module
gwt_user_agent_zip = ctx.new_file(ctx.label.name + "_gwt.zip") gwt_user_agent_zip = ctx.actions.declare_file(ctx.label.name + "_gwt.zip")
gwt = "%s_%s.gwt.xml" % (MODULE.replace(".", "/"), ua) gwt = "%s_%s.gwt.xml" % (MODULE.replace(".", "/"), ua)
dir = gwt_user_agent_zip.path + ".dir" dir = gwt_user_agent_zip.path + ".dir"
cmd = " && ".join([ cmd = " && ".join([
@@ -209,14 +209,14 @@ def _get_transitive_closure(ctx):
gwt_binary = rule( gwt_binary = rule(
attrs = { attrs = {
"user_agent": attr.string(),
"style": attr.string(default = "OBF"),
"optimize": attr.string(default = "9"),
"deps": attr.label_list(allow_files = jar_filetype),
"module": attr.string_list(default = [MODULE]),
"module_deps": attr.label_list(allow_files = jar_filetype),
"compiler_args": attr.string_list(), "compiler_args": attr.string_list(),
"jvm_args": attr.string_list(), "jvm_args": attr.string_list(),
"module": attr.string_list(default = [MODULE]),
"module_deps": attr.label_list(allow_files = jar_filetype),
"optimize": attr.string(default = "9"),
"style": attr.string(default = "OBF"),
"user_agent": attr.string(),
"deps": attr.label_list(allow_files = jar_filetype),
"_jdk": attr.label( "_jdk": attr.label(
default = Label("@bazel_tools//tools/jdk:current_java_runtime"), default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
cfg = "host", cfg = "host",

View File

@@ -23,7 +23,7 @@ def _impl(ctx):
source_jars += l.java.source_jars source_jars += l.java.source_jars
transitive_jar_set += l.java.transitive_deps transitive_jar_set += l.java.transitive_deps
transitive_jar_paths = [j.path for j in transitive_jar_set] transitive_jar_paths = [j.path for j in transitive_jar_set.to_list()]
dir = ctx.outputs.zip.path + ".dir" dir = ctx.outputs.zip.path + ".dir"
source = ctx.outputs.zip.path + ".source" source = ctx.outputs.zip.path + ".source"
external_docs = ["http://docs.oracle.com/javase/8/docs/api"] + ctx.attr.external_docs external_docs = ["http://docs.oracle.com/javase/8/docs/api"] + ctx.attr.external_docs
@@ -32,7 +32,7 @@ def _impl(ctx):
"export TZ", "export TZ",
"rm -rf %s" % source, "rm -rf %s" % source,
"mkdir %s" % source, "mkdir %s" % source,
" && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars]), " && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars.to_list()]),
"rm -rf %s" % dir, "rm -rf %s" % dir,
"mkdir %s" % dir, "mkdir %s" % dir,
" ".join([ " ".join([
@@ -56,17 +56,17 @@ def _impl(ctx):
"(cd %s && zip -Xqr ../%s *)" % (dir, ctx.outputs.zip.basename), "(cd %s && zip -Xqr ../%s *)" % (dir, ctx.outputs.zip.basename),
] ]
ctx.actions.run_shell( ctx.actions.run_shell(
inputs = list(transitive_jar_set) + list(source_jars) + ctx.files._jdk, inputs = transitive_jar_set.to_list() + source_jars.to_list() + ctx.files._jdk,
outputs = [zip_output], outputs = [zip_output],
command = " && ".join(cmd), command = " && ".join(cmd),
) )
java_doc = rule( java_doc = rule(
attrs = { attrs = {
"external_docs": attr.string_list(),
"libs": attr.label_list(allow_files = False), "libs": attr.label_list(allow_files = False),
"pkgs": attr.string_list(), "pkgs": attr.string_list(),
"title": attr.string(), "title": attr.string(),
"external_docs": attr.string_list(),
"_jdk": attr.label( "_jdk": attr.label(
default = Label("@bazel_tools//tools/jdk:current_java_runtime"), default = Label("@bazel_tools//tools/jdk:current_java_runtime"),
allow_files = True, allow_files = True,

View File

@@ -1,10 +1,10 @@
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary", "closure_js_library")
load("//lib/js:npm.bzl", "NPM_SHA1S", "NPM_VERSIONS")
NPMJS = "NPMJS" NPMJS = "NPMJS"
GERRIT = "GERRIT:" GERRIT = "GERRIT:"
load("//lib/js:npm.bzl", "NPM_SHA1S", "NPM_VERSIONS")
load("@io_bazel_rules_closure//closure:defs.bzl", "closure_js_binary", "closure_js_library")
def _npm_tarball(name): def _npm_tarball(name):
return "%s@%s.npm_binary.tgz" % (name, NPM_VERSIONS[name]) return "%s@%s.npm_binary.tgz" % (name, NPM_VERSIONS[name])
@@ -37,9 +37,9 @@ def _npm_binary_impl(ctx):
npm_binary = repository_rule( npm_binary = repository_rule(
attrs = { attrs = {
"repository": attr.string(default = NPMJS),
# Label resolves within repo of the .bzl file. # Label resolves within repo of the .bzl file.
"_download_script": attr.label(default = Label("//tools:download_file.py")), "_download_script": attr.label(default = Label("//tools:download_file.py")),
"repository": attr.string(default = NPMJS),
}, },
local = True, local = True,
implementation = _npm_binary_impl, implementation = _npm_binary_impl,
@@ -120,13 +120,13 @@ def _bash(ctx, cmd):
bower_archive = repository_rule( bower_archive = repository_rule(
_bower_archive, _bower_archive,
attrs = { attrs = {
"_bower_archive": attr.label(default = Label("@bower//:%s" % _npm_tarball("bower"))),
"_run_npm": attr.label(default = Label("//tools/js:run_npm_binary.py")),
"_download_bower": attr.label(default = Label("//tools/js:download_bower.py")),
"sha1": attr.string(mandatory = True),
"version": attr.string(mandatory = True),
"package": attr.string(mandatory = True), "package": attr.string(mandatory = True),
"semver": attr.string(), "semver": attr.string(),
"sha1": attr.string(mandatory = True),
"version": attr.string(mandatory = True),
"_bower_archive": attr.label(default = Label("@bower//:%s" % _npm_tarball("bower"))),
"_download_bower": attr.label(default = Label("//tools/js:download_bower.py")),
"_run_npm": attr.label(default = Label("//tools/js:run_npm_binary.py")),
}, },
) )
@@ -207,12 +207,12 @@ js_component = rule(
_bower_component = rule( _bower_component = rule(
_bower_component_impl, _bower_component_impl,
attrs = dict(_common_attrs.items() + { attrs = dict(_common_attrs.items() + {
"zipfile": attr.label(allow_single_file = [".zip"]),
"license": attr.label(allow_single_file = True), "license": attr.label(allow_single_file = True),
"version_json": attr.label(allow_files = [".json"]),
# If set, define by hand, and don't regenerate this entry in bower2bazel. # If set, define by hand, and don't regenerate this entry in bower2bazel.
"seed": attr.bool(default = False), "seed": attr.bool(default = False),
"version_json": attr.label(allow_files = [".json"]),
"zipfile": attr.label(allow_single_file = [".zip"]),
}.items()), }.items()),
) )
@@ -247,7 +247,7 @@ def _bower_component_bundle_impl(ctx):
out_versions = ctx.outputs.version_json out_versions = ctx.outputs.version_json
ctx.actions.run_shell( ctx.actions.run_shell(
inputs = list(zips), inputs = zips.to_list(),
outputs = [out_zip], outputs = [out_zip],
command = " && ".join([ command = " && ".join([
"p=$PWD", "p=$PWD",
@@ -256,7 +256,7 @@ def _bower_component_bundle_impl(ctx):
"rm -rf %s.dir" % out_zip.path, "rm -rf %s.dir" % out_zip.path,
"mkdir -p %s.dir/bower_components" % out_zip.path, "mkdir -p %s.dir/bower_components" % out_zip.path,
"cd %s.dir/bower_components" % out_zip.path, "cd %s.dir/bower_components" % out_zip.path,
"for z in %s; do unzip -q $p/$z ; done" % " ".join(sorted([z.path for z in zips])), "for z in %s; do unzip -q $p/$z ; done" % " ".join(sorted([z.path for z in zips.to_list()])),
"cd ..", "cd ..",
"find . -exec touch -t 198001010000 '{}' ';'", "find . -exec touch -t 198001010000 '{}' ';'",
"zip -Xqr $p/%s bower_components/*" % out_zip.path, "zip -Xqr $p/%s bower_components/*" % out_zip.path,
@@ -265,10 +265,10 @@ def _bower_component_bundle_impl(ctx):
) )
ctx.actions.run_shell( ctx.actions.run_shell(
inputs = list(versions), inputs = versions.to_list(),
outputs = [out_versions], outputs = [out_versions],
mnemonic = "BowerVersions", mnemonic = "BowerVersions",
command = "(echo '{' ; for j in %s ; do cat $j; echo ',' ; done ; echo \\\"\\\":\\\"\\\"; echo '}') > %s" % (" ".join([v.path for v in versions]), out_versions.path), command = "(echo '{' ; for j in %s ; do cat $j; echo ',' ; done ; echo \\\"\\\":\\\"\\\"; echo '}') > %s" % (" ".join([v.path for v in versions.to_list()]), out_versions.path),
) )
return struct( return struct(
@@ -281,8 +281,8 @@ bower_component_bundle = rule(
_bower_component_bundle_impl, _bower_component_bundle_impl,
attrs = _common_attrs, attrs = _common_attrs,
outputs = { outputs = {
"zip": "%{name}.zip",
"version_json": "%{name}-versions.json", "version_json": "%{name}-versions.json",
"zip": "%{name}.zip",
}, },
) )
@@ -394,11 +394,6 @@ def _bundle_output_func(name, split):
_bundle_rule = rule( _bundle_rule = rule(
_bundle_impl, _bundle_impl,
attrs = { attrs = {
"deps": attr.label_list(providers = ["transitive_zipfiles"]),
"app": attr.label(
mandatory = True,
allow_single_file = True,
),
"srcs": attr.label_list(allow_files = [ "srcs": attr.label_list(allow_files = [
".js", ".js",
".html", ".html",
@@ -406,12 +401,13 @@ _bundle_rule = rule(
".css", ".css",
".ico", ".ico",
]), ]),
"pkg": attr.string(mandatory = True), "app": attr.label(
"split": attr.bool(default = True), mandatory = True,
"_run_npm": attr.label(
default = Label("//tools/js:run_npm_binary.py"),
allow_single_file = True, allow_single_file = True,
), ),
"pkg": attr.string(mandatory = True),
"split": attr.bool(default = True),
"deps": attr.label_list(providers = ["transitive_zipfiles"]),
"_bundler_archive": attr.label( "_bundler_archive": attr.label(
default = Label("@polymer-bundler//:%s" % _npm_tarball("polymer-bundler")), default = Label("@polymer-bundler//:%s" % _npm_tarball("polymer-bundler")),
allow_single_file = True, allow_single_file = True,
@@ -420,13 +416,17 @@ _bundle_rule = rule(
default = Label("@crisper//:%s" % _npm_tarball("crisper")), default = Label("@crisper//:%s" % _npm_tarball("crisper")),
allow_single_file = True, allow_single_file = True,
), ),
"_run_npm": attr.label(
default = Label("//tools/js:run_npm_binary.py"),
allow_single_file = True,
),
}, },
outputs = _bundle_output_func, outputs = _bundle_output_func,
) )
def bundle_assets(*args, **kwargs): def bundle_assets(*args, **kwargs):
"""Combine html, js, css files and optionally split into js and html bundles.""" """Combine html, js, css files and optionally split into js and html bundles."""
_bundle_rule(*args, pkg = native.package_name(), **kwargs) _bundle_rule(pkg = native.package_name(), *args, **kwargs)
def polygerrit_plugin(name, app, srcs = [], assets = None, plugin_name = None, **kwargs): def polygerrit_plugin(name, app, srcs = [], assets = None, plugin_name = None, **kwargs):
"""Bundles plugin dependencies for deployment. """Bundles plugin dependencies for deployment.

View File

@@ -50,7 +50,7 @@ def _impl(ctx):
classes = ",".join( classes = ",".join(
[_AsClassName(x) for x in ctx.attr.srcs], [_AsClassName(x) for x in ctx.attr.srcs],
) )
ctx.file_action(output = ctx.outputs.out, content = _OUTPUT % ( ctx.actions.write(output = ctx.outputs.out, content = _OUTPUT % (
classes, classes,
ctx.attr.outname, ctx.attr.outname,
)) ))
@@ -81,8 +81,8 @@ def junit_tests(name, srcs, **kwargs):
) )
jvm_flags = kwargs.get("jvm_flags", []) jvm_flags = kwargs.get("jvm_flags", [])
jvm_flags = jvm_flags + select({ jvm_flags = jvm_flags + select({
"//:java9": POST_JDK8_OPTS,
"//:java10": POST_JDK8_OPTS, "//:java10": POST_JDK8_OPTS,
"//:java9": POST_JDK8_OPTS,
"//conditions:default": [], "//conditions:default": [],
}) })
native.java_test( native.java_test(

View File

@@ -164,15 +164,15 @@ def _maven_jar_impl(ctx):
maven_jar = repository_rule( maven_jar = repository_rule(
attrs = { attrs = {
"artifact": attr.string(mandatory = True), "artifact": attr.string(mandatory = True),
"attach_source": attr.bool(default = True),
"exclude": attr.string_list(),
"repository": attr.string(default = MAVEN_CENTRAL),
"sha1": attr.string(), "sha1": attr.string(),
"src_sha1": attr.string(), "src_sha1": attr.string(),
"_download_script": attr.label(default = Label("//tools:download_file.py")),
"repository": attr.string(default = MAVEN_CENTRAL),
"attach_source": attr.bool(default = True),
"unsign": attr.bool(default = False), "unsign": attr.bool(default = False),
"deps": attr.string_list(),
"exports": attr.string_list(), "exports": attr.string_list(),
"exclude": attr.string_list(), "deps": attr.string_list(),
"_download_script": attr.label(default = Label("//tools:download_file.py")),
}, },
local = True, local = True,
implementation = _maven_jar_impl, implementation = _maven_jar_impl,

View File

@@ -83,7 +83,7 @@ def _war_impl(ctx):
elif hasattr(l, "files"): elif hasattr(l, "files"):
transitive_lib_deps += l.files transitive_lib_deps += l.files
for dep in transitive_lib_deps: for dep in transitive_lib_deps.to_list():
cmd += _add_file(dep, build_output + "/WEB-INF/lib/") cmd += _add_file(dep, build_output + "/WEB-INF/lib/")
inputs.append(dep) inputs.append(dep)
@@ -92,7 +92,7 @@ def _war_impl(ctx):
for l in ctx.attr.pgmlibs: for l in ctx.attr.pgmlibs:
transitive_pgmlib_deps += l.java.transitive_runtime_deps transitive_pgmlib_deps += l.java.transitive_runtime_deps
for dep in transitive_pgmlib_deps: for dep in transitive_pgmlib_deps.to_list():
if dep not in inputs: if dep not in inputs:
cmd += _add_file(dep, build_output + "/WEB-INF/pgm-lib/") cmd += _add_file(dep, build_output + "/WEB-INF/pgm-lib/")
inputs.append(dep) inputs.append(dep)
@@ -105,7 +105,7 @@ def _war_impl(ctx):
transitive_context_deps += jar.java.transitive_runtime_deps transitive_context_deps += jar.java.transitive_runtime_deps
elif hasattr(jar, "files"): elif hasattr(jar, "files"):
transitive_context_deps += jar.files transitive_context_deps += jar.files
for dep in transitive_context_deps: for dep in transitive_context_deps.to_list():
cmd += _add_context(dep, build_output) cmd += _add_context(dep, build_output)
inputs.append(dep) inputs.append(dep)

View File

@@ -1,5 +1,5 @@
load("//tools/bzl:pkg_war.bzl", "LIBS", "PGMLIBS")
load("//tools/bzl:classpath.bzl", "classpath_collector") load("//tools/bzl:classpath.bzl", "classpath_collector")
load("//tools/bzl:pkg_war.bzl", "LIBS", "PGMLIBS")
load( load(
"//tools/bzl:plugins.bzl", "//tools/bzl:plugins.bzl",
"CORE_PLUGINS", "CORE_PLUGINS",