diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8e22aa443..5d9d0f23f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-20.04] - bazel_version: [5.0.0, 6.3.2] + bazel_version: [6.3.2, 7.0.0] steps: - uses: actions/checkout@v3 - run: ./scripts/ci.sh build diff --git a/rules/private/phases/phase_binary_launcher.bzl b/rules/private/phases/phase_binary_launcher.bzl index 9bdd51f36..5d969ceaf 100644 --- a/rules/private/phases/phase_binary_launcher.bzl +++ b/rules/private/phases/phase_binary_launcher.bzl @@ -23,7 +23,7 @@ def phase_binary_launcher(ctx, g): ctx, "{}/".format(ctx.label.name), ctx.outputs.bin, - g.javainfo.java_info.transitive_runtime_deps, + g.javainfo.java_info.transitive_runtime_jars, jvm_flags = [ctx.expand_location(f, ctx.attr.data) for f in ctx.attr.jvm_flags], main_class = main_class, ) @@ -35,7 +35,7 @@ def phase_binary_launcher(ctx, g): files = inputs + files, transitive_files = depset( order = "default", - transitive = [ctx.attr._target_jdk[java_common.JavaRuntimeInfo].files, g.javainfo.java_info.transitive_runtime_deps], + transitive = [ctx.attr._target_jdk[java_common.JavaRuntimeInfo].files, g.javainfo.java_info.transitive_runtime_jars], ), collect_default = True, ), diff --git a/rules/private/phases/phase_test_launcher.bzl b/rules/private/phases/phase_test_launcher.bzl index da27456c6..d0d107b5a 100644 --- a/rules/private/phases/phase_test_launcher.bzl +++ b/rules/private/phases/phase_test_launcher.bzl @@ -29,9 +29,9 @@ def phase_test_launcher(ctx, g): test_jars = depset(direct = [ coverage_replacements[jar] if jar in coverage_replacements else jar - for jar in g.javainfo.java_info.transitive_runtime_deps.to_list() + for jar in g.javainfo.java_info.transitive_runtime_jars.to_list() ]) - runner_jars = depset(transitive = [ctx.attr.runner[JavaInfo].transitive_runtime_deps, coverage_runner_jars]) + runner_jars = depset(transitive = [ctx.attr.runner[JavaInfo].transitive_runtime_jars, coverage_runner_jars]) all_jars = [test_jars, runner_jars] args = ctx.actions.args() @@ -40,10 +40,10 @@ def phase_test_launcher(ctx, g): if ctx.attr.isolation == "classloader": shared_deps = java_common.merge(_collect(JavaInfo, ctx.attr.shared_deps)) args.add("--isolation", "classloader") - args.add_all("--shared_classpath", shared_deps.transitive_runtime_deps, map_each = _test_launcher_short_path) + args.add_all("--shared_classpath", shared_deps.transitive_runtime_jars, map_each = _test_launcher_short_path) elif ctx.attr.isolation == "process": subprocess_executable = ctx.actions.declare_file("{}/subprocess".format(ctx.label.name)) - subprocess_runner_jars = ctx.attr.subprocess_runner[JavaInfo].transitive_runtime_deps + subprocess_runner_jars = ctx.attr.subprocess_runner[JavaInfo].transitive_runtime_jars all_jars.append(subprocess_runner_jars) files += _write_launcher( ctx, diff --git a/rules/scala.bzl b/rules/scala.bzl index 4acc80213..5f8c5c52c 100644 --- a/rules/scala.bzl +++ b/rules/scala.bzl @@ -262,6 +262,7 @@ def make_scala_library(*extras): *[extra["outputs"] for extra in extras] ), implementation = _scala_library_implementation, + toolchains = ["@bazel_tools//tools/jdk:toolchain_type"], ) scala_library = make_scala_library() @@ -302,6 +303,7 @@ To run the program: `bazel run ` *[extra["outputs"] for extra in extras] ), implementation = _scala_binary_implementation, + toolchains = ["@bazel_tools//tools/jdk:toolchain_type"], ) scala_binary = make_scala_binary() @@ -365,6 +367,7 @@ To build and run a specific test: `bazel test --test_filter=` "bin": "%{name}-bin", }, implementation = _scala_repl_implementation, + toolchains = ["@bazel_tools//tools/jdk:toolchain_type"], ) scala_import = rule( diff --git a/rules/scala/private/doc.bzl b/rules/scala/private/doc.bzl index e5231bf6a..43aed6fe8 100644 --- a/rules/scala/private/doc.bzl +++ b/rules/scala/private/doc.bzl @@ -34,8 +34,8 @@ def scaladoc_implementation(ctx): classpath = depset(transitive = [dep[JavaInfo].transitive_deps for dep in ctx.attr.deps]) compiler_classpath = depset( transitive = - [scompiler_classpath.transitive_runtime_deps] + - [dep[JavaInfo].transitive_runtime_deps for dep in ctx.attr.compiler_deps], + [scompiler_classpath.transitive_runtime_jars] + + [dep[JavaInfo].transitive_runtime_jars for dep in ctx.attr.compiler_deps], ) srcs = [file for file in ctx.files.srcs if file.extension.lower() in ["java", "scala"]] diff --git a/rules/scala/private/repl.bzl b/rules/scala/private/repl.bzl index edeeebc61..67c598a79 100644 --- a/rules/scala/private/repl.bzl +++ b/rules/scala/private/repl.bzl @@ -14,8 +14,8 @@ def scala_repl_implementation(ctx): _collect(JavaInfo, scala_configuration.compiler_classpath), ) - classpath = depset(transitive = [dep[JavaInfo].transitive_runtime_deps for dep in ctx.attr.deps]) - runner_classpath = ctx.attr._runner[JavaInfo].transitive_runtime_deps + classpath = depset(transitive = [dep[JavaInfo].transitive_runtime_jars for dep in ctx.attr.deps]) + runner_classpath = ctx.attr._runner[JavaInfo].transitive_runtime_jars args = ctx.actions.args() args.add("--compiler_bridge", zinc_configuration.compiler_bridge.short_path) @@ -42,7 +42,7 @@ def scala_repl_implementation(ctx): files = depset( [args_file, zinc_configuration.compiler_bridge] + launcher_files, - transitive = [classpath, runner_classpath, scompiler_classpath.transitive_runtime_deps], + transitive = [classpath, runner_classpath, scompiler_classpath.transitive_runtime_jars], ) return [ DefaultInfo( diff --git a/src/main/scala/higherkindness/rules_scala/workers/deps/DepsRunner.scala b/src/main/scala/higherkindness/rules_scala/workers/deps/DepsRunner.scala index 7d7e2d934..6d55b6326 100644 --- a/src/main/scala/higherkindness/rules_scala/workers/deps/DepsRunner.scala +++ b/src/main/scala/higherkindness/rules_scala/workers/deps/DepsRunner.scala @@ -60,13 +60,14 @@ object DepsRunner extends WorkerMain[Unit] { case _ => throw new Exception(s"Unexpected case in DepsRunner") } val labelToPaths = groups.toMap + def pathsForLabel(depLabel: String) = Seq(depLabel, s"@${depLabel}", depLabel.stripPrefix("@")).collect(labelToPaths).flatten val usedPaths = Files.readAllLines(namespace.get[File]("used").toPath).asScala.toSet val remove = if (namespace.getBoolean("check_used") == true) { val usedWhitelist = namespace.getList[String]("used_whitelist").asScala.map(_.tail).toList directLabels .diff(usedWhitelist) - .filterNot(label => labelToPaths.getOrElse(label, labelToPaths(s"@$label")).exists(usedPaths)) + .filterNot(label => pathsForLabel(label).exists(usedPaths)) } else Nil remove.foreach { depLabel => out.println(s"Target '$depLabel' not used, please remove it from the deps.") @@ -76,9 +77,7 @@ object DepsRunner extends WorkerMain[Unit] { val add = if (namespace.getBoolean("check_direct") == true) { val unusedWhitelist = namespace.getList[String]("unused_whitelist").asScala.map(_.tail).toList - (usedPaths -- (directLabels :++ unusedWhitelist).flatMap { label => - labelToPaths.getOrElse(label, labelToPaths(s"@$label")) - }) + (usedPaths -- (directLabels :++ unusedWhitelist).flatMap(pathsForLabel)) .flatMap { path => groups.collectFirst { case (label, paths) if paths(path) => label }.orElse { System.err.println(s"Warning: There is a reference to $path, but no dependency of $label provides it")