Skip to content

Commit 1a83b0d

Browse files
committed
Add scala.tools.cmd.CommandLineParser for >=2.13.9
Fixes //third_party/utils/src/test:test_util for Scala 2.13.9 and later by providing a thin `scala.tools.cmd.CommandLineParser` adapter. Before this change, building under Scala 2.13.14 produced: ```txt $ 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: - scala/scala#10057
1 parent 8f69486 commit 1a83b0d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

third_party/utils/src/test/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ scala_library(
1313
any_3 = [
1414
"io/bazel/rulesscala/utils/Scala3CompilerUtils.scala",
1515
],
16+
between_2_13_9_and_3 = [
17+
"scala/tools/cmd/Scala_2_13_9_CommandLineParser.scala",
18+
],
1619
),
1720
visibility = ["//visibility:public"],
1821
deps = [
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package scala.tools.cmd;
2+
3+
// Hack due to CommandLineParser disappearing in Scala 2.13.9:
4+
// https://github.com/scala/scala/pull/10057
5+
object CommandLineParser {
6+
def tokenize(line: String): List[String] = scala.sys.process.Parser
7+
.tokenize(line)
8+
}

0 commit comments

Comments
 (0)