Skip to content

Commit bf8c48b

Browse files
committed
improvement: Correctly download Scala 2 bridge for Scala 2.13.12
In preparation for the new Scala 2.13.12 release
1 parent c2f24c0 commit bf8c48b

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

backend/src/main/scala/bloop/ScalaInstance.scala

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import bloop.internal.build.BloopScalaInfo
1717
import bloop.logging.DebugFilter
1818
import bloop.logging.Logger
1919

20+
import coursierapi.Repository
21+
2022
final class ScalaInstance private (
2123
val organization: String,
2224
val name: String,
@@ -195,12 +197,14 @@ object ScalaInstance {
195197
scalaOrg: String,
196198
scalaName: String,
197199
scalaVersion: String,
198-
logger: Logger
200+
logger: Logger,
201+
additionalRepositories: List[Repository] = Nil
199202
): ScalaInstance = {
200203
def resolveInstance: ScalaInstance = {
201204
val allPaths = DependencyResolution.resolve(
202205
List(DependencyResolution.Artifact(scalaOrg, scalaName, scalaVersion)),
203-
logger
206+
logger,
207+
additionalRepos = additionalRepositories
204208
)
205209
val allJars = allPaths.collect {
206210
case path if path.underlying.toString.endsWith(".jar") => path.underlying.toFile

backend/src/main/scala/sbt/internal/inc/BloopComponentCompiler.scala

+19-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import xsbti.ComponentProvider
2727
import xsbti.Logger
2828
import xsbti.compile.ClasspathOptionsUtil
2929
import xsbti.compile.CompilerBridgeProvider
30+
import scala.util.control.NonFatal
3031

3132
object BloopComponentCompiler {
3233
import xsbti.compile.ScalaInstance
@@ -44,11 +45,22 @@ object BloopComponentCompiler {
4445

4546
private val CompileConf = Some(Configurations.Compile.name)
4647
def getModuleForBridgeSources(scalaInstance: ScalaInstance): ModuleID = {
48+
val isAfter2_13_11 =
49+
try {
50+
val Array(_, _, patch) = scalaInstance.version().split("\\.")
51+
val patchTrimmed = patch.takeWhile(_.isDigit).toInt
52+
scalaInstance.version().startsWith("2.13.") && patchTrimmed >= 12
53+
} catch {
54+
case NonFatal(_) => false
55+
}
56+
4757
def compilerBridgeId(scalaVersion: String) = {
58+
4859
// Defaults to bridge for 2.13 for Scala versions bigger than 2.13.x
4960
scalaVersion match {
5061
case sc if (sc startsWith "0.") => "dotty-sbt-bridge"
5162
case sc if (sc startsWith "3.") => "scala3-sbt-bridge"
63+
case _ if isAfter2_13_11 => "scala2-sbt-bridge"
5264
case sc if (sc startsWith "2.10.") => "compiler-bridge_2.10"
5365
case sc if (sc startsWith "2.11.") => "compiler-bridge_2.11"
5466
case sc if (sc startsWith "2.12.") => "compiler-bridge_2.12"
@@ -57,7 +69,7 @@ object BloopComponentCompiler {
5769
}
5870

5971
val (isDotty, organization, version) = scalaInstance match {
60-
case instance: BloopScalaInstance if instance.isDotty =>
72+
case instance: BloopScalaInstance if instance.isDotty || isAfter2_13_11 =>
6173
(true, instance.organization, instance.version)
6274
case _ => (false, "org.scala-sbt", latestVersion)
6375
}
@@ -250,7 +262,12 @@ private[inc] class BloopComponentCompiler(
250262
.Artifact(bridgeSources.organization, bridgeSources.name, bridgeSources.revision)
251263
),
252264
logger,
253-
resolveSources = shouldResolveSources
265+
resolveSources = shouldResolveSources,
266+
List(
267+
coursierapi.MavenRepository.of(
268+
"https://scala-ci.typesafe.com/artifactory/scala-integration/"
269+
)
270+
)
254271
) match {
255272
case Right(paths) => paths.map(_.underlying).toVector
256273
case Left(t) =>

frontend/src/test/scala/bloop/ScalaVersionsSpec.scala

+13-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import bloop.task.Task
1010
import bloop.util.TestProject
1111
import bloop.util.TestUtil
1212

13+
import coursierapi.MavenRepository
14+
1315
object ScalaVersionsSpec extends bloop.testing.BaseSuite {
1416
var loggers: List[RecordingLogger] = Nil
1517

@@ -22,7 +24,15 @@ object ScalaVersionsSpec extends bloop.testing.BaseSuite {
2224

2325
def jarsForScalaVersion(version: String, logger: RecordingLogger) = {
2426
ScalaInstance
25-
.resolve(compilerOrg, compilerArtifact, version, logger)
27+
.resolve(
28+
compilerOrg,
29+
compilerArtifact,
30+
version,
31+
logger,
32+
List(
33+
MavenRepository.of("https://scala-ci.typesafe.com/artifactory/scala-integration/")
34+
)
35+
)
2636
.allJars
2737
.map(AbsolutePath(_))
2838
}
@@ -66,7 +76,8 @@ object ScalaVersionsSpec extends bloop.testing.BaseSuite {
6676
"2.12.17",
6777
"2.13.10",
6878
"3.1.3",
69-
"3.2.1"
79+
"3.2.1",
80+
"2.13.12-bin-86f40c2"
7081
)
7182

7283
val allVersions = scalaVersions

0 commit comments

Comments
 (0)