Skip to content

Commit f3edd3f

Browse files
authored
Merge pull request #11952 from dotty-staging/fix-scalaBinaryVersion
sbt-dotty: the binary version is 3 for Scala >= 3.0.0
2 parents b568cdb + c0d4e35 commit f3edd3f

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

community-build/src/scala/dotty/communitybuild/projects.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ lazy val sbtPluginFilePath: String =
2121
def log(msg: String) = println(Console.GREEN + msg + Console.RESET)
2222

2323
/** Executes shell command, returns false in case of error. */
24-
def exec(projectDir: Path, binary: String, arguments: String*): Int =
24+
def exec(projectDir: Path, binary: String, arguments: Seq[String], environment: Map[String, String]): Int =
25+
import collection.JavaConverters._
2526
val command = binary +: arguments
2627
log(command.mkString(" "))
2728
val builder = new ProcessBuilder(command: _*).directory(projectDir.toFile).inheritIO()
29+
builder.environment.putAll(environment.asJava)
2830
val process = builder.start()
2931
val exitCode = process.waitFor()
3032
exitCode
@@ -41,6 +43,7 @@ sealed trait CommunityProject:
4143
val binaryName: String
4244
val runCommandsArgs: List[String] = Nil
4345
val requiresExperimental: Boolean
46+
val environment: Map[String, String] = Map.empty
4447

4548
final val projectDir = communitybuildDir.resolve("community-projects").resolve(project)
4649

@@ -55,7 +58,7 @@ sealed trait CommunityProject:
5558
log(s"Publishing $project")
5659
if publishCommand eq null then
5760
throw RuntimeException(s"Publish command is not specified for $project. Project details:\n$this")
58-
val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ publishCommand): _*)
61+
val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ publishCommand), environment)
5962
if exitCode != 0 then
6063
throw RuntimeException(s"Publish command exited with code $exitCode for project $project. Project details:\n$this")
6164
published = true
@@ -70,11 +73,11 @@ sealed trait CommunityProject:
7073
log(s"Documenting $project")
7174
if docCommand eq null then
7275
throw RuntimeException(s"Doc command is not specified for $project. Project details:\n$this")
73-
val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ docCommand): _*)
76+
val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ docCommand), environment)
7477
if exitCode != 0 then
7578
throw RuntimeException(s"Doc command exited with code $exitCode for project $project. Project details:\n$this")
7679

77-
final def build(): Int = exec(projectDir, binaryName, buildCommands: _*)
80+
final def build(): Int = exec(projectDir, binaryName, buildCommands, environment)
7881

7982
final def buildCommands = runCommandsArgs :+ testCommand
8083

@@ -94,6 +97,7 @@ final case class MillCommunityProject(
9497
// uncomment once mill is released
9598
// if ignoreDocs then null else s"$baseCommand.docJar"
9699
override val runCommandsArgs = List("-i", "-D", s"dottyVersion=$compilerVersion")
100+
override val environment = Map("MILL_VERSION" -> "0.9.6-16-a5da34")
97101

98102
final case class SbtCommunityProject(
99103
project: String,

project/Build.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1248,9 +1248,12 @@ object Build {
12481248
baseDirectory.value / "../language-server/src/dotty/tools/languageserver/config",
12491249
sbtTestDirectory := baseDirectory.value / "sbt-test",
12501250

1251-
// ensure that sbt-dotty is built on sbt 1.4
1251+
// ensure that sbt-dotty is built with sbt 1.4
12521252
pluginCrossBuild / sbtVersion := "1.4.9",
12531253

1254+
// scritped tests are run with current sbt version
1255+
scriptedSbt := sbtVersion.value,
1256+
12541257
// The batch mode accidentally became the default with no way to disable
12551258
// it in sbt 1.4 (https://github.com/sbt/sbt/issues/5913#issuecomment-716003195).
12561259
// We enable it explicitly here to make it clear that we're using it.

sbt-dotty/sbt-test/source-dependencies/value-class/test renamed to sbt-dotty/sbt-test/source-dependencies/value-class/pending

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
## This failing test is pending because it will be solved by removing sbt-dotty
2+
13
## Case 1: value class as parameter of method
24
$ copy-file changes/A0.scala src/main/scala/A.scala
35
$ copy-file changes/B0.scala src/main/scala/B.scala

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,10 @@ object DottyPlugin extends AutoPlugin {
269269
scalaBinaryVersion := {
270270
scalaVersion.value.split("[\\.-]").toList match {
271271
case "0" :: minor :: _ => s"0.$minor"
272-
case "3" :: minor :: patch :: suffix =>
273-
s"3.$minor.$patch" + (suffix match {
274-
case milestone :: _ => s"-$milestone"
275-
case Nil => ""
276-
})
272+
case "3" :: "0" :: "0" :: milestone :: _ =>
273+
s"3.0.0-$milestone"
274+
case "3" :: _ =>
275+
"3"
277276
case _ => scalaBinaryVersion.value
278277
}
279278
},

0 commit comments

Comments
 (0)