bazelbuild / rules_scala

Scala rules for Bazel
Apache License 2.0
363 stars 278 forks source link

Add CommandLineParserAdapter for >=2.13.9 #1634

Closed mbland closed 4 weeks ago

mbland commented 1 month ago

Description

Fixes //third_party/utils/src/test:test_util for Scala 2.13.9 and later by providing a thin scala.tools.cmd.CommandLineParser adapter. Part of #1482.

Motivation

Before this change, building under Scala 2.13.14 produced:

$ bazel build --repo_env=SCALA_VERSION=2.13.14 \
    //third_party/utils/src/test:test_util

ERROR: .../third_party/utils/src/test/BUILD:6:14:
  scala @@//third_party/utils/src/test:test_util failed: (Exit 1):
  scalac failed: error executing Scalac command
  (from target //third_party/utils/src/test:test_util)
  bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/src/java/io/bazel/rulesscala/scalac/scalac
  @bazel-out/darwin_arm64-fastbuild/bin/third_party/utils/src/test/test_util.jar-0.params

third_party/utils/src/test/io/bazel/rulesscala/utils/TestUtil.scala:10:
  error: object cmd is not a member of package tools
    import scala.tools.cmd.CommandLineParser
                       ^
third_party/utils/src/test/io/bazel/rulesscala/utils/TestUtil.scala:119:
  error: not found: value CommandLineParser
    val options = CommandLineParser.tokenize(compileOptions)
                  ^

Turns out CommandLineParser disappered in Scala 2.13.9, and its Parser replacement is private: