Skip to content

Fix setup_scala_testing_toolchain() classpaths #1707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

mbland
Copy link
Contributor

@mbland mbland commented Feb 26, 2025

Description

Fixes #1706. Removes the addition of the Scala version suffix to *_classpath argument labels in setup_scala_testing_toolchain().

To facilitate the fix:

  • Moves everything from testing/deps.bzl into testing/testing.bzl and removes the original testing/deps.bzl file.

  • Updates repositories() from scala/scala_cross_version.bzl to accept and return None as an argument.

  • Updates examples/testing/multi_frameworks_toolchain/BUILD to provide a reproduction and validation of the fix.

After updating multi_frameworks_toolchain/BUILD, but before applying the fix, the multi_framework_toolchain_example test case broke in a similar fashion to #1706:

$ RULES_SCALA_TEST_ONLY=multi_framework_toolchain_example \
  ./test_examples.sh

running test multi_framework_toolchain_example
ERROR: .../examples/testing/multi_frameworks_toolchain/BUILD:19:30:
  no such package '@io_bazel_rules_scala_org_specs2_specs2_fp_2_12_20_2_12_20//':
  The repository '@io_bazel_rules_scala_org_specs2_specs2_fp_2_12_20_2_12_20'
  could not be resolved:
  Repository '@io_bazel_rules_scala_org_specs2_specs2_fp_2_12_20_2_12_20'
  is not defined and referenced by '//:testing_toolchain_specs2_classpath_provider'

ERROR: Analysis of target
  '//:testing_toolchain_specs2_classpath_provider' failed;
  build aborted:
Analysis failed
INFO: Elapsed time: 0.159s
INFO: 0 processes.
ERROR: Couldn't start the build. Unable to run tests

Motivation

This was clearly a bug introduced earlier in the effort to make rules_scala Bzlmod compatible in #1482. At the time I didn't understand the ramifications, and we didn't have tests to catch this specific case. Many thanks to @crt-31 for finding it and filing #1706 before the next major release.

Fixes bazel-contrib#1706. Removes the addition of the Scala version suffix to
`*_classpath` argument labels in `setup_scala_testing_toolchain()`.

To facilitate the fix:

- Moves everything from `testing/deps.bzl` into `testing/testing.bzl`
  and removes the original `testing/deps.bzl` file.

- Updates `repositories()` from `scala/scala_cross_version.bzl` to
  accept and return `None` as an argument.

- Updates `examples/testing/multi_frameworks_toolchain/BUILD` to provide
  a reproduction and validation of the fix.

After updating `multi_frameworks_toolchain/BUILD`, but before applying
the fix, the `multi_framework_toolchain_example` test case broke in a
similar fashion to bazel-contrib#1706:

```txt
$ RULES_SCALA_TEST_ONLY=multi_framework_toolchain_example \
  ./test_examples.sh

running test multi_framework_toolchain_example
ERROR: .../examples/testing/multi_frameworks_toolchain/BUILD:19:30:
  no such package '@io_bazel_rules_scala_org_specs2_specs2_fp_2_12_20_2_12_20//':
  The repository '@io_bazel_rules_scala_org_specs2_specs2_fp_2_12_20_2_12_20'
  could not be resolved:
  Repository '@io_bazel_rules_scala_org_specs2_specs2_fp_2_12_20_2_12_20'
  is not defined and referenced by '//:testing_toolchain_specs2_classpath_provider'

ERROR: Analysis of target
  '//:testing_toolchain_specs2_classpath_provider' failed;
  build aborted:
Analysis failed
INFO: Elapsed time: 0.159s
INFO: 0 processes.
ERROR: Couldn't start the build. Unable to run tests
```
Copy link

Important

The terms of service for this installation has not been accepted. Please ask the Organization owners to visit the Gemini Code Assist Admin Console to sign it.

Copy link
Collaborator

@simuons simuons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mbland and @crt-31

@simuons simuons merged commit cd1bf15 into bazel-contrib:master Feb 28, 2025
2 checks passed
@mbland mbland deleted the fix-setup-testing-toolchain-#1706 branch February 28, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

setup_scala_testing_toolchain() failing when passed xxx_classpath
2 participants