diff --git a/.bazelrc b/.bazelrc index 5ffdbdc80..ca0bab4e0 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,4 +1,5 @@ common --config=rules common:v5.0 --config=rules_v5.0 common:v6.3 --config=rules_v6.3 +common:v7.0 --config=rules_v7.0 import %workspace%/.bazelrc_shared diff --git a/.bazelrc_shared b/.bazelrc_shared index fc3ed9111..d86b754b0 100644 --- a/.bazelrc_shared +++ b/.bazelrc_shared @@ -1,5 +1,6 @@ common --announce_rc common --color=yes +common --noenable_bzlmod build --experimental_strict_action_env build --javacopt="-source 11 -target 11" @@ -28,6 +29,7 @@ test --test_output=all common:rules_v5.0 --config=noop common:rules_v6.3 --config=noop +common:rules_v7.0 --config=noop # route potentially unrouted configs to a terminating noop config # it's a noop because we use the default value @@ -35,6 +37,7 @@ common:rules --config=noop common:tests --config=noop common:v5.0 --config=rules_v5.0 common:v6.3 --config=rules_v6.3 +common:v7.0 --config=rules_v7.0 # pick something trivial as a "noop" common:noop --logging=3 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/WORKSPACE b/WORKSPACE index f9530955c..1fa2da66c 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -17,17 +17,6 @@ http_archive( ], ) -skydoc_tag = "0.3.0" - -skydoc_sha256 = "8762a212cff5f81505a1632630edcfe9adce381479a50a03c968bd2fc217972d" - -http_archive( - name = "io_bazel_skydoc", - sha256 = skydoc_sha256, - strip_prefix = "skydoc-{}".format(skydoc_tag), - url = "https://github.com/bazelbuild/skydoc/archive/{}.zip".format(skydoc_tag), -) - # com_github_bazelbuild_buildtools buildtools_tag = "0.29.0" @@ -47,13 +36,13 @@ buildifier_dependencies() # io_bazel_rules_go -rules_go_tag = "v0.28.0" +rules_go_tag = "v0.43.0" rules_go_sha256 = "8e968b5fcea1d2d64071872b12737bbb5514524ee5f0a4f54f5920266c261acb" http_archive( name = "io_bazel_rules_go", - sha256 = rules_go_sha256, + integrity = "sha256-1qtrV+SMCVI+kwUPE2mPcIQoz9XmGSUuNp03evZZdwc=", urls = [ "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/{tag}/rules_go-{tag}.zip".format(tag = rules_go_tag), "https://github.com/bazelbuild/rules_go/releases/download/{tag}/rules_go-{tag}.zip".format(tag = rules_go_tag), diff --git a/docs/stardoc/external.md b/docs/stardoc/external.md deleted file mode 100644 index ee4aeee79..000000000 --- a/docs/stardoc/external.md +++ /dev/null @@ -1,82 +0,0 @@ - - - - -## scala_import_external - -
-scala_import_external(rule_load, kwargs)
-
- - - -### Parameters - - - - - - - - - - - - - - - - -
rule_load - optional. default is "load(\"@rules_scala_annex//rules:scala.bzl\", \"scala_import\")" -
kwargs - optional. -
- - - - -## scala_maven_import_external - -
-scala_maven_import_external(artifact, server_urls, rule_load, kwargs)
-
- - - -### Parameters - - - - - - - - - - - - - - - - - - - - - - - - -
artifact - required. -
server_urls - required. -
rule_load - optional. default is "load(\"@rules_scala_annex//rules:scala.bzl\", \"scala_import\")" -
kwargs - optional. -
- - diff --git a/docs/stardoc/jvm.md b/docs/stardoc/jvm.md deleted file mode 100644 index f33037eff..000000000 --- a/docs/stardoc/jvm.md +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/docs/stardoc/providers.md b/docs/stardoc/providers.md deleted file mode 100644 index 48573fe0b..000000000 --- a/docs/stardoc/providers.md +++ /dev/null @@ -1,534 +0,0 @@ - - - - -## declare_scala_configuration - -
-declare_scala_configuration(name, compiler_classpath, global_plugins, global_scalacopts, runtime_classpath, version)
-
- -Creates a `ScalaConfiguration`. - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
compiler_classpath - List of labels; required -
global_plugins - List of labels; optional -

- Scalac plugins that will always be enabled. -

-
global_scalacopts - List of strings; optional -

- Scalac options that will always be enabled. -

-
runtime_classpath - List of labels; required -
version - String; required -
- - - - -## declare_zinc_configuration - -
-declare_zinc_configuration(name, compiler_bridge)
-
- -Creates a `ZincConfiguration`. - -### Attributes - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
compiler_bridge - Label; required -
- - - - -## join_configurations - -
-join_configurations(name, configurations)
-
- - - -### Attributes - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
configurations - List of labels; required -
- - - - -## reconfigure_deps_configuration - -
-reconfigure_deps_configuration(name, direct, provider, used)
-
- - - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
direct - String; optional -
provider - Label; required -
used - String; optional -
- - - - -## CodeCoverageConfiguration - -
-CodeCoverageConfiguration(instrumentation_worker)
-
- -Code coverage related configuration - -### Fields - - - - - - - - - - - - -
instrumentation_worker -

the worker used for instrumenting jars

-
- - - - -## DepsConfiguration - -
-DepsConfiguration(direct, used, worker)
-
- -Dependency checking configuration. - -### Fields - - - - - - - - - - - - - - - - - - - - -
direct -

either error or off

-
used -

either error or off

-
worker -

the worker label for checking used/unused deps

-
- - - - -## IntellijInfo - -
-IntellijInfo(outputs, transitive_exports)
-
- -Provider for IntelliJ. - -### Fields - - - - - - - - - - - - - - - - -
outputs -

java_output_jars

-
transitive_exports -

labels of transitive dependencies

-
- - - - -## LabeledJars - -
-LabeledJars(values)
-
- -Exported jars and their labels. - -### Fields - - - - - - - - - - - - -
values -

The preorder depset of label and jars.

-
- - - - -## ScalaConfiguration - -
-ScalaConfiguration(version, compiler_classpath, runtime_classpath, global_plugins, global_scalacopts, use_ijar)
-
- -Scala compile-time and runtime configuration - -### Fields - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
version -

The Scala full version.

-
compiler_classpath -

The compiler classpath.

-
runtime_classpath -

The runtime classpath.

-
global_plugins -

Globally enabled compiler plugins

-
global_scalacopts -

Globally enabled compiler options

-
use_ijar -

Whether to use ijars for this Scala compiler

-
- - - - -## ScalaInfo - -
-ScalaInfo(macro, scala_configuration)
-
- -Scala library. - -### Fields - - - - - - - - - - - - - - - - -
macro -

whether the jar contains macros

-
scala_configuration -

ScalaConfiguration associated with this output

-
- - - - -## ScalaRulePhase - -
-ScalaRulePhase(phases)
-
- -A Scala compiler plugin - -### Fields - - - - - - - - - - - - -
phases -

the phases to add

-
- - - - -## ZincConfiguration - -
-ZincConfiguration(compiler_bridge, compile_worker, log_level)
-
- -Zinc configuration. - -### Fields - - - - - - - - - - - - - - - - - - - - -
compiler_bridge -

compiled Zinc compiler bridge

-
compile_worker -

the worker label for compilation with Zinc

-
log_level -

log level for the Zinc compiler

-
- - - - -## ZincInfo - -
-ZincInfo(apis, deps, deps_files, label, relations)
-
- -Zinc-specific outputs. - -### Fields - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
apis -

The API file.

-
deps -

The depset of library dependency outputs.

-
deps_files -

The depset of all Zinc files.

-
label -

The label for this output.

-
relations -

The relations file.

-
- - diff --git a/docs/stardoc/rules_scala.md b/docs/stardoc/rules_scala.md deleted file mode 100644 index cb88f206d..000000000 --- a/docs/stardoc/rules_scala.md +++ /dev/null @@ -1,79 +0,0 @@ - - - - -## emulate_rules_scala_repository - -
-emulate_rules_scala_repository(name, extra_deps)
-
- - - -### Attributes - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this repository. -

-
extra_deps - List of labels; optional -
- - - - -## emulate_rules_scala - -
-emulate_rules_scala(scala, scalatest, extra_deps)
-
- - - -### Parameters - - - - - - - - - - - - - - - - - - - - -
scala - required. -
scalatest - required. -
extra_deps - optional. default is [] -
- - diff --git a/docs/stardoc/scala.md b/docs/stardoc/scala.md deleted file mode 100644 index 1a037fb63..000000000 --- a/docs/stardoc/scala.md +++ /dev/null @@ -1,960 +0,0 @@ - - - - -## configure_bootstrap_scala - -
-configure_bootstrap_scala(name, compiler_classpath, global_plugins, global_scalacopts, runtime_classpath, use_ijar, version)
-
- - - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
compiler_classpath - List of labels; required -
global_plugins - List of labels; optional -

- Scalac plugins that will always be enabled. -

-
global_scalacopts - List of strings; optional -

- Scalac options that will always be enabled. -

-
runtime_classpath - List of labels; required -
use_ijar - Boolean; optional -

- Whether to use ijars for this compiler. Scala 3 currently cannot use ijars. -

-
version - String; required -
- - - - -## scala_binary - -
-scala_binary(name, data, deps, deps_unused_whitelist, deps_used_whitelist, javacopts, jvm_flags, main_class, plugins, resource_jars, resource_strip_prefix, resources, runtime_deps, scala, scalacopts, srcs)
-
- - -Compiles and links a Scala JVM executable. - -Produces the following implicit outputs: - - - `_deploy.jar`: a single jar that contains all the necessary information to run the program - - `.jar`: a jar file that contains the class files produced from the sources - - `-bin`: the script that's used to run the program in conjunction with the generated runfiles - -To run the program: `bazel run ` - - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
data - List of labels; optional -

- The additional runtime files needed by this library. -

-
deps - List of labels; optional -

- The JVM library dependencies. -

-
deps_unused_whitelist - List of labels; optional -

- The JVM library dependencies to always consider unused for `scala_deps_direct` checks. -

-
deps_used_whitelist - List of labels; optional -

- The JVM library dependencies to always consider used for `scala_deps_used` checks. -

-
javacopts - List of strings; optional -

- The Javac options. -

-
jvm_flags - List of strings; optional -

- The JVM runtime flags. -

-
main_class - String; optional -

- The main class. If not provided, it will be inferred by its type signature. -

-
plugins - List of labels; optional -

- The Scalac plugins. -

-
resource_jars - List of labels; optional -

- The JARs to merge into the output JAR. -

-
resource_strip_prefix - String; optional -

- The path prefix to strip from classpath resources. -

-
resources - List of labels; optional -

- The files to include as classpath resources. -

-
runtime_deps - List of labels; optional -

- The JVM runtime-only library dependencies. -

-
scala - Label; optional -

- The `ScalaConfiguration`. Among other things, this specifies which scala version to use. - Defaults to the default_scala target specified in the WORKSPACE file. -

-
scalacopts - List of strings; optional -

- The Scalac options. -

-
srcs - List of labels; optional -

- The source Scala and Java files (and `.srcjar` files of those). -

-
- - - - -## scala_import - -
-scala_import(name, deps, exports, jars, neverlink, runtime_deps, srcjar)
-
- - -Creates a Scala JVM library. - -Use this only for libraries with macros. Otherwise, use `java_import`. - - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
deps - List of labels; optional -
exports - List of labels; optional -
jars - List of labels; optional -
runtime_deps - List of labels; optional -
srcjar - Label; optional -
- - - - -## scala_library - -
-scala_library(name, data, deps, deps_unused_whitelist, deps_used_whitelist, exports, javacopts, macro, neverlink, plugins, resource_jars, resource_strip_prefix, resources, runtime_deps, scala, scalacopts, srcs)
-
- -Compiles a Scala JVM library. - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
data - List of labels; optional -

- The additional runtime files needed by this library. -

-
deps - List of labels; optional -

- The JVM library dependencies. -

-
deps_unused_whitelist - List of labels; optional -

- The JVM library dependencies to always consider unused for `scala_deps_direct` checks. -

-
deps_used_whitelist - List of labels; optional -

- The JVM library dependencies to always consider used for `scala_deps_used` checks. -

-
exports - List of labels; optional -

- The JVM libraries to add as dependencies to any libraries dependent on this one. -

-
javacopts - List of strings; optional -

- The Javac options. -

-
macro - Boolean; optional -

- Whether this library provides macros. -

-
plugins - List of labels; optional -

- The Scalac plugins. -

-
resource_jars - List of labels; optional -

- The JARs to merge into the output JAR. -

-
resource_strip_prefix - String; optional -

- The path prefix to strip from classpath resources. -

-
resources - List of labels; optional -

- The files to include as classpath resources. -

-
runtime_deps - List of labels; optional -

- The JVM runtime-only library dependencies. -

-
scala - Label; optional -

- The `ScalaConfiguration`. Among other things, this specifies which scala version to use. - Defaults to the default_scala target specified in the WORKSPACE file. -

-
scalacopts - List of strings; optional -

- The Scalac options. -

-
srcs - List of labels; optional -

- The source Scala and Java files (and `.srcjar` files of those). -

-
- - - - -## scala_repl - -
-scala_repl(name, data, deps, jvm_flags, scala, scalacopts)
-
- - -Launches a REPL with all given dependencies available. - -To run: `bazel run ` - - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
data - List of labels; optional -

- The additional runtime files needed by this REPL. -

-
deps - List of labels; optional -
jvm_flags - List of strings; optional -

- The JVM runtime flags. -

-
scala - Label; optional -

- The `ScalaConfiguration`. -

-
scalacopts - List of strings; optional -

- The Scalac options. -

-
- - - - -## scala_test - -
-scala_test(name, data, deps, deps_unused_whitelist, deps_used_whitelist, frameworks, isolation, javacopts, jvm_flags, plugins, resource_jars, resource_strip_prefix, resources, runner, runtime_deps, scala, scalacopts, shared_deps, srcs, subprocess_runner)
-
- - -Compiles and links a collection of Scala tests. - -To buid and run all tests: `bazel test ` - -To build and run a specific test: `bazel test --test_filter=` -
(Note: the syntax of the `` varies by test framework, and not all test frameworks support the `test_filter` option at this time.) - -[More Info](/docs/scala.md#tests) - - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
data - List of labels; optional -

- The additional runtime files needed by this library. -

-
deps - List of labels; optional -

- The JVM library dependencies. -

-
deps_unused_whitelist - List of labels; optional -

- The JVM library dependencies to always consider unused for `scala_deps_direct` checks. -

-
deps_used_whitelist - List of labels; optional -

- The JVM library dependencies to always consider used for `scala_deps_used` checks. -

-
frameworks - List of strings; optional -
isolation - String; optional -

- The isolation level to apply -

-
javacopts - List of strings; optional -

- The Javac options. -

-
jvm_flags - List of strings; optional -

- The JVM runtime flags. -

-
plugins - List of labels; optional -

- The Scalac plugins. -

-
resource_jars - List of labels; optional -

- The JARs to merge into the output JAR. -

-
resource_strip_prefix - String; optional -

- The path prefix to strip from classpath resources. -

-
resources - List of labels; optional -

- The files to include as classpath resources. -

-
runner - Label; optional -
runtime_deps - List of labels; optional -

- The JVM runtime-only library dependencies. -

-
scala - Label; optional -

- The `ScalaConfiguration`. Among other things, this specifies which scala version to use. - Defaults to the default_scala target specified in the WORKSPACE file. -

-
scalacopts - List of strings; optional -
shared_deps - List of labels; optional -

- If isolation is "classloader", the list of deps to keep loaded between tests -

-
srcs - List of labels; optional -

- The source Scala and Java files (and `.srcjar` files of those). -

-
subprocess_runner - Label; optional -
- - - - -## scaladoc - -
-scaladoc(name, compiler_deps, deps, scala, scalacopts, srcs, title)
-
- - -Generates Scaladocs. - - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
compiler_deps - List of labels; optional -
deps - List of labels; optional -
scala - Label; optional -
scalacopts - List of strings; optional -
srcs - List of labels; optional -
title - String; optional -
- - - - -## configure_zinc_scala - -
-configure_zinc_scala(kwargs)
-
- - - -### Parameters - - - - - - - - - - - - -
kwargs - optional. -
- - - - -## make_scala_binary - -
-make_scala_binary(extras)
-
- - - -### Parameters - - - - - - - - - - - - -
extras - optional. -
- - - - -## make_scala_library - -
-make_scala_library(extras)
-
- - - -### Parameters - - - - - - - - - - - - -
extras - optional. -
- - - - -## make_scala_test - -
-make_scala_test(extras)
-
- - - -### Parameters - - - - - - - - - - - - -
extras - optional. -
- - diff --git a/docs/stardoc/scala_proto.md b/docs/stardoc/scala_proto.md deleted file mode 100644 index 894fa3b34..000000000 --- a/docs/stardoc/scala_proto.md +++ /dev/null @@ -1,129 +0,0 @@ - - - - -## scala_proto_library - -
-scala_proto_library(name, deps, grpc)
-
- - -Generates Scala code from proto sources. The output is a `.srcjar` that can be passed into other rules for compilation. - -See example use in [/tests/proto/BUILD](/tests/proto/BUILD) - - -### Attributes - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
deps - List of labels; optional -

- The proto_library targets you wish to generate Scala from -

-
grpc - Boolean; optional -
- - - - -## scala_proto_toolchain - -
-scala_proto_toolchain(name, compiler, compiler_supports_workers)
-
- - -Specifies a toolchain of the `@rules_scala_annex//rules/scala_proto:compiler_toolchain_type` toolchain type. - -This rule should be used with an accompanying `toolchain` that binds it and specifies constraints -(See the official documentation for more info on [Bazel Toolchains](https://docs.bazel.build/versions/master/toolchains.html)) - -For example: - -```python -scala_proto_toolchain( - name = "scalapb_toolchain_example", - compiler = ":worker", - compiler_supports_workers = True, - visibility = ["//visibility:public"], -) - -toolchain( - name = "scalapb_toolchain_example_linux", - toolchain = ":scalapb_toolchain_example", - toolchain_type = "@rules_scala_annex//rules/scala_proto:compiler_toolchain_type", - exec_compatible_with = [ - "@bazel_tools//platforms:linux", - "@bazel_tools//platforms:x86_64", - ], - target_compatible_with = [ - "@bazel_tools//platforms:linux", - "@bazel_tools//platforms:x86_64", - ], - visibility = ["//visibility:public"], -) -``` - - -### Attributes - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
compiler - Label; optional -

- The compiler to use to generate Scala form proto sources -

-
compiler_supports_workers - Boolean; optional -
- - diff --git a/docs/stardoc/scala_with_scalafmt.md b/docs/stardoc/scala_with_scalafmt.md deleted file mode 100644 index 9f8a81b32..000000000 --- a/docs/stardoc/scala_with_scalafmt.md +++ /dev/null @@ -1,600 +0,0 @@ - - - - -## scala_binary - -
-scala_binary(name, config, data, deps, deps_unused_whitelist, deps_used_whitelist, format, javacopts, jvm_flags, main_class, plugins, resource_jars, resource_strip_prefix, resources, runtime_deps, scala, scalacopts, srcs)
-
- - -Compiles and links a Scala JVM executable. - -Produces the following implicit outputs: - - - `_deploy.jar`: a single jar that contains all the necessary information to run the program - - `.jar`: a jar file that contains the class files produced from the sources - - `-bin`: the script that's used to run the program in conjunction with the generated runfiles - -To run the program: `bazel run ` - - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
config - Label; optional -

- The Scalafmt configuration file. -

-
data - List of labels; optional -

- The additional runtime files needed by this library. -

-
deps - List of labels; optional -

- The JVM library dependencies. -

-
deps_unused_whitelist - List of labels; optional -

- The JVM library dependencies to always consider unused for `scala_deps_direct` checks. -

-
deps_used_whitelist - List of labels; optional -

- The JVM library dependencies to always consider used for `scala_deps_used` checks. -

-
format - Boolean; optional -
javacopts - List of strings; optional -

- The Javac options. -

-
jvm_flags - List of strings; optional -

- The JVM runtime flags. -

-
main_class - String; optional -

- The main class. If not provided, it will be inferred by its type signature. -

-
plugins - List of labels; optional -

- The Scalac plugins. -

-
resource_jars - List of labels; optional -

- The JARs to merge into the output JAR. -

-
resource_strip_prefix - String; optional -

- The path prefix to strip from classpath resources. -

-
resources - List of labels; optional -

- The files to include as classpath resources. -

-
runtime_deps - List of labels; optional -

- The JVM runtime-only library dependencies. -

-
scala - Label; optional -

- The `ScalaConfiguration`. Among other things, this specifies which scala version to use. - Defaults to the default_scala target specified in the WORKSPACE file. -

-
scalacopts - List of strings; optional -

- The Scalac options. -

-
srcs - List of labels; optional -

- The source Scala and Java files (and `.srcjar` files of those). -

-
- - - - -## scala_library - -
-scala_library(name, config, data, deps, deps_unused_whitelist, deps_used_whitelist, exports, format, javacopts, macro, neverlink, plugins, resource_jars, resource_strip_prefix, resources, runtime_deps, scala, scalacopts, srcs)
-
- -Compiles a Scala JVM library. - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
config - Label; optional -

- The Scalafmt configuration file. -

-
data - List of labels; optional -

- The additional runtime files needed by this library. -

-
deps - List of labels; optional -

- The JVM library dependencies. -

-
deps_unused_whitelist - List of labels; optional -

- The JVM library dependencies to always consider unused for `scala_deps_direct` checks. -

-
deps_used_whitelist - List of labels; optional -

- The JVM library dependencies to always consider used for `scala_deps_used` checks. -

-
exports - List of labels; optional -

- The JVM libraries to add as dependencies to any libraries dependent on this one. -

-
format - Boolean; optional -
javacopts - List of strings; optional -

- The Javac options. -

-
macro - Boolean; optional -

- Whether this library provides macros. -

-
plugins - List of labels; optional -

- The Scalac plugins. -

-
resource_jars - List of labels; optional -

- The JARs to merge into the output JAR. -

-
resource_strip_prefix - String; optional -

- The path prefix to strip from classpath resources. -

-
resources - List of labels; optional -

- The files to include as classpath resources. -

-
runtime_deps - List of labels; optional -

- The JVM runtime-only library dependencies. -

-
scala - Label; optional -

- The `ScalaConfiguration`. Among other things, this specifies which scala version to use. - Defaults to the default_scala target specified in the WORKSPACE file. -

-
scalacopts - List of strings; optional -

- The Scalac options. -

-
srcs - List of labels; optional -

- The source Scala and Java files (and `.srcjar` files of those). -

-
- - - - -## scala_test - -
-scala_test(name, config, data, deps, deps_unused_whitelist, deps_used_whitelist, format, frameworks, isolation, javacopts, jvm_flags, plugins, resource_jars, resource_strip_prefix, resources, runner, runtime_deps, scala, scalacopts, shared_deps, srcs, subprocess_runner)
-
- - -Compiles and links a collection of Scala tests. - -To buid and run all tests: `bazel test ` - -To build and run a specific test: `bazel test --test_filter=` -
(Note: the syntax of the `` varies by test framework, and not all test frameworks support the `test_filter` option at this time.) - -[More Info](/docs/scala.md#tests) - - -### Attributes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
config - Label; optional -

- The Scalafmt configuration file. -

-
data - List of labels; optional -

- The additional runtime files needed by this library. -

-
deps - List of labels; optional -

- The JVM library dependencies. -

-
deps_unused_whitelist - List of labels; optional -

- The JVM library dependencies to always consider unused for `scala_deps_direct` checks. -

-
deps_used_whitelist - List of labels; optional -

- The JVM library dependencies to always consider used for `scala_deps_used` checks. -

-
format - Boolean; optional -
frameworks - List of strings; optional -
isolation - String; optional -

- The isolation level to apply -

-
javacopts - List of strings; optional -

- The Javac options. -

-
jvm_flags - List of strings; optional -

- The JVM runtime flags. -

-
plugins - List of labels; optional -

- The Scalac plugins. -

-
resource_jars - List of labels; optional -

- The JARs to merge into the output JAR. -

-
resource_strip_prefix - String; optional -

- The path prefix to strip from classpath resources. -

-
resources - List of labels; optional -

- The files to include as classpath resources. -

-
runner - Label; optional -
runtime_deps - List of labels; optional -

- The JVM runtime-only library dependencies. -

-
scala - Label; optional -

- The `ScalaConfiguration`. Among other things, this specifies which scala version to use. - Defaults to the default_scala target specified in the WORKSPACE file. -

-
scalacopts - List of strings; optional -
shared_deps - List of labels; optional -

- If isolation is "classloader", the list of deps to keep loaded between tests -

-
srcs - List of labels; optional -

- The source Scala and Java files (and `.srcjar` files of those). -

-
subprocess_runner - Label; optional -
- - diff --git a/docs/stardoc/scalafmt.md b/docs/stardoc/scalafmt.md deleted file mode 100644 index 0ec717817..000000000 --- a/docs/stardoc/scalafmt.md +++ /dev/null @@ -1,51 +0,0 @@ - - - - -## scala_format_test - -
-scala_format_test(name, config, srcs)
-
- - - -### Attributes - - - - - - - - - - - - - - - - - - - - -
name - Name; required -

- A unique name for this target. -

-
config - Label; optional -

- The Scalafmt configuration file. -

-
srcs - List of labels; optional -

- The Scala files. -

-
- - diff --git a/rules/BUILD b/rules/BUILD index 62d4c9212..622ef9eea 100644 --- a/rules/BUILD +++ b/rules/BUILD @@ -1,26 +1,6 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") load("@bazel_skylib//lib:paths.bzl", "paths") load("@rules_pkg//pkg:pkg.bzl", "pkg_tar") -load("@io_bazel_skydoc//stardoc:stardoc.bzl", "stardoc") - -[ - stardoc( - name = paths.replace_extension(file, "_doc").replace("/", "_"), - out = paths.replace_extension(file, ".md").replace("/", "_"), - input = file, - deps = [ - ":bzl_internal", - "@rules_scala_annex//rules:bzl", - ], - ) - for file in glob(["**/*.bzl"]) -] - -pkg_tar( - name = "docs", - srcs = [paths.replace_extension(file, ".md").replace("/", "_") for file in glob(["**/*.bzl"])], - mode = "0644", -) bzl_library( name = "bzl", 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..9c107d237 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( @@ -436,6 +440,7 @@ Creates a Scala JVM library. Use this only for libraries with macros. Otherwise, use `java_import`. """, + toolchains = ["@bazel_tools//tools/jdk:toolchain_type"], implementation = _scala_import_implementation, ) @@ -464,6 +469,7 @@ scaladoc = rule( doc = """ Generates Scaladocs. """, + toolchains = ["@bazel_tools//tools/jdk:toolchain_type"], implementation = _scaladoc_implementation, ) diff --git a/rules/scala/private/doc.bzl b/rules/scala/private/doc.bzl index e5231bf6a..1ce91f7d2 100644 --- a/rules/scala/private/doc.bzl +++ b/rules/scala/private/doc.bzl @@ -31,11 +31,11 @@ def scaladoc_implementation(ctx): html = ctx.actions.declare_directory("html") tmp = ctx.actions.declare_directory("tmp") - classpath = depset(transitive = [dep[JavaInfo].transitive_deps for dep in ctx.attr.deps]) + classpath = depset(transitive = [dep[JavaInfo].transitive_compile_time_jars 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/scripts/ci.sh b/scripts/ci.sh index 02e7e462c..efb98d2f9 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -25,7 +25,6 @@ case "$1" in "lint") ./scripts/format.sh check - ./scripts/gen-docs.sh && git diff --exit-code ;; "") echo "command not specified" diff --git a/scripts/gen-docs.sh b/scripts/gen-docs.sh deleted file mode 100755 index d72f796ba..000000000 --- a/scripts/gen-docs.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -# -# Regenerates stardoc for the rules -# - -cd "$(dirname "$0")/.." -set -x - -rm -fr docs/stardoc -mkdir -p docs/stardoc - -bazel build rules:docs -tar xf "$(bazel info bazel-bin)/rules/docs.tar" -C docs/stardoc -find docs/stardoc -size 0 -print0 | while read path; do - rm $path -done 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..1ebff7788 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,15 @@ 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 +78,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") diff --git a/tests/WORKSPACE b/tests/WORKSPACE index 426f0e801..dff71dfc5 100644 --- a/tests/WORKSPACE +++ b/tests/WORKSPACE @@ -135,7 +135,7 @@ emulate_rules_scala( "@annex//:org_scala_lang_scala_reflect_2_13_11", "@annex_test//:org_scala_lang_modules_scala_xml_2_13", ], - scala = "//scala:2_13", + scala = "@//scala:2_13", scalatest = "@scalatest_2_13//jar", ) diff --git a/tests/dependencies/unused/test b/tests/dependencies/unused/test index d89376e00..689cea2ba 100755 --- a/tests/dependencies/unused/test +++ b/tests/dependencies/unused/test @@ -3,7 +3,7 @@ bazel build :0_used ! bazel build :0_unused || false -bazel build :0_unused |& grep "buildozer 'remove deps @annex_test//:org_scalacheck_scalacheck_2_13' //dependencies/unused:0_unused" +bazel build :0_unused |& grep "buildozer 'remove deps @\?@annex_test//:org_scalacheck_scalacheck_2_13' //dependencies/unused:0_unused" bazel build :0_unused_whitelist bazel build :indirect_unused ! bazel build :indirect_unused_missing || false diff --git a/tools/bazel b/tools/bazel index 350b4b406..afcc896c9 100755 --- a/tools/bazel +++ b/tools/bazel @@ -15,7 +15,7 @@ abs_path() { workspace=$(cd $(dirname "$0")/..; pwd) root_workspace=$(cd $(dirname $(abs_path "$0"))/..; pwd) -default_bazel_version='6.3.2' +default_bazel_version='7.0.0' if [ -z "$BAZEL_VERSION" ]; then bazel_version="$default_bazel_version" @@ -35,6 +35,9 @@ case "$bazel_version" in '6.3.2') linux_sha='f117506267ed148d5f4f9844bcf187c4f111dad7ff4f1a9eb1f4e45331f3f9f0' ;; + '7.0.0') + linux_sha='b32c278fd1e72a676ea560d7b4e71ce97536405f6a3f8c1752acb4e88c031184' + ;; *) echo "The requested Bazel version '$bazel_version' is not supported" exit 1