From dcb8b824b2beae3fec7fdd8f200f463f93ade7e5 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Fri, 6 Sep 2019 18:47:25 +0200 Subject: [PATCH 1/4] Rename left over Buck prolog compiler class to Bazel Change-Id: I8bac9813d5173cb85e059130fd5e5dcf9da17ebf --- lib/prolog/BUILD | 4 ++-- .../{BuckPrologCompiler.java => BazelPrologCompiler.java} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename lib/prolog/java/{BuckPrologCompiler.java => BazelPrologCompiler.java} (98%) diff --git a/lib/prolog/BUILD b/lib/prolog/BUILD index 6ae443469c..fa556829e3 100644 --- a/lib/prolog/BUILD +++ b/lib/prolog/BUILD @@ -44,14 +44,14 @@ java_library( java_binary( name = "compiler-bin", - main_class = "BuckPrologCompiler", + main_class = "BazelPrologCompiler", visibility = ["//visibility:public"], runtime_deps = [":compiler-lib"], ) java_library( name = "compiler-lib", - srcs = ["java/BuckPrologCompiler.java"], + srcs = ["java/BazelPrologCompiler.java"], visibility = ["//visibility:public"], deps = [ ":compiler", diff --git a/lib/prolog/java/BuckPrologCompiler.java b/lib/prolog/java/BazelPrologCompiler.java similarity index 98% rename from lib/prolog/java/BuckPrologCompiler.java rename to lib/prolog/java/BazelPrologCompiler.java index cc3e39e603..37ea6960bb 100644 --- a/lib/prolog/java/BuckPrologCompiler.java +++ b/lib/prolog/java/BazelPrologCompiler.java @@ -21,7 +21,7 @@ import java.nio.file.Files; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; -public class BuckPrologCompiler { +public class BazelPrologCompiler { private static File tmpdir; public static void main(String[] argv) throws IOException, CompileException { From 09c905ef161ec7cfefc2dd5d7bef24049c12504e Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Mon, 9 Sep 2019 20:53:31 +0200 Subject: [PATCH 2/4] Bazel: Add fixes for --incompatible_disallow_legacy_java_provider MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some places the old style, string-indexed Starlark ‘java’ provider was already replaced with new style javaInfo in: I1d5afb8b022. But some other places were missed to be replaced. Change-Id: Ie5ee9eed689793f532f99aeaa38f12ec87a709e1 --- tools/bzl/classpath.bzl | 6 +++--- tools/bzl/gwt.bzl | 8 ++++---- tools/bzl/javadoc.bzl | 7 +++++-- tools/bzl/pkg_war.bzl | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/bzl/classpath.bzl b/tools/bzl/classpath.bzl index 55479c50c7..682ee3c42a 100644 --- a/tools/bzl/classpath.bzl +++ b/tools/bzl/classpath.bzl @@ -1,9 +1,9 @@ def _classpath_collector(ctx): all = [] for d in ctx.attr.deps: - if hasattr(d, "java"): - all.append(d.java.transitive_runtime_deps) - all.append(d.java.compilation_info.runtime_classpath) + if JavaInfo in d: + all.append(d[JavaInfo].transitive_runtime_deps) + all.append(d[JavaInfo].compilation_info.runtime_classpath) elif hasattr(d, "files"): all.append(d.files) diff --git a/tools/bzl/gwt.bzl b/tools/bzl/gwt.bzl index 4cfc99e614..c13d927a3b 100644 --- a/tools/bzl/gwt.bzl +++ b/tools/bzl/gwt.bzl @@ -198,11 +198,11 @@ def _gwt_binary_impl(ctx): def _get_transitive_closure(ctx): deps = [] for dep in ctx.attr.module_deps: - deps.append(dep.java.transitive_runtime_deps) - deps.append(dep.java.transitive_source_jars) + deps.append(dep[JavaInfo].transitive_runtime_deps) + deps.append(dep[JavaInfo].transitive_source_jars) for dep in ctx.attr.deps: - if hasattr(dep, "java"): - deps.append(dep.java.transitive_runtime_deps) + if JavaInfo in dep: + deps.append(dep[JavaInfo].transitive_runtime_deps) elif hasattr(dep, "files"): deps.append(dep.files) diff --git a/tools/bzl/javadoc.bzl b/tools/bzl/javadoc.bzl index 754bd961cf..77c2d4adc0 100644 --- a/tools/bzl/javadoc.bzl +++ b/tools/bzl/javadoc.bzl @@ -17,8 +17,11 @@ def _impl(ctx): zip_output = ctx.outputs.zip - transitive_jars = depset(transitive = [j.java.transitive_deps for j in ctx.attr.libs]) - source_jars = depset(transitive = [j.java.source_jars for j in ctx.attr.libs]) + transitive_jars = depset(transitive = [j[JavaInfo].transitive_deps for j in ctx.attr.libs]) + + # TODO(davido): Remove list to depset conversion on source_jars, when this issue is fixed: + # https://github.com/bazelbuild/bazel/issues/4221 + source_jars = depset(transitive = [depset(j[JavaInfo].source_jars) for j in ctx.attr.libs]) transitive_jar_paths = [j.path for j in transitive_jars.to_list()] dir = ctx.outputs.zip.path + ".dir" diff --git a/tools/bzl/pkg_war.bzl b/tools/bzl/pkg_war.bzl index 64970faf34..140f8e346a 100644 --- a/tools/bzl/pkg_war.bzl +++ b/tools/bzl/pkg_war.bzl @@ -102,8 +102,8 @@ def _war_impl(ctx): transitive_context_libs = [] if ctx.attr.context: for jar in ctx.attr.context: - if hasattr(jar, "java"): - transitive_context_libs.append(jar.java.transitive_runtime_deps) + if JavaInfo in jar: + transitive_context_libs.append(jar[JavaInfo].transitive_runtime_deps) elif hasattr(jar, "files"): transitive_context_libs.append(jar.files) From 4ef157dde6f45f040c7a182955606d0a84844095 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Wed, 4 Sep 2019 08:40:36 +0200 Subject: [PATCH 3/4] Bazel: Reuse version from .bazelversion for minimum used version check Bazel is still supported in addition to the Bazel wrapper Bazelisk, that is recommended, as it would automatically switch to the right Bazel version on stable branches (like it was the case with Buck). That why minimum used Bazel version check is still needed in WORKSPACE file in addition to the .bazelversion used by Bazelisk. That means that currently, bazel version is maintained in two places: * .bazelversion * WORKSPACE This change introduces the repository rule to read the bazel version from the .bazelversion file and perform the minimum version check. When all Gerrit users and developers switched to using Bazelisk, we might consider to remove the check altogether. Inspired-By: Yannic Bonenberger Change-Id: I2fb8b2e5524be501571a0d2418f4676c8fb484ae --- WORKSPACE | 9 +++++++-- tools/bzl/bazelisk_version.bzl | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tools/bzl/bazelisk_version.bzl diff --git a/WORKSPACE b/WORKSPACE index 311fca6d57..d4773738dd 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -63,9 +63,14 @@ http_file( urls = ["https://raw.githubusercontent.com/google/closure-compiler/775609aad61e14aef289ebec4bfc09ad88877f9e/contrib/externs/polymer-1.0.js"], ) -load("@bazel_skylib//lib:versions.bzl", "versions") +# Check Bazel version when invoked by Bazel directly +load("//tools/bzl:bazelisk_version.bzl", "bazelisk_version") -versions.check(minimum_bazel_version = "0.29.0") +bazelisk_version(name = "bazelisk_version") + +load("@bazelisk_version//:check.bzl", "check_bazel_version") + +check_bazel_version() # Rules Python http_archive( diff --git a/tools/bzl/bazelisk_version.bzl b/tools/bzl/bazelisk_version.bzl new file mode 100644 index 0000000000..d8b3d10982 --- /dev/null +++ b/tools/bzl/bazelisk_version.bzl @@ -0,0 +1,16 @@ +_template = """ +load("@bazel_skylib//lib:versions.bzl", "versions") + +def check_bazel_version(): + versions.check(minimum_bazel_version = "{version}") +""".strip() + +def _impl(repository_ctx): + repository_ctx.symlink(Label("@//:.bazelversion"), ".bazelversion") + bazelversion = repository_ctx.read(".bazelversion").strip() + + repository_ctx.file("BUILD", executable = False) + + repository_ctx.file("check.bzl", executable = False, content = _template.format(version = bazelversion)) + +bazelisk_version = repository_rule(implementation = _impl) From 828291df252290722169fd223b1ce0721bc6ffbc Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Tue, 10 Sep 2019 08:31:31 +0900 Subject: [PATCH 4/4] Upgrade testcontainers to 1.12.1 Change-Id: I2dbd960efdd59e27fc212cc11193094e266189ad --- WORKSPACE | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index e87c429bd9..2d0d1acaa7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -952,18 +952,18 @@ maven_jar( sha1 = "0f5a654e4675769c716e5b387830d19b501ca191", ) -TESTCONTAINERS_VERSION = "1.12.0" +TESTCONTAINERS_VERSION = "1.12.1" maven_jar( name = "testcontainers", artifact = "org.testcontainers:testcontainers:" + TESTCONTAINERS_VERSION, - sha1 = "ac89643ce1ddde504da09172086aba0c7df10bff", + sha1 = "1dc8666ead914c5515d087f75ffe92629414caf6", ) maven_jar( name = "testcontainers-elasticsearch", artifact = "org.testcontainers:elasticsearch:" + TESTCONTAINERS_VERSION, - sha1 = "cd9020f1803396c45ef935312bf232f9b17332b0", + sha1 = "2491f792627a1f15d341bfcd6dd0ea7e3541d82f", ) maven_jar(