Skip to content

Commit 6dbf28a

Browse files
authored
Merge pull request #12084 from adpi2/backport-scalabinaryversion
Backport: sbt-dotty: the binary version is 3 for Scala >= 3.0.0
2 parents 21c6e8d + 55018fe commit 6dbf28a

File tree

7 files changed

+30
-22
lines changed

7 files changed

+30
-22
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,9 @@ jobs:
348348
- name: Add SBT proxy repositories
349349
run: cp -vf .github/workflows/repositories /root/.sbt/ ; true
350350

351-
- name: Test sbt 1.4.x
351+
- name: Test sbt
352352
run: ./project/scripts/sbt "sbt-dotty/scripted; sbt-community-build/scripted"
353353

354-
- name: Test sbt 1.5.x
355-
run: ./project/scripts/sbt "set \`sbt-dotty\`/scriptedSbt := \"1.5.0-RC1\"; sbt-dotty/scripted sbt-dotty/*"
356-
357354
test_java8:
358355
runs-on: [self-hosted, Linux]
359356
container:
Submodule stdLib213 updated 705 files

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

Lines changed: 15 additions & 11 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
@@ -40,6 +42,7 @@ sealed trait CommunityProject:
4042
val dependencies: List[CommunityProject]
4143
val binaryName: String
4244
val runCommandsArgs: List[String] = Nil
45+
val environment: Map[String, String] = Map.empty
4346

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

@@ -53,7 +56,7 @@ sealed trait CommunityProject:
5356
log(s"Publishing $project")
5457
if publishCommand eq null then
5558
throw RuntimeException(s"Publish command is not specified for $project. Project details:\n$this")
56-
val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ publishCommand): _*)
59+
val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ publishCommand), environment)
5760
if exitCode != 0 then
5861
throw RuntimeException(s"Publish command exited with code $exitCode for project $project. Project details:\n$this")
5962
published = true
@@ -63,11 +66,11 @@ sealed trait CommunityProject:
6366
log(s"Documenting $project")
6467
if docCommand eq null then
6568
throw RuntimeException(s"Doc command is not specified for $project. Project details:\n$this")
66-
val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ docCommand): _*)
69+
val exitCode = exec(projectDir, binaryName, (runCommandsArgs :+ docCommand), environment)
6770
if exitCode != 0 then
6871
throw RuntimeException(s"Doc command exited with code $exitCode for project $project. Project details:\n$this")
6972

70-
final def build(): Int = exec(projectDir, binaryName, buildCommands: _*)
73+
final def build(): Int = exec(projectDir, binaryName, buildCommands, environment)
7174

7275
final def buildCommands = runCommandsArgs :+ testCommand
7376

@@ -86,6 +89,7 @@ final case class MillCommunityProject(
8689
// uncomment once mill is released
8790
// if ignoreDocs then null else s"$baseCommand.docJar"
8891
override val runCommandsArgs = List("-i", "-D", s"dottyVersion=$compilerVersion")
92+
override val environment = Map("MILL_VERSION" -> "0.9.6-16-a5da34")
8993

9094
final case class SbtCommunityProject(
9195
project: String,
@@ -102,12 +106,12 @@ final case class SbtCommunityProject(
102106
scalacOptions.map("\"" + _ + "\"").mkString("List(", ",", ")")
103107

104108
private val baseCommand =
105-
"clean; set logLevel in Global := Level.Error; set updateOptions in Global ~= (_.withLatestSnapshots(false)); "
106-
++ (if scalacOptions.isEmpty then "" else s"""set scalacOptions in Global ++= $scalacOptionsString;""")
109+
"clean; set Global/logLevel := Level.Error; set Global/updateOptions ~= (_.withLatestSnapshots(false)); "
110+
++ (if scalacOptions.isEmpty then "" else s"""set Global/scalacOptions ++= $scalacOptionsString;""")
107111
++ s"++$compilerVersion!; "
108112

109113
override val testCommand =
110-
"""set testOptions in Global += Tests.Argument(TestFramework("munit.Framework"), "+l"); """
114+
"""set Global/testOptions += Tests.Argument(TestFramework("munit.Framework"), "+l"); """
111115
++ s"$baseCommand$sbtTestCommand"
112116

113117
override val publishCommand =
@@ -124,7 +128,7 @@ final case class SbtCommunityProject(
124128
case Some(ivyHome) => List(s"-Dsbt.ivy.home=$ivyHome")
125129
case _ => Nil
126130
extraSbtArgs ++ sbtProps ++ List(
127-
"-sbt-version", "1.4.9",
131+
"-sbt-version", "1.5.0",
128132
"-Dsbt.supershell=false",
129133
s"-Ddotty.communitybuild.dir=$communitybuildDir",
130134
s"--addPluginSbtFile=$sbtPluginFilePath"
@@ -140,12 +144,12 @@ object projects:
140144

141145
private def forceDoc(projects: String*) =
142146
projects.map(project =>
143-
s""";set $project/Compile/doc/sources ++= ($project/Compile/doc/tastyFiles).value ;$project/doc"""
147+
s""";set $project/Compile/doc/sources ++= ($project/Compile/doc/dotty.tools.sbtplugin.DottyPlugin.autoImport.tastyFiles).value ;$project/doc"""
144148
).mkString(" ")
145149

146150
private def aggregateDoc(in: String)(projects: String*) =
147151
val tastyFiles =
148-
(in +: projects).map(p => s"($p/Compile/doc/tastyFiles).value").mkString(" ++ ")
152+
(in +: projects).map(p => s"($p/Compile/doc/dotty.tools.sbtplugin.DottyPlugin.autoImport.tastyFiles).value").mkString(" ++ ")
149153
s""";set $in/Compile/doc/sources ++= file("a.scala") +: ($tastyFiles) ;$in/doc"""
150154

151155
lazy val utest = MillCommunityProject(
@@ -512,7 +516,7 @@ object projects:
512516

513517
lazy val cats = SbtCommunityProject(
514518
project = "cats",
515-
sbtTestCommand = "set scalaJSStage in Global := FastOptStage;buildJVM;validateAllJS",
519+
sbtTestCommand = "set Global/scalaJSStage := FastOptStage;buildJVM;validateAllJS",
516520
sbtPublishCommand = "catsJVM/publishLocal;catsJS/publishLocal",
517521
dependencies = List(discipline, disciplineMunit, scalacheck, simulacrumScalafixAnnotations),
518522
scalacOptions = SbtCommunityProject.scalacOptions.filter(_ != "-Ysafe-init") // disable -Ysafe-init, due to -Xfatal-warning

project/Build.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,12 @@ object Build {
12431243
baseDirectory.value / "../language-server/src/dotty/tools/languageserver/config",
12441244
sbtTestDirectory := baseDirectory.value / "sbt-test",
12451245

1246+
// ensure that sbt-dotty is built with sbt 1.4
1247+
pluginCrossBuild / sbtVersion := "1.4.9",
1248+
1249+
// scritped tests are run with current sbt version
1250+
scriptedSbt := sbtVersion.value,
1251+
12461252
// The batch mode accidentally became the default with no way to disable
12471253
// it in sbt 1.4 (https://github.com/sbt/sbt/issues/5913#issuecomment-716003195).
12481254
// We enable it explicitly here to make it clear that we're using it.

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.4.9
1+
sbt.version=1.5.0

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
@@ -264,11 +264,10 @@ object DottyPlugin extends AutoPlugin {
264264
scalaBinaryVersion := {
265265
scalaVersion.value.split("[\\.-]").toList match {
266266
case "0" :: minor :: _ => s"0.$minor"
267-
case "3" :: minor :: patch :: suffix =>
268-
s"3.$minor.$patch" + (suffix match {
269-
case milestone :: _ => s"-$milestone"
270-
case Nil => ""
271-
})
267+
case "3" :: "0" :: "0" :: milestone :: _ =>
268+
s"3.0.0-$milestone"
269+
case "3" :: _ =>
270+
"3"
272271
case _ => scalaBinaryVersion.value
273272
}
274273
},

0 commit comments

Comments
 (0)