Format bzl files with buildifier
Change-Id: I2e2a7d832d595f664115f23026ea44baf15ac432
diff --git a/bouncycastle.bzl b/bouncycastle.bzl
index 9f503d0..9c75973 100644
--- a/bouncycastle.bzl
+++ b/bouncycastle.bzl
@@ -8,36 +8,42 @@
BC_VERS = "1.57"
def bouncycastle_repos():
- maven_jar(
- name = "bouncycastle_bcprov",
- artifact = "org.bouncycastle:bcprov-jdk15on:" + BC_VERS,
- sha1 = "f66a135611d42c992e5745788c3f94eb06464537",
- )
- maven_jar(
- name = "bouncycastle_bcpg",
- artifact = "org.bouncycastle:bcpg-jdk15on:" + BC_VERS,
- sha1 = "7b2d587f5e3780b79e1d35af3e84d00634e9420b",
- )
- maven_jar(
- name = "bouncycastle_bcpkix",
- artifact = "org.bouncycastle:bcpkix-jdk15on:" + BC_VERS,
- sha1 = "5c96e34bc9bd4cd6870e6d193a99438f1e274ca7",
- )
- native.bind(
- name = 'bcprov',
- actual = '@bouncycastle_bcprov//jar')
- native.bind(
- name = 'bcprov-neverlink',
- actual = '@bouncycastle_bcprov//jar:neverlink')
- native.bind(
- name = 'bcpg',
- actual = '@bouncycastle_bcpg//jar')
- native.bind(
- name = 'bcpg-neverlink',
- actual = '@bouncycastle_bcpg//jar:neverlink')
- native.bind(
- name = 'bcpkix',
- actual = '@bouncycastle_bcpkix//jar')
- native.bind(
- name = 'bcpkix-neverlink',
- actual = '@bouncycastle_bcpkix//jar:neverlink')
+ maven_jar(
+ name = "bouncycastle_bcprov",
+ artifact = "org.bouncycastle:bcprov-jdk15on:" + BC_VERS,
+ sha1 = "f66a135611d42c992e5745788c3f94eb06464537",
+ )
+ maven_jar(
+ name = "bouncycastle_bcpg",
+ artifact = "org.bouncycastle:bcpg-jdk15on:" + BC_VERS,
+ sha1 = "7b2d587f5e3780b79e1d35af3e84d00634e9420b",
+ )
+ maven_jar(
+ name = "bouncycastle_bcpkix",
+ artifact = "org.bouncycastle:bcpkix-jdk15on:" + BC_VERS,
+ sha1 = "5c96e34bc9bd4cd6870e6d193a99438f1e274ca7",
+ )
+ native.bind(
+ name = "bcprov",
+ actual = "@bouncycastle_bcprov//jar",
+ )
+ native.bind(
+ name = "bcprov-neverlink",
+ actual = "@bouncycastle_bcprov//jar:neverlink",
+ )
+ native.bind(
+ name = "bcpg",
+ actual = "@bouncycastle_bcpg//jar",
+ )
+ native.bind(
+ name = "bcpg-neverlink",
+ actual = "@bouncycastle_bcpg//jar:neverlink",
+ )
+ native.bind(
+ name = "bcpkix",
+ actual = "@bouncycastle_bcpkix//jar",
+ )
+ native.bind(
+ name = "bcpkix-neverlink",
+ actual = "@bouncycastle_bcpkix//jar:neverlink",
+ )
diff --git a/gerrit_api.bzl b/gerrit_api.bzl
index fd72e92..47610a3 100644
--- a/gerrit_api.bzl
+++ b/gerrit_api.bzl
@@ -8,39 +8,45 @@
VER = "2.15.2"
def gerrit_api():
- bouncycastle_repos()
+ bouncycastle_repos()
- maven_jar(
- name = 'gerrit_plugin_api',
- artifact = 'com.google.gerrit:gerrit-plugin-api:' + VER,
- sha1 = '118179c5577e6d6d67a6347694eedc8214d0e44b',
- )
- maven_jar(
- name = 'gerrit_plugin_gwtui',
- artifact = 'com.google.gerrit:gerrit-plugin-gwtui:' + VER,
- sha1 = 'bc1b74ca1cdef78ee0533c853adb3a399682a648',
- exclude = ['com/google/gwt/*'],
- )
- maven_jar(
- name = 'gerrit_acceptance_framework',
- artifact = 'com.google.gerrit:gerrit-acceptance-framework:' + VER,
- sha1 = '5c2dee7b74812cd78c054fc5b933778e5daaf7ed',
- )
- native.bind(
- name = 'gerrit-plugin-api',
- actual = '@gerrit_plugin_api//jar')
- native.bind(
- name = 'gerrit-plugin-gwtui',
- actual = '@gerrit_plugin_gwtui//jar')
- native.bind(
- name = 'gerrit-acceptance-framework',
- actual = '@gerrit_acceptance_framework//jar')
- native.bind(
- name = 'gerrit-plugin-api-neverlink',
- actual = '@gerrit_plugin_api//jar:neverlink')
- native.bind(
- name = 'gerrit-plugin-gwtui-neverlink',
- actual = '@gerrit_plugin_gwtui//jar:neverlink')
- native.bind(
- name = 'gerrit-acceptance-framework-neverlink',
- actual = '@gerrit_acceptance_framework//jar:neverlink')
+ maven_jar(
+ name = "gerrit_plugin_api",
+ artifact = "com.google.gerrit:gerrit-plugin-api:" + VER,
+ sha1 = "118179c5577e6d6d67a6347694eedc8214d0e44b",
+ )
+ maven_jar(
+ name = "gerrit_plugin_gwtui",
+ artifact = "com.google.gerrit:gerrit-plugin-gwtui:" + VER,
+ sha1 = "bc1b74ca1cdef78ee0533c853adb3a399682a648",
+ exclude = ["com/google/gwt/*"],
+ )
+ maven_jar(
+ name = "gerrit_acceptance_framework",
+ artifact = "com.google.gerrit:gerrit-acceptance-framework:" + VER,
+ sha1 = "5c2dee7b74812cd78c054fc5b933778e5daaf7ed",
+ )
+ native.bind(
+ name = "gerrit-plugin-api",
+ actual = "@gerrit_plugin_api//jar",
+ )
+ native.bind(
+ name = "gerrit-plugin-gwtui",
+ actual = "@gerrit_plugin_gwtui//jar",
+ )
+ native.bind(
+ name = "gerrit-acceptance-framework",
+ actual = "@gerrit_acceptance_framework//jar",
+ )
+ native.bind(
+ name = "gerrit-plugin-api-neverlink",
+ actual = "@gerrit_plugin_api//jar:neverlink",
+ )
+ native.bind(
+ name = "gerrit-plugin-gwtui-neverlink",
+ actual = "@gerrit_plugin_gwtui//jar:neverlink",
+ )
+ native.bind(
+ name = "gerrit-acceptance-framework-neverlink",
+ actual = "@gerrit_acceptance_framework//jar:neverlink",
+ )
diff --git a/gerrit_api_maven_local.bzl b/gerrit_api_maven_local.bzl
index c294e0a..e431f69 100644
--- a/gerrit_api_maven_local.bzl
+++ b/gerrit_api_maven_local.bzl
@@ -1,4 +1,4 @@
-load("//tools:maven_jar.bzl", "maven_jar", "MAVEN_LOCAL")
+load("//tools:maven_jar.bzl", "MAVEN_LOCAL", "maven_jar")
load("//:bouncycastle.bzl", "bouncycastle_repos")
"""Bazel rule for building [Gerrit Code Review](https://www.gerritcodereview.com/)
@@ -8,38 +8,44 @@
VER = "2.16-SNAPSHOT"
def gerrit_api_maven_local():
- bouncycastle_repos()
+ bouncycastle_repos()
- maven_jar(
- name = 'gerrit_plugin_api',
- artifact = 'com.google.gerrit:gerrit-plugin-api:' + VER,
- repository = MAVEN_LOCAL,
- )
- maven_jar(
- name = 'gerrit_plugin_gwtui',
- artifact = 'com.google.gerrit:gerrit-plugin-gwtui:' + VER,
- repository = MAVEN_LOCAL,
- )
- maven_jar(
- name = 'gerrit_acceptance_framework',
- artifact = 'com.google.gerrit:gerrit-acceptance-framework:' + VER,
- repository = MAVEN_LOCAL,
- )
- native.bind(
- name = 'gerrit-plugin-api',
- actual = '@gerrit_plugin_api//jar')
- native.bind(
- name = 'gerrit-plugin-gwtui',
- actual = '@gerrit_plugin_gwtui//jar')
- native.bind(
- name = 'gerrit-acceptance-framework',
- actual = '@gerrit_acceptance_framework//jar')
- native.bind(
- name = 'gerrit-plugin-api-neverlink',
- actual = '@gerrit_plugin_api//jar:neverlink')
- native.bind(
- name = 'gerrit-plugin-gwtui-neverlink',
- actual = '@gerrit_plugin_gwtui//jar:neverlink')
- native.bind(
- name = 'gerrit-acceptance-framework-neverlink',
- actual = '@gerrit_acceptance_framework//jar:neverlink')
+ maven_jar(
+ name = "gerrit_plugin_api",
+ artifact = "com.google.gerrit:gerrit-plugin-api:" + VER,
+ repository = MAVEN_LOCAL,
+ )
+ maven_jar(
+ name = "gerrit_plugin_gwtui",
+ artifact = "com.google.gerrit:gerrit-plugin-gwtui:" + VER,
+ repository = MAVEN_LOCAL,
+ )
+ maven_jar(
+ name = "gerrit_acceptance_framework",
+ artifact = "com.google.gerrit:gerrit-acceptance-framework:" + VER,
+ repository = MAVEN_LOCAL,
+ )
+ native.bind(
+ name = "gerrit-plugin-api",
+ actual = "@gerrit_plugin_api//jar",
+ )
+ native.bind(
+ name = "gerrit-plugin-gwtui",
+ actual = "@gerrit_plugin_gwtui//jar",
+ )
+ native.bind(
+ name = "gerrit-acceptance-framework",
+ actual = "@gerrit_acceptance_framework//jar",
+ )
+ native.bind(
+ name = "gerrit-plugin-api-neverlink",
+ actual = "@gerrit_plugin_api//jar:neverlink",
+ )
+ native.bind(
+ name = "gerrit-plugin-gwtui-neverlink",
+ actual = "@gerrit_plugin_gwtui//jar:neverlink",
+ )
+ native.bind(
+ name = "gerrit-acceptance-framework-neverlink",
+ actual = "@gerrit_acceptance_framework//jar:neverlink",
+ )
diff --git a/gerrit_gwt.bzl b/gerrit_gwt.bzl
index 024ef1f..c1980cf 100644
--- a/gerrit_gwt.bzl
+++ b/gerrit_gwt.bzl
@@ -5,140 +5,154 @@
OW2_VER = "5.1"
def gerrit_gwt():
- maven_jar(
- name = 'gwt_user',
- artifact = 'com.google.gwt:gwt-user:' + GWT_VER,
- sha1 = 'a2b9be2c996a658c4e009ba652a9c6a81c88a797',
- attach_source = False,
- )
- maven_jar(
- name = 'gwt_dev',
- artifact = 'com.google.gwt:gwt-dev:' + GWT_VER,
- sha1 = '7a87e060bbf129386b7ae772459fb9f87297c332',
- attach_source = False,
- )
- maven_jar(
- name = 'javax_validation',
- artifact = 'javax.validation:validation-api:1.0.0.GA',
- sha1 = 'b6bd7f9d78f6fdaa3c37dae18a4bd298915f328e',
- src_sha1 = '7a561191db2203550fbfa40d534d4997624cd369',
- )
- maven_jar(
- name = 'jsinterop_annotations',
- artifact = 'com.google.jsinterop:jsinterop-annotations:1.0.2',
- sha1 = 'abd7319f53d018e11108a88f599bd16492448dd2',
- src_sha1 = '33716f8aef043f2f02b78ab4a1acda6cd90a7602',
- )
- maven_jar(
- name = 'findbugs_jsr305',
- artifact = 'com.google.code.findbugs:jsr305:3.0.1',
- sha1 = 'f7be08ec23c21485b9b5a1cf1654c2ec8c58168d',
- attach_source = False,
- )
- maven_jar(
- name = 'ant_artifact',
- artifact = 'ant:ant:1.6.5',
- sha1 = '7d18faf23df1a5c3a43613952e0e8a182664564b',
- src_sha1 = '9e0a847494563f35f9b02846a1c1eb4aa2ee5a9a',
- )
- maven_jar(
- name = 'colt_artifact',
- artifact = 'colt:colt:1.2.0',
- attach_source = False,
- sha1 = '0abc984f3adc760684d49e0f11ddf167ba516d4f',
- )
- maven_jar(
- name = 'tapestry_artifact',
- artifact = 'tapestry:tapestry:4.0.2',
- attach_source = False,
- sha1 = 'e855a807425d522e958cbce8697f21e9d679b1f7',
- )
- maven_jar(
- name = 'w3c_css_sac',
- artifact = 'org.w3c.css:sac:1.3',
- attach_source = False,
- sha1 = 'cdb2dcb4e22b83d6b32b93095f644c3462739e82',
- )
- maven_jar(
- name = 'ow2_asm',
- artifact = 'org.ow2.asm:asm:' + OW2_VER,
- sha1 = '5ef31c4fe953b1fd00b8a88fa1d6820e8785bb45',
- )
- maven_jar(
- name = 'ow2_asm_analysis',
- artifact = 'org.ow2.asm:asm-analysis:' + OW2_VER,
- sha1 = '6d1bf8989fc7901f868bee3863c44f21aa63d110',
- )
- maven_jar(
- name = 'ow2_asm_commons',
- artifact = 'org.ow2.asm:asm-commons:' + OW2_VER,
- sha1 = '25d8a575034dd9cfcb375a39b5334f0ba9c8474e',
- )
- maven_jar(
- name = 'ow2_asm_tree',
- artifact = 'org.ow2.asm:asm-tree:' + OW2_VER,
- sha1 = '87b38c12a0ea645791ead9d3e74ae5268d1d6c34',
- )
- maven_jar(
- name = 'ow2_asm_util',
- artifact = 'org.ow2.asm:asm-util:' + OW2_VER,
- sha1 = 'b60e33a6bd0d71831e0c249816d01e6c1dd90a47',
- )
- native.bind(
- name = 'gwt-user',
- actual = '@gwt_user//jar')
- native.bind(
- name = 'gwt-dev',
- actual = '@gwt_dev//jar')
- native.bind(
- name = 'gwt-user-neverlink',
- actual = '@gwt_user//jar:neverlink')
- native.bind(
- name = 'gwt-dev-neverlink',
- actual = '@gwt_dev//jar:neverlink')
- native.bind(
- name = 'javax-validation',
- actual = '@javax_validation//jar')
- native.bind(
- name = 'javax-validation-src',
- actual = '@javax_validation//src')
- native.bind(
- name = 'jsinterop-annotations',
- actual = '@jsinterop_annotations//jar')
- native.bind(
- name = 'jsinterop-annotations-src',
- actual = '@jsinterop_annotations//src')
- native.bind(
- name = 'jsr305',
- actual = '@findbugs_jsr305//jar')
- native.bind(
- name = 'ant',
- actual = '@ant_artifact//jar')
- native.bind(
- name = 'colt',
- actual = '@colt_artifact//jar')
- native.bind(
- name = 'tapestry',
- actual = '@tapestry_artifact//jar')
- native.bind(
- name = 'w3c-css-sac',
- actual = '@w3c_css_sac//jar')
- native.bind(
- name = 'ow2-asm',
- actual = '@ow2_asm//jar',
- )
- native.bind(
- name = 'ow2-asm-analysis',
- actual = '@ow2_asm_analysis//jar',
- )
- native.bind(
- name = 'ow2-asm-commons',
- actual = '@ow2_asm_commons//jar',
- )
- native.bind(
- name = 'ow2-asm-tree',
- actual = '@ow2_asm_tree//jar',
- )
- native.bind(
- name = 'ow2-asm-util',
- actual = '@ow2_asm_util//jar')
+ maven_jar(
+ name = "gwt_user",
+ artifact = "com.google.gwt:gwt-user:" + GWT_VER,
+ sha1 = "a2b9be2c996a658c4e009ba652a9c6a81c88a797",
+ attach_source = False,
+ )
+ maven_jar(
+ name = "gwt_dev",
+ artifact = "com.google.gwt:gwt-dev:" + GWT_VER,
+ sha1 = "7a87e060bbf129386b7ae772459fb9f87297c332",
+ attach_source = False,
+ )
+ maven_jar(
+ name = "javax_validation",
+ artifact = "javax.validation:validation-api:1.0.0.GA",
+ sha1 = "b6bd7f9d78f6fdaa3c37dae18a4bd298915f328e",
+ src_sha1 = "7a561191db2203550fbfa40d534d4997624cd369",
+ )
+ maven_jar(
+ name = "jsinterop_annotations",
+ artifact = "com.google.jsinterop:jsinterop-annotations:1.0.2",
+ sha1 = "abd7319f53d018e11108a88f599bd16492448dd2",
+ src_sha1 = "33716f8aef043f2f02b78ab4a1acda6cd90a7602",
+ )
+ maven_jar(
+ name = "findbugs_jsr305",
+ artifact = "com.google.code.findbugs:jsr305:3.0.1",
+ sha1 = "f7be08ec23c21485b9b5a1cf1654c2ec8c58168d",
+ attach_source = False,
+ )
+ maven_jar(
+ name = "ant_artifact",
+ artifact = "ant:ant:1.6.5",
+ sha1 = "7d18faf23df1a5c3a43613952e0e8a182664564b",
+ src_sha1 = "9e0a847494563f35f9b02846a1c1eb4aa2ee5a9a",
+ )
+ maven_jar(
+ name = "colt_artifact",
+ artifact = "colt:colt:1.2.0",
+ attach_source = False,
+ sha1 = "0abc984f3adc760684d49e0f11ddf167ba516d4f",
+ )
+ maven_jar(
+ name = "tapestry_artifact",
+ artifact = "tapestry:tapestry:4.0.2",
+ attach_source = False,
+ sha1 = "e855a807425d522e958cbce8697f21e9d679b1f7",
+ )
+ maven_jar(
+ name = "w3c_css_sac",
+ artifact = "org.w3c.css:sac:1.3",
+ attach_source = False,
+ sha1 = "cdb2dcb4e22b83d6b32b93095f644c3462739e82",
+ )
+ maven_jar(
+ name = "ow2_asm",
+ artifact = "org.ow2.asm:asm:" + OW2_VER,
+ sha1 = "5ef31c4fe953b1fd00b8a88fa1d6820e8785bb45",
+ )
+ maven_jar(
+ name = "ow2_asm_analysis",
+ artifact = "org.ow2.asm:asm-analysis:" + OW2_VER,
+ sha1 = "6d1bf8989fc7901f868bee3863c44f21aa63d110",
+ )
+ maven_jar(
+ name = "ow2_asm_commons",
+ artifact = "org.ow2.asm:asm-commons:" + OW2_VER,
+ sha1 = "25d8a575034dd9cfcb375a39b5334f0ba9c8474e",
+ )
+ maven_jar(
+ name = "ow2_asm_tree",
+ artifact = "org.ow2.asm:asm-tree:" + OW2_VER,
+ sha1 = "87b38c12a0ea645791ead9d3e74ae5268d1d6c34",
+ )
+ maven_jar(
+ name = "ow2_asm_util",
+ artifact = "org.ow2.asm:asm-util:" + OW2_VER,
+ sha1 = "b60e33a6bd0d71831e0c249816d01e6c1dd90a47",
+ )
+ native.bind(
+ name = "gwt-user",
+ actual = "@gwt_user//jar",
+ )
+ native.bind(
+ name = "gwt-dev",
+ actual = "@gwt_dev//jar",
+ )
+ native.bind(
+ name = "gwt-user-neverlink",
+ actual = "@gwt_user//jar:neverlink",
+ )
+ native.bind(
+ name = "gwt-dev-neverlink",
+ actual = "@gwt_dev//jar:neverlink",
+ )
+ native.bind(
+ name = "javax-validation",
+ actual = "@javax_validation//jar",
+ )
+ native.bind(
+ name = "javax-validation-src",
+ actual = "@javax_validation//src",
+ )
+ native.bind(
+ name = "jsinterop-annotations",
+ actual = "@jsinterop_annotations//jar",
+ )
+ native.bind(
+ name = "jsinterop-annotations-src",
+ actual = "@jsinterop_annotations//src",
+ )
+ native.bind(
+ name = "jsr305",
+ actual = "@findbugs_jsr305//jar",
+ )
+ native.bind(
+ name = "ant",
+ actual = "@ant_artifact//jar",
+ )
+ native.bind(
+ name = "colt",
+ actual = "@colt_artifact//jar",
+ )
+ native.bind(
+ name = "tapestry",
+ actual = "@tapestry_artifact//jar",
+ )
+ native.bind(
+ name = "w3c-css-sac",
+ actual = "@w3c_css_sac//jar",
+ )
+ native.bind(
+ name = "ow2-asm",
+ actual = "@ow2_asm//jar",
+ )
+ native.bind(
+ name = "ow2-asm-analysis",
+ actual = "@ow2_asm_analysis//jar",
+ )
+ native.bind(
+ name = "ow2-asm-commons",
+ actual = "@ow2_asm_commons//jar",
+ )
+ native.bind(
+ name = "ow2-asm-tree",
+ actual = "@ow2_asm_tree//jar",
+ )
+ native.bind(
+ name = "ow2-asm-util",
+ actual = "@ow2_asm_util//jar",
+ )
diff --git a/gerrit_plugin.bzl b/gerrit_plugin.bzl
index a0b425f..9d8ae27 100644
--- a/gerrit_plugin.bzl
+++ b/gerrit_plugin.bzl
@@ -7,11 +7,11 @@
)
load(
"//tools:gwt.bzl",
+ "GWT_COMPILER_ARGS",
+ "GWT_JVM_ARGS",
"GWT_PLUGIN_DEPS",
"GWT_PLUGIN_DEPS_NEVERLINK",
"GWT_TRANSITIVE_DEPS",
- "GWT_COMPILER_ARGS",
- "GWT_JVM_ARGS",
"gwt_binary",
)
@@ -20,94 +20,95 @@
"""
def gerrit_plugin(
- name,
- deps = [],
- provided_deps = [],
- srcs = [],
- gwt_module = [],
- resources = [],
- manifest_entries = [],
- dir_name = None,
- target_suffix = "",
- **kwargs):
+ name,
+ deps = [],
+ provided_deps = [],
+ srcs = [],
+ gwt_module = [],
+ resources = [],
+ manifest_entries = [],
+ dir_name = None,
+ target_suffix = "",
+ **kwargs):
+ gwt_deps = []
+ static_jars = []
+ if gwt_module:
+ static_jars = [":%s-static" % name]
+ gwt_deps = GWT_PLUGIN_DEPS_NEVERLINK
- gwt_deps = []
- static_jars = []
- if gwt_module:
- static_jars = [':%s-static' % name]
- gwt_deps = GWT_PLUGIN_DEPS_NEVERLINK
+ if not dir_name:
+ dir_name = name
- if not dir_name:
- dir_name = name
-
- native.java_library(
- name = name + '__plugin',
- srcs = srcs,
- resources = resources,
- deps = provided_deps + deps + gwt_deps + PLUGIN_DEPS_NEVERLINK,
- visibility = ['//visibility:public'],
- **kwargs
- )
-
- native.java_binary(
- name = '%s__non_stamped' % name,
- deploy_manifest_lines = manifest_entries + ["Gerrit-ApiType: plugin"],
- main_class = 'Dummy',
- runtime_deps = [
- ':%s__plugin' % name,
- ] + static_jars,
- visibility = ['//visibility:public'],
- )
-
- if gwt_module:
native.java_library(
- name = name + '__gwt_module',
- resources = list(depset(srcs + resources)),
- runtime_deps = deps + GWT_PLUGIN_DEPS,
- visibility = ['//visibility:public'],
+ name = name + "__plugin",
+ srcs = srcs,
+ resources = resources,
+ deps = provided_deps + deps + gwt_deps + PLUGIN_DEPS_NEVERLINK,
+ visibility = ["//visibility:public"],
+ **kwargs
)
+
+ native.java_binary(
+ name = "%s__non_stamped" % name,
+ deploy_manifest_lines = manifest_entries + ["Gerrit-ApiType: plugin"],
+ main_class = "Dummy",
+ runtime_deps = [
+ ":%s__plugin" % name,
+ ] + static_jars,
+ visibility = ["//visibility:public"],
+ )
+
+ if gwt_module:
+ native.java_library(
+ name = name + "__gwt_module",
+ resources = list(depset(srcs + resources)),
+ runtime_deps = deps + GWT_PLUGIN_DEPS,
+ visibility = ["//visibility:public"],
+ )
+ genrule2(
+ name = "%s-static" % name,
+ cmd = " && ".join([
+ "mkdir -p $$TMP/static",
+ "unzip -qd $$TMP/static $(location %s__gwt_application)" % name,
+ "cd $$TMP",
+ "zip -qr $$ROOT/$@ .",
+ ]),
+ tools = [":%s__gwt_application" % name],
+ outs = ["%s-static.jar" % name],
+ )
+ gwt_binary(
+ name = name + "__gwt_application",
+ module = [gwt_module],
+ deps = GWT_PLUGIN_DEPS + GWT_TRANSITIVE_DEPS + [
+ "//external:gwt-dev",
+ "//external:gwt-user",
+ ],
+ module_deps = [":%s__gwt_module" % name],
+ compiler_args = GWT_COMPILER_ARGS,
+ jvm_args = GWT_JVM_ARGS,
+ )
+
+ native.genrule(
+ name = name + "__gen_stamp_info",
+ stamp = 1,
+ cmd = "cat bazel-out/stable-status.txt | grep \"^STABLE_BUILD_%s_LABEL\" | awk '{print $$NF}' > $@" % dir_name.upper(),
+ outs = ["%s__gen_stamp_info.txt" % name],
+ )
+
+ # TODO(davido): Remove manual merge of manifest file when this feature
+ # request is implemented: https://github.com/bazelbuild/bazel/issues/2009
genrule2(
- name = '%s-static' % name,
- cmd = ' && '.join([
- 'mkdir -p $$TMP/static',
- 'unzip -qd $$TMP/static $(location %s__gwt_application)' % name,
- 'cd $$TMP',
- 'zip -qr $$ROOT/$@ .']),
- tools = [':%s__gwt_application' % name],
- outs = ['%s-static.jar' % name],
+ name = name + target_suffix,
+ stamp = 1,
+ srcs = ["%s__non_stamped_deploy.jar" % name],
+ cmd = " && ".join([
+ "GEN_VERSION=$$(cat $(location :%s__gen_stamp_info))" % name,
+ "cd $$TMP",
+ "unzip -q $$ROOT/$<",
+ "echo \"Implementation-Version: $$GEN_VERSION\n$$(cat META-INF/MANIFEST.MF)\" > META-INF/MANIFEST.MF",
+ "zip -qr $$ROOT/$@ .",
+ ]),
+ tools = [":%s__gen_stamp_info" % name],
+ outs = ["%s%s.jar" % (name, target_suffix)],
+ visibility = ["//visibility:public"],
)
- gwt_binary(
- name = name + '__gwt_application',
- module = [gwt_module],
- deps = GWT_PLUGIN_DEPS + GWT_TRANSITIVE_DEPS + [
- '//external:gwt-dev',
- '//external:gwt-user',
- ],
- module_deps = [':%s__gwt_module' % name],
- compiler_args = GWT_COMPILER_ARGS,
- jvm_args = GWT_JVM_ARGS,
- )
-
- native.genrule(
- name = name + "__gen_stamp_info",
- stamp = 1,
- cmd = "cat bazel-out/stable-status.txt | grep \"^STABLE_BUILD_%s_LABEL\" | awk '{print $$NF}' > $@" % dir_name.upper(),
- outs = ["%s__gen_stamp_info.txt" % name],
- )
-
- # TODO(davido): Remove manual merge of manifest file when this feature
- # request is implemented: https://github.com/bazelbuild/bazel/issues/2009
- genrule2(
- name = name + target_suffix,
- stamp = 1,
- srcs = ['%s__non_stamped_deploy.jar' % name],
- cmd = " && ".join([
- "GEN_VERSION=$$(cat $(location :%s__gen_stamp_info))" % name,
- "cd $$TMP",
- "unzip -q $$ROOT/$<",
- "echo \"Implementation-Version: $$GEN_VERSION\n$$(cat META-INF/MANIFEST.MF)\" > META-INF/MANIFEST.MF",
- "zip -qr $$ROOT/$@ ."]),
- tools = [':%s__gen_stamp_info' % name],
- outs = ['%s%s.jar' % (name, target_suffix)],
- visibility = ['//visibility:public'],
- )
diff --git a/lib/prolog/prolog.bzl b/lib/prolog/prolog.bzl
index fe300c4..5d9d3f3 100644
--- a/lib/prolog/prolog.bzl
+++ b/lib/prolog/prolog.bzl
@@ -13,22 +13,22 @@
# limitations under the License.
def prolog_cafe_library(
- name,
- srcs,
- deps = [],
- **kwargs):
- native.genrule(
- name = name + '__pl2j',
- cmd = '$(location @com_googlesource_gerrit_bazlets//lib/prolog:compiler-bin) ' +
- '$$(dirname $@) $@ ' +
- '$(SRCS)',
- srcs = srcs,
- tools = ['@com_googlesource_gerrit_bazlets//lib/prolog:compiler-bin'],
- outs = [ name + '.srcjar' ],
- )
- native.java_library(
- name = name,
- srcs = [':' + name + '__pl2j'],
- deps = ['@prolog-runtime//jar:neverlink'] + deps,
- **kwargs
- )
+ name,
+ srcs,
+ deps = [],
+ **kwargs):
+ native.genrule(
+ name = name + "__pl2j",
+ cmd = "$(location @com_googlesource_gerrit_bazlets//lib/prolog:compiler-bin) " +
+ "$$(dirname $@) $@ " +
+ "$(SRCS)",
+ srcs = srcs,
+ tools = ["@com_googlesource_gerrit_bazlets//lib/prolog:compiler-bin"],
+ outs = [name + ".srcjar"],
+ )
+ native.java_library(
+ name = name,
+ srcs = [":" + name + "__pl2j"],
+ deps = ["@prolog-runtime//jar:neverlink"] + deps,
+ **kwargs
+ )
diff --git a/tools/classpath.bzl b/tools/classpath.bzl
index fa7d9e2..28677c8 100644
--- a/tools/classpath.bzl
+++ b/tools/classpath.bzl
@@ -1,15 +1,17 @@
def _classpath_collector(ctx):
all = depset()
for d in ctx.attr.deps:
- if hasattr(d, 'java'):
+ if hasattr(d, "java"):
all = all + d.java.transitive_runtime_deps
all = all + d.java.compilation_info.runtime_classpath
- elif hasattr(d, 'files'):
+ elif hasattr(d, "files"):
all = all + d.files
as_strs = [c.path for c in all]
- ctx.file_action(output= ctx.outputs.runtime,
- content="\n".join(sorted(as_strs)))
+ ctx.file_action(
+ output = ctx.outputs.runtime,
+ content = "\n".join(sorted(as_strs)),
+ )
classpath_collector = rule(
attrs = {
diff --git a/tools/genrule2.bzl b/tools/genrule2.bzl
index 563a9ef..3113022 100644
--- a/tools/genrule2.bzl
+++ b/tools/genrule2.bzl
@@ -17,11 +17,12 @@
# expose TMP shell variable
def genrule2(cmd, **kwargs):
- cmd = ' && '.join([
- 'ROOT=$$PWD',
- 'TMP=$$(mktemp -d || mktemp -d -t bazel-tmp)',
- '(' + cmd + ')',
- ])
- native.genrule(
- cmd = cmd,
- **kwargs)
+ cmd = " && ".join([
+ "ROOT=$$PWD",
+ "TMP=$$(mktemp -d || mktemp -d -t bazel-tmp)",
+ "(" + cmd + ")",
+ ])
+ native.genrule(
+ cmd = cmd,
+ **kwargs
+ )
diff --git a/tools/gwt.bzl b/tools/gwt.bzl
index 8ca5ec4..1becb54 100644
--- a/tools/gwt.bzl
+++ b/tools/gwt.bzl
@@ -89,115 +89,120 @@
</module>
"""
-def gwt_module(gwt_xml=None, resources=[], srcs=[], **kwargs):
- if gwt_xml:
- resources = resources + [gwt_xml]
+def gwt_module(gwt_xml = None, resources = [], srcs = [], **kwargs):
+ if gwt_xml:
+ resources = resources + [gwt_xml]
- java_library2(
- srcs = srcs,
- resources = resources,
- **kwargs)
+ java_library2(
+ srcs = srcs,
+ resources = resources,
+ **kwargs
+ )
def _gwt_user_agent_module(ctx):
- """Generate user agent specific GWT module."""
- if not ctx.attr.user_agent:
- return None
+ """Generate user agent specific GWT module."""
+ if not ctx.attr.user_agent:
+ return None
- ua = ctx.attr.user_agent
- impl = ua
- if ua in ALIASES:
- impl = ALIASES[ua]
+ ua = ctx.attr.user_agent
+ impl = ua
+ if ua in ALIASES:
+ impl = ALIASES[ua]
- # intermediate artifact: user agent speific GWT xml file
- gwt_user_agent_xml = ctx.new_file(ctx.label.name + "_gwt.xml")
- ctx.file_action(output = gwt_user_agent_xml,
- content=USER_AGENT_XML % (MODULE, impl))
+ # intermediate artifact: user agent speific GWT xml file
+ gwt_user_agent_xml = ctx.new_file(ctx.label.name + "_gwt.xml")
+ ctx.file_action(
+ output = gwt_user_agent_xml,
+ content = USER_AGENT_XML % (MODULE, impl),
+ )
- # intermediate artifact: user agent specific zip with GWT module
- gwt_user_agent_zip = ctx.new_file(ctx.label.name + "_gwt.zip")
- gwt = '%s_%s.gwt.xml' % (MODULE.replace('.', '/'), ua)
- dir = gwt_user_agent_zip.path + ".dir"
- cmd = " && ".join([
- "p=$PWD",
- "mkdir -p %s" % dir,
- "cd %s" % dir,
- "mkdir -p $(dirname %s)" % gwt,
- "cp $p/%s %s" % (gwt_user_agent_xml.path, gwt),
- "$p/%s cC $p/%s $(find . | sed 's|^./||')" % (ctx.executable._zip.path, gwt_user_agent_zip.path)
- ])
- ctx.action(
- inputs = [gwt_user_agent_xml] + ctx.files._zip,
- outputs = [gwt_user_agent_zip],
- command = cmd,
- mnemonic = "GenerateUserAgentGWTModule")
+ # intermediate artifact: user agent specific zip with GWT module
+ gwt_user_agent_zip = ctx.new_file(ctx.label.name + "_gwt.zip")
+ gwt = "%s_%s.gwt.xml" % (MODULE.replace(".", "/"), ua)
+ dir = gwt_user_agent_zip.path + ".dir"
+ cmd = " && ".join([
+ "p=$PWD",
+ "mkdir -p %s" % dir,
+ "cd %s" % dir,
+ "mkdir -p $(dirname %s)" % gwt,
+ "cp $p/%s %s" % (gwt_user_agent_xml.path, gwt),
+ "$p/%s cC $p/%s $(find . | sed 's|^./||')" % (ctx.executable._zip.path, gwt_user_agent_zip.path),
+ ])
+ ctx.action(
+ inputs = [gwt_user_agent_xml] + ctx.files._zip,
+ outputs = [gwt_user_agent_zip],
+ command = cmd,
+ mnemonic = "GenerateUserAgentGWTModule",
+ )
- return struct(
- zip=gwt_user_agent_zip,
- module=MODULE + '_' + ua
- )
+ return struct(
+ zip = gwt_user_agent_zip,
+ module = MODULE + "_" + ua,
+ )
def _gwt_binary_impl(ctx):
- module = ctx.attr.module[0]
- output_zip = ctx.outputs.output
- output_dir = output_zip.path + '.gwt_output'
- deploy_dir = output_zip.path + '.gwt_deploy'
+ module = ctx.attr.module[0]
+ output_zip = ctx.outputs.output
+ output_dir = output_zip.path + ".gwt_output"
+ deploy_dir = output_zip.path + ".gwt_deploy"
- deps = _get_transitive_closure(ctx)
+ deps = _get_transitive_closure(ctx)
- paths = []
- for dep in deps:
- paths.append(dep.path)
+ paths = []
+ for dep in deps:
+ paths.append(dep.path)
- gwt_user_agent_modules = []
- ua = _gwt_user_agent_module(ctx)
- if ua:
- paths.append(ua.zip.path)
- gwt_user_agent_modules.append(ua.zip)
- module = ua.module
+ gwt_user_agent_modules = []
+ ua = _gwt_user_agent_module(ctx)
+ if ua:
+ paths.append(ua.zip.path)
+ gwt_user_agent_modules.append(ua.zip)
+ module = ua.module
- 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,
- )
- # TODO(davido): clean up command concatenation
- cmd = cmd + " ".join([
- "-style %s" % ctx.attr.style,
- "-optimize %s" % ctx.attr.optimize,
- "-strict",
- " ".join(ctx.attr.compiler_args),
- module + "\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,
+ 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,
)
- ])
- ctx.action(
- inputs = list(deps) + ctx.files._jdk + ctx.files._zip + gwt_user_agent_modules,
- outputs = [output_zip],
- mnemonic = "GwtBinary",
- progress_message = "GWT compiling " + output_zip.short_path,
- command = "set -e\n" + cmd,
- )
+ # TODO(davido): clean up command concatenation
+ cmd = cmd + " ".join([
+ "-style %s" % ctx.attr.style,
+ "-optimize %s" % ctx.attr.optimize,
+ "-strict",
+ " ".join(ctx.attr.compiler_args),
+ module + "\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 + gwt_user_agent_modules,
+ outputs = [output_zip],
+ mnemonic = "GwtBinary",
+ progress_message = "GWT compiling " + output_zip.short_path,
+ command = "set -e\n" + cmd,
+ )
def _get_transitive_closure(ctx):
- deps = depset()
- for dep in ctx.attr.module_deps:
- deps = deps + dep.java.transitive_runtime_deps
- deps = deps + dep.java.transitive_source_jars
- for dep in ctx.attr.deps:
- if hasattr(dep, 'java'):
- deps = deps + dep.java.transitive_runtime_deps
- elif hasattr(dep, 'files'):
- deps = deps + dep.files
+ deps = depset()
+ for dep in ctx.attr.module_deps:
+ deps = deps + dep.java.transitive_runtime_deps
+ deps = deps + dep.java.transitive_source_jars
+ for dep in ctx.attr.deps:
+ if hasattr(dep, "java"):
+ deps = deps + dep.java.transitive_runtime_deps
+ elif hasattr(dep, "files"):
+ deps = deps + dep.files
- return deps
+ return deps
gwt_binary = rule(
attrs = {
@@ -226,58 +231,58 @@
)
def gwt_genrule(suffix = ""):
- dbg = 'ui_dbg' + suffix
- opt = 'ui_opt' + suffix
- module_dep = ':ui_module' + suffix
- args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS
+ dbg = "ui_dbg" + suffix
+ opt = "ui_opt" + suffix
+ module_dep = ":ui_module" + suffix
+ args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS
- genrule2(
- name = 'ui_optdbg' + suffix,
- srcs = [
- ':' + dbg,
- ':' + opt,
- ],
- cmd = 'cd $$TMP;' +
- 'unzip -q $$ROOT/$(location :%s);' % dbg +
- 'mv' +
- ' gerrit_ui/gerrit_ui.nocache.js' +
- ' gerrit_ui/dbg_gerrit_ui.nocache.js;' +
- 'unzip -qo $$ROOT/$(location :%s);' % opt +
- 'mkdir -p $$(dirname $@);' +
- 'zip -qr $$ROOT/$@ .',
- outs = ['ui_optdbg' + suffix + '.zip'],
- visibility = ['//visibility:public'],
- )
+ genrule2(
+ name = "ui_optdbg" + suffix,
+ srcs = [
+ ":" + dbg,
+ ":" + opt,
+ ],
+ cmd = "cd $$TMP;" +
+ "unzip -q $$ROOT/$(location :%s);" % dbg +
+ "mv" +
+ " gerrit_ui/gerrit_ui.nocache.js" +
+ " gerrit_ui/dbg_gerrit_ui.nocache.js;" +
+ "unzip -qo $$ROOT/$(location :%s);" % opt +
+ "mkdir -p $$(dirname $@);" +
+ "zip -qr $$ROOT/$@ .",
+ outs = ["ui_optdbg" + suffix + ".zip"],
+ visibility = ["//visibility:public"],
+ )
- gwt_binary(
- name = opt,
- module = [MODULE],
- module_deps = [module_dep],
- deps = DEPS,
- compiler_args = args,
- jvm_args = GWT_JVM_ARGS,
- )
+ gwt_binary(
+ name = opt,
+ module = [MODULE],
+ module_deps = [module_dep],
+ deps = DEPS,
+ compiler_args = args,
+ jvm_args = GWT_JVM_ARGS,
+ )
- gwt_binary(
- name = dbg,
- style = 'PRETTY',
- optimize = "0",
- module_deps = [module_dep],
- deps = DEPS,
- compiler_args = GWT_COMPILER_ARGS,
- jvm_args = GWT_JVM_ARGS,
- )
+ gwt_binary(
+ name = dbg,
+ style = "PRETTY",
+ optimize = "0",
+ module_deps = [module_dep],
+ deps = DEPS,
+ compiler_args = GWT_COMPILER_ARGS,
+ jvm_args = GWT_JVM_ARGS,
+ )
def gwt_user_agent_permutations():
- for ua in BROWSERS:
- gwt_binary(
- name = "ui_%s" % ua,
- user_agent = ua,
- style = 'PRETTY',
- optimize = "0",
- module = [MODULE],
- module_deps = [':ui_module'],
- deps = DEPS,
- compiler_args = GWT_COMPILER_ARGS,
- jvm_args = GWT_JVM_ARGS,
- )
+ for ua in BROWSERS:
+ gwt_binary(
+ name = "ui_%s" % ua,
+ user_agent = ua,
+ style = "PRETTY",
+ optimize = "0",
+ module = [MODULE],
+ module_deps = [":ui_module"],
+ deps = DEPS,
+ compiler_args = GWT_COMPILER_ARGS,
+ jvm_args = GWT_JVM_ARGS,
+ )
diff --git a/tools/java.bzl b/tools/java.bzl
index 5fca724..7c41fbe 100644
--- a/tools/java.bzl
+++ b/tools/java.bzl
@@ -15,11 +15,12 @@
# Syntactic sugar for native java_library() rule:
# accept exported_deps attributes
-def java_library2(deps=[], exported_deps=[], exports=[], **kwargs):
- if exported_deps:
- deps = deps + exported_deps
- exports = exports + exported_deps
- native.java_library(
- deps = deps,
- exports = exports,
- **kwargs)
+def java_library2(deps = [], exported_deps = [], exports = [], **kwargs):
+ if exported_deps:
+ deps = deps + exported_deps
+ exports = exports + exported_deps
+ native.java_library(
+ deps = deps,
+ exports = exports,
+ **kwargs
+ )
diff --git a/tools/javadoc.bzl b/tools/javadoc.bzl
index 3a1ee49..43346ba 100644
--- a/tools/javadoc.bzl
+++ b/tools/javadoc.bzl
@@ -15,47 +15,49 @@
# Javadoc rule.
def _impl(ctx):
- zip_output = ctx.outputs.zip
+ zip_output = ctx.outputs.zip
- transitive_jar_set = depset()
- source_jars = depset()
- for l in ctx.attr.libs:
- source_jars = source_jars + l.java.source_jars
- transitive_jar_set = transitive_jar_set + l.java.transitive_deps
+ transitive_jar_set = depset()
+ source_jars = depset()
+ for l in ctx.attr.libs:
+ source_jars = source_jars + l.java.source_jars
+ transitive_jar_set = 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"
- external_docs = ["http://docs.oracle.com/javase/8/docs/api"] + ctx.attr.external_docs
- cmd = [
- "rm -rf %s" % source,
- "mkdir %s" % source,
- " && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars]),
- "rm -rf %s" % dir,
- "mkdir %s" % dir,
- " ".join([
- ctx.file._javadoc.path,
- "-Xdoclint:-missing",
- "-protected",
- "-encoding UTF-8",
- "-charset UTF-8",
- "-notimestamp",
- "-quiet",
- "-windowtitle '%s'" % ctx.attr.title,
- " ".join(['-link %s' % url for url in external_docs]),
- "-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))
+ transitive_jar_paths = [j.path for j in transitive_jar_set]
+ dir = ctx.outputs.zip.path + ".dir"
+ source = ctx.outputs.zip.path + ".source"
+ external_docs = ["http://docs.oracle.com/javase/8/docs/api"] + ctx.attr.external_docs
+ cmd = [
+ "rm -rf %s" % source,
+ "mkdir %s" % source,
+ " && ".join(["unzip -qud %s %s" % (source, j.path) for j in source_jars]),
+ "rm -rf %s" % dir,
+ "mkdir %s" % dir,
+ " ".join([
+ ctx.file._javadoc.path,
+ "-Xdoclint:-missing",
+ "-protected",
+ "-encoding UTF-8",
+ "-charset UTF-8",
+ "-notimestamp",
+ "-quiet",
+ "-windowtitle '%s'" % ctx.attr.title,
+ " ".join(["-link %s" % url for url in external_docs]),
+ "-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 = {
diff --git a/tools/junit.bzl b/tools/junit.bzl
index c820d10..6d3fa1a 100644
--- a/tools/junit.bzl
+++ b/tools/junit.bzl
@@ -43,15 +43,21 @@
if findex != -1:
break
if findex == -1:
- fail("%s does not contain any of %s",
- fname, _PREFIXES)
+ fail(
+ "%s does not contain any of %s",
+ fname,
+ _PREFIXES,
+ )
return ".".join(toks[findex:]) + ".class"
def _impl(ctx):
classes = ",".join(
- [_AsClassName(x) for x in ctx.attr.srcs])
- ctx.file_action(output=ctx.outputs.out, content=_OUTPUT % (
- classes, ctx.attr.outname))
+ [_AsClassName(x) for x in ctx.attr.srcs],
+ )
+ ctx.file_action(output = ctx.outputs.out, content = _OUTPUT % (
+ classes,
+ ctx.attr.outname,
+ ))
_GenSuite = rule(
attrs = {
@@ -64,10 +70,14 @@
def junit_tests(name, srcs, **kwargs):
s_name = name.replace("-", "_") + "TestSuite"
- _GenSuite(name = s_name,
- srcs = srcs,
- outname = s_name)
- native.java_test(name = name,
- test_class = s_name,
- srcs = srcs + [":"+s_name],
- **kwargs)
+ _GenSuite(
+ name = s_name,
+ srcs = srcs,
+ outname = s_name,
+ )
+ native.java_test(
+ name = name,
+ test_class = s_name,
+ srcs = srcs + [":" + s_name],
+ **kwargs
+ )
diff --git a/tools/maven/package.bzl b/tools/maven/package.bzl
index 39d9b4e..06feecd 100644
--- a/tools/maven/package.bzl
+++ b/tools/maven/package.bzl
@@ -24,49 +24,58 @@
]))
def maven_package(
- version,
- group,
- repository = None,
- url = None,
- jar = {},
- src = {},
- doc = {}):
+ version,
+ group,
+ repository = None,
+ url = None,
+ jar = {},
+ src = {},
+ doc = {}):
+ build_cmd = ["bazel", "build"]
+ mvn_cmd = [
+ "$(location @com_googlesource_gerrit_bazlets//tools/maven:mvn.py)",
+ "-v",
+ version,
+ "-g",
+ group,
+ "-r",
+ ".",
+ ]
+ api_cmd = mvn_cmd[:]
+ api_targets = []
+ for type, d in [("jar", jar), ("java-source", src), ("javadoc", doc)]:
+ for a, t in sorted(d.items()):
+ api_cmd.append("-s %s:%s:$(location %s)" % (a, type, t))
+ api_targets.append(t)
- build_cmd = ['bazel', 'build']
- mvn_cmd = [
- '$(location @com_googlesource_gerrit_bazlets//tools/maven:mvn.py)',
- '-v', version,
- '-g', group,
- '-r', '.',
- ]
- api_cmd = mvn_cmd[:]
- api_targets = []
- for type,d in [('jar', jar), ('java-source', src), ('javadoc', doc)]:
- for a,t in sorted(d.items()):
- api_cmd.append('-s %s:%s:$(location %s)' % (a,type,t))
- api_targets.append(t)
-
- native.genrule(
- name = 'gen_api_install',
- cmd = sh_bang_template % (
- ' '.join(build_cmd + api_targets),
- ' '.join(api_cmd + ['-a', 'install'])),
- srcs = api_targets + ["@com_googlesource_gerrit_bazlets//tools/maven:mvn.py"],
- outs = ['api_install.sh'],
- executable = True,
- testonly = 1,
- )
-
- if repository and url:
native.genrule(
- name = 'gen_api_deploy',
- cmd = sh_bang_template % (
- ' '.join(build_cmd + api_targets),
- ' '.join(api_cmd + ['-a', 'deploy',
- '--repository', repository,
- '--url', url])),
- srcs = api_targets + ["@com_googlesource_gerrit_bazlets//tools/maven:mvn.py"],
- outs = ['api_deploy.sh'],
- executable = True,
- testonly = 1,
+ name = "gen_api_install",
+ cmd = sh_bang_template % (
+ " ".join(build_cmd + api_targets),
+ " ".join(api_cmd + ["-a", "install"]),
+ ),
+ srcs = api_targets + ["@com_googlesource_gerrit_bazlets//tools/maven:mvn.py"],
+ outs = ["api_install.sh"],
+ executable = True,
+ testonly = 1,
)
+
+ if repository and url:
+ native.genrule(
+ name = "gen_api_deploy",
+ cmd = sh_bang_template % (
+ " ".join(build_cmd + api_targets),
+ " ".join(api_cmd + [
+ "-a",
+ "deploy",
+ "--repository",
+ repository,
+ "--url",
+ url,
+ ]),
+ ),
+ srcs = api_targets + ["@com_googlesource_gerrit_bazlets//tools/maven:mvn.py"],
+ outs = ["api_deploy.sh"],
+ executable = True,
+ testonly = 1,
+ )
diff --git a/tools/maven_jar.bzl b/tools/maven_jar.bzl
index 8947893..240abc8 100644
--- a/tools/maven_jar.bzl
+++ b/tools/maven_jar.bzl
@@ -24,67 +24,68 @@
MAVEN_LOCAL = "MAVEN_LOCAL:"
def _maven_release(ctx, parts):
- """induce jar and url name from maven coordinates."""
- if len(parts) not in [3, 4]:
- fail('%s:\nexpected id="groupId:artifactId:version[:classifier]"'
- % ctx.attr.artifact)
- if len(parts) == 4:
- group, artifact, version, classifier = parts
- file_version = version + '-' + classifier
- else:
- group, artifact, version = parts
- file_version = version
+ """induce jar and url name from maven coordinates."""
+ if len(parts) not in [3, 4]:
+ fail('%s:\nexpected id="groupId:artifactId:version[:classifier]"' %
+ ctx.attr.artifact)
+ if len(parts) == 4:
+ group, artifact, version, classifier = parts
+ file_version = version + "-" + classifier
+ else:
+ group, artifact, version = parts
+ file_version = version
- jar = artifact.lower() + '-' + file_version
- url = '/'.join([
- ctx.attr.repository,
- group.replace('.', '/'),
- artifact,
- version,
- artifact + '-' + file_version])
+ jar = artifact.lower() + "-" + file_version
+ url = "/".join([
+ ctx.attr.repository,
+ group.replace(".", "/"),
+ artifact,
+ version,
+ artifact + "-" + file_version,
+ ])
- return jar, url
+ return jar, url
# Creates a struct containing the different parts of an artifact's FQN
def _create_coordinates(fully_qualified_name):
- parts = fully_qualified_name.split(":")
- packaging = None
- classifier = None
+ parts = fully_qualified_name.split(":")
+ packaging = None
+ classifier = None
- if len(parts) == 3:
- group_id, artifact_id, version = parts
- elif len(parts) == 4:
- group_id, artifact_id, version, packaging = parts
- elif len(parts) == 5:
- group_id, artifact_id, version, packaging, classifier = parts
- else:
- fail("Invalid fully qualified name for artifact: %s" % fully_qualified_name)
+ if len(parts) == 3:
+ group_id, artifact_id, version = parts
+ elif len(parts) == 4:
+ group_id, artifact_id, version, packaging = parts
+ elif len(parts) == 5:
+ group_id, artifact_id, version, packaging, classifier = parts
+ else:
+ fail("Invalid fully qualified name for artifact: %s" % fully_qualified_name)
- return struct(
- fully_qualified_name = fully_qualified_name,
- group_id = group_id,
- artifact_id = artifact_id,
- packaging = packaging,
- classifier = classifier,
- version = version,
- )
+ return struct(
+ fully_qualified_name = fully_qualified_name,
+ group_id = group_id,
+ artifact_id = artifact_id,
+ packaging = packaging,
+ classifier = classifier,
+ version = version,
+ )
def _format_deps(attr, deps):
- formatted_deps = ""
- if deps:
- if len(deps) == 1:
- formatted_deps = formatted_deps + "%s = [\'%s\']," % (attr, deps[0])
- else:
- formatted_deps = formatted_deps + "%s = [\n" % attr
- for dep in deps:
- formatted_deps = formatted_deps + " \'%s\',\n" % dep
- formatted_deps = formatted_deps + " ],"
- return formatted_deps
+ formatted_deps = ""
+ if deps:
+ if len(deps) == 1:
+ formatted_deps = formatted_deps + "%s = [\'%s\']," % (attr, deps[0])
+ else:
+ formatted_deps = formatted_deps + "%s = [\n" % attr
+ for dep in deps:
+ formatted_deps = formatted_deps + " \'%s\',\n" % dep
+ formatted_deps = formatted_deps + " ],"
+ return formatted_deps
# Provides the syntax "@jar_name//jar" for bin classifier
# and "@jar_name//src" for sources
def _generate_build_file(ctx, classifier, filename):
- contents = """
+ contents = """
# DO NOT EDIT: automatically generated BUILD file for maven_jar rule {rule_name}
java_import(
name = '{classifier}',
@@ -105,56 +106,59 @@
name = 'file',
srcs = ['{filename}'],
visibility = ['//visibility:public']
-)\n""".format(classifier = classifier,
- rule_name = ctx.name,
- filename = filename,
- deps = _format_deps("deps", ctx.attr.deps),
- exports = _format_deps("exports", ctx.attr.exports))
- ctx.file('%s/BUILD' % ctx.path(classifier), contents, False)
+)\n""".format(
+ classifier = classifier,
+ rule_name = ctx.name,
+ filename = filename,
+ deps = _format_deps("deps", ctx.attr.deps),
+ exports = _format_deps("exports", ctx.attr.exports),
+ )
+ ctx.file("%s/BUILD" % ctx.path(classifier), contents, False)
def _maven_jar_impl(ctx):
- """rule to download a Maven archive."""
- coordinates = _create_coordinates(ctx.attr.artifact)
+ """rule to download a Maven archive."""
+ coordinates = _create_coordinates(ctx.attr.artifact)
- name = ctx.name
+ name = ctx.name
- parts = ctx.attr.artifact.split(':')
- # TODO(davido): Only releases for now, implement handling snapshots
- jar, url = _maven_release(ctx, parts)
+ parts = ctx.attr.artifact.split(":")
- binjar = jar + '.jar'
- binjar_path = ctx.path('/'.join(['jar', binjar]))
- binurl = url + '.jar'
+ # TODO(davido): Only releases for now, implement handling snapshots
+ jar, url = _maven_release(ctx, parts)
- srcjar = jar + '-src.jar'
- srcjar_path = ctx.path('/'.join(['src', srcjar]))
- srcurl = url + '-sources.jar'
+ binjar = jar + ".jar"
+ binjar_path = ctx.path("/".join(["jar", binjar]))
+ binurl = url + ".jar"
- python = ctx.which("python")
- script = ctx.path(ctx.attr._download_script)
+ srcjar = jar + "-src.jar"
+ srcjar_path = ctx.path("/".join(["src", srcjar]))
+ srcurl = url + "-sources.jar"
- args = [python, script, "-o", binjar_path, "-u", binurl]
- if ctx.attr.sha1:
- args.extend(['-v', ctx.attr.sha1])
- if ctx.attr.unsign:
- args.append('--unsign')
- for x in ctx.attr.exclude:
- args.extend(['-x', x])
+ python = ctx.which("python")
+ script = ctx.path(ctx.attr._download_script)
- out = ctx.execute(args)
+ args = [python, script, "-o", binjar_path, "-u", binurl]
+ if ctx.attr.sha1:
+ args.extend(["-v", ctx.attr.sha1])
+ if ctx.attr.unsign:
+ args.append("--unsign")
+ for x in ctx.attr.exclude:
+ args.extend(["-x", x])
- if out.return_code:
- fail("failed %s: %s" % (' '.join(args), out.stderr))
- _generate_build_file(ctx, "jar", binjar)
-
- if ctx.attr.src_sha1 or ctx.attr.attach_source:
- args = [python, script, "-o", srcjar_path, "-u", srcurl]
- if ctx.attr.src_sha1:
- args.extend(['-v', ctx.attr.src_sha1])
out = ctx.execute(args)
+
if out.return_code:
- fail("failed %s: %s" % (args, out.stderr))
- _generate_build_file(ctx, "src", srcjar)
+ fail("failed %s: %s" % (" ".join(args), out.stderr))
+ _generate_build_file(ctx, "jar", binjar)
+
+ if ctx.attr.src_sha1 or ctx.attr.attach_source:
+ args = [python, script, "-o", srcjar_path, "-u", srcurl]
+ if ctx.attr.src_sha1:
+ args.extend(["-v", ctx.attr.src_sha1])
+ out = ctx.execute(args)
+ if out.return_code:
+ fail("failed %s: %s" % (args, out.stderr))
+ _generate_build_file(ctx, "src", srcjar)
maven_jar = repository_rule(
attrs = {
diff --git a/tools/pkg_war.bzl b/tools/pkg_war.bzl
index 171173f..6a5a4f7 100644
--- a/tools/pkg_war.bzl
+++ b/tools/pkg_war.bzl
@@ -17,82 +17,82 @@
jar_filetype = FileType([".jar"])
def _add_context(in_file, output):
- input_path = in_file.path
- return [
- 'unzip -qd %s %s' % (output, input_path)
- ]
+ input_path = in_file.path
+ return [
+ "unzip -qd %s %s" % (output, input_path),
+ ]
def _add_file(name, in_file, output):
- output_path = output
- input_path = in_file.path
- short_path = in_file.short_path
- n = in_file.basename
+ output_path = output
+ input_path = in_file.path
+ short_path = in_file.short_path
+ n = in_file.basename
- if n != 'web.xml' and short_path.startswith('%s-' % name):
- n = short_path.split('/')[0] + '-' + n
+ if n != "web.xml" and short_path.startswith("%s-" % name):
+ n = short_path.split("/")[0] + "-" + n
- output_path = output_path + n
+ output_path = output_path + n
- return [
- 'test -L %s || ln -s $(pwd)/%s %s' % (output_path, input_path, output_path)
- ]
+ return [
+ "test -L %s || ln -s $(pwd)/%s %s" % (output_path, input_path, output_path),
+ ]
def _make_war(input_dir, output):
- return '(%s)' % ' && '.join([
- 'root=$(pwd)',
- 'cd %s' % input_dir,
- "find . -exec touch -t 198001010000 '{}' ';' 2> /dev/null",
- 'zip -9qr ${root}/%s .' % (output.path),
- ])
+ return "(%s)" % " && ".join([
+ "root=$(pwd)",
+ "cd %s" % input_dir,
+ "find . -exec touch -t 198001010000 '{}' ';' 2> /dev/null",
+ "zip -9qr ${root}/%s ." % (output.path),
+ ])
def _war_impl(ctx):
- war = ctx.outputs.war
- build_output = war.path + '.build_output'
- inputs = []
+ war = ctx.outputs.war
+ build_output = war.path + ".build_output"
+ inputs = []
- cmd = [
- 'set -e;rm -rf ' + build_output,
- 'mkdir -p ' + build_output,
- 'mkdir -p %s/WEB-INF/lib' % build_output,
- ]
+ cmd = [
+ "set -e;rm -rf " + build_output,
+ "mkdir -p " + build_output,
+ "mkdir -p %s/WEB-INF/lib" % build_output,
+ ]
- transitive_lib_deps = depset()
- for l in ctx.attr.libs:
- if hasattr(l, 'java'):
- transitive_lib_deps = transitive_lib_deps + l.java.transitive_runtime_deps
- elif hasattr(l, 'files'):
- transitive_lib_deps = transitive_lib_deps + l.files
+ transitive_lib_deps = depset()
+ for l in ctx.attr.libs:
+ if hasattr(l, "java"):
+ transitive_lib_deps = transitive_lib_deps + l.java.transitive_runtime_deps
+ elif hasattr(l, "files"):
+ transitive_lib_deps = transitive_lib_deps + l.files
- for dep in transitive_lib_deps:
- cmd = cmd + _add_file(ctx.attr.name, dep, build_output + '/WEB-INF/lib/')
- inputs.append(dep)
+ for dep in transitive_lib_deps:
+ cmd = cmd + _add_file(ctx.attr.name, dep, build_output + "/WEB-INF/lib/")
+ inputs.append(dep)
- if ctx.attr.web_xml:
- for web_xml in ctx.attr.web_xml.files:
- inputs.append(web_xml)
- cmd = cmd + _add_file(ctx.attr.name, web_xml, build_output + '/WEB-INF/')
+ if ctx.attr.web_xml:
+ for web_xml in ctx.attr.web_xml.files:
+ inputs.append(web_xml)
+ cmd = cmd + _add_file(ctx.attr.name, web_xml, build_output + "/WEB-INF/")
- transitive_context_deps = depset()
- if ctx.attr.context:
- for jar in ctx.attr.context:
- if hasattr(jar, 'java'):
- transitive_context_deps = transitive_context_deps + jar.java.transitive_runtime_deps
- elif hasattr(jar, 'files'):
- transitive_context_deps = transitive_context_deps + jar.files
- for dep in transitive_context_deps:
- cmd = cmd + _add_context(dep, build_output)
- inputs.append(dep)
+ transitive_context_deps = depset()
+ if ctx.attr.context:
+ for jar in ctx.attr.context:
+ if hasattr(jar, "java"):
+ transitive_context_deps = transitive_context_deps + jar.java.transitive_runtime_deps
+ elif hasattr(jar, "files"):
+ transitive_context_deps = transitive_context_deps + jar.files
+ for dep in transitive_context_deps:
+ cmd = cmd + _add_context(dep, build_output)
+ inputs.append(dep)
- # Add zip war
- cmd.append(_make_war(build_output, war))
+ # 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,
- )
+ ctx.action(
+ inputs = inputs,
+ outputs = [war],
+ mnemonic = "WAR",
+ command = "\n".join(cmd),
+ use_default_shell_env = True,
+ )
# context: go to the root directory
# libs: go to the WEB-INF/lib directory
@@ -108,8 +108,8 @@
)
def pkg_war(name, context = [], **kwargs):
- _pkg_war(
- name = name,
- context = context,
- **kwargs
- )
+ _pkg_war(
+ name = name,
+ context = context,
+ **kwargs
+ )
diff --git a/tools/py_binary_path.bzl b/tools/py_binary_path.bzl
index 8b7384e..70c367b 100644
--- a/tools/py_binary_path.bzl
+++ b/tools/py_binary_path.bzl
@@ -13,12 +13,12 @@
# limitations under the License.
def _py_binary_path_impl(ctx):
- """rule to retrieve python script location."""
- content = ""
- for f in ctx.attr.py_binary_label.py.transitive_sources:
- if ctx.attr.name in f.path:
- content = content + f.path
- ctx.file_action(output = ctx.outputs.output, content=content)
+ """rule to retrieve python script location."""
+ content = ""
+ for f in ctx.attr.py_binary_label.py.transitive_sources:
+ if ctx.attr.name in f.path:
+ content = content + f.path
+ ctx.file_action(output = ctx.outputs.output, content = content)
py_binary_path = rule(
attrs = {