Skip to content

Commit 99d73b6

Browse files
committed
Add Scala 3 artifacts
1 parent 8353364 commit 99d73b6

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

core/src/main/scala/sbt/librarymanagement/ScalaArtifacts.scala

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,46 @@ object ScalaArtifacts {
88
val ActorsID = "scala-actors"
99
val ScalapID = "scalap"
1010
val Artifacts = Vector(LibraryID, CompilerID, ReflectID, ActorsID, ScalapID)
11-
val DottyIDPrefix = "dotty"
1211

13-
def dottyID(binaryVersion: String): String = s"${DottyIDPrefix}_${binaryVersion}"
12+
val Scala3LibraryID = "scala3-library"
13+
val Scala3CompilerID = "scala3-compiler"
1414

15-
def libraryDependency(version: String): ModuleID = ModuleID(Organization, LibraryID, version)
15+
def isScala3(scalaVersion: String): Boolean = scalaVersion.startsWith("3.")
16+
17+
def libraryIds(version: String): Array[String] = {
18+
if (isScala3(version))
19+
Array(Scala3LibraryID, LibraryID)
20+
else Array(LibraryID)
21+
}
22+
23+
def compilerId(version: String): String = {
24+
if (isScala3(version)) Scala3CompilerID
25+
else CompilerID
26+
}
27+
28+
def libraryDependency(version: String): ModuleID = libraryDependency(Organization, version)
29+
30+
def libraryDependency(org: String, version: String): ModuleID = {
31+
if (isScala3(version))
32+
ModuleID(org, Scala3LibraryID, version).withCrossVersion(CrossVersion.binary)
33+
else
34+
ModuleID(org, LibraryID, version)
35+
}
1636

1737
private[sbt] def toolDependencies(
1838
org: String,
19-
version: String,
20-
isDotty: Boolean = false
39+
version: String
2140
): Seq[ModuleID] =
22-
if (isDotty)
41+
if (isScala3(version))
2342
Seq(
24-
ModuleID(org, DottyIDPrefix, version)
43+
ModuleID(org, Scala3CompilerID, version)
2544
.withConfigurations(Some(Configurations.ScalaTool.name + "->default(compile)"))
2645
.withCrossVersion(CrossVersion.binary)
2746
)
2847
else
2948
Seq(
30-
scalaToolDependency(org, ScalaArtifacts.CompilerID, version),
31-
scalaToolDependency(org, ScalaArtifacts.LibraryID, version)
49+
scalaToolDependency(org, CompilerID, version),
50+
scalaToolDependency(org, LibraryID, version)
3251
)
3352

3453
private[this] def scalaToolDependency(org: String, id: String, version: String): ModuleID =

0 commit comments

Comments
 (0)