Skip to content

Commit 5d06f3b

Browse files
authored
Merge pull request #2712 from tgodzik/bridge-impr
improvement: Make sure onl sbt bridge is used for bridge artifacts
2 parents 5457f2b + e138d03 commit 5d06f3b

4 files changed

Lines changed: 39 additions & 8 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ object ScalaInstance {
181181
scalaVersion: String,
182182
allJars: Seq[AbsolutePath],
183183
logger: Logger,
184-
bridgeJarsOpt: Option[Seq[AbsolutePath]]
184+
bridgeJarsOpt: Option[Seq[AbsolutePath]],
185+
additionalRepositories: List[Repository] = Nil
185186
): ScalaInstance = {
186187
val jarsKey = allJars.map(_.underlying).sortBy(_.toString).toList
187188
if (allJars.nonEmpty) {
@@ -202,7 +203,7 @@ object ScalaInstance {
202203
val nonExistingJars = allJars.filter(j => !Files.exists(j.underlying))
203204
nonExistingJars.foreach(p => logger.error(s"Scala instance jar ${p.syntax} doesn't exist!"))
204205
instancesByJar.computeIfAbsent(jarsKey, _ => newInstance)
205-
} else resolve(scalaOrg, scalaName, scalaVersion, logger)
206+
} else resolve(scalaOrg, scalaName, scalaVersion, logger, additionalRepositories)
206207
}
207208

208209
// Cannot wait to use opaque types for this

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ private[inc] class BloopComponentCompiler(
279279
List(
280280
coursierapi.MavenRepository.of(
281281
"https://scala-ci.typesafe.com/artifactory/scala-integration/"
282-
)
282+
),
283+
coursierapi.MavenRepository
284+
.of("https://repo.scala-lang.org/artifactory/maven-nightlies")
283285
)
284286
) match {
285287
case Right(paths) => paths.map(_.underlying).toVector
@@ -288,10 +290,12 @@ private[inc] class BloopComponentCompiler(
288290
throw new InvalidComponent(msg, t)
289291
}
290292
}
291-
292293
if (!shouldResolveSources) {
293-
// This is usually true in the Dotty case, that has a pre-compiled compiler
294-
manager.define(compilerBridgeId, allArtifacts.map(_.toFile()))
294+
// This is usually true in the Dotty case, that has a pre-compiled compiler, only take the bridge jar
295+
manager.define(
296+
compilerBridgeId,
297+
allArtifacts.find(_.toString().contains(bridgeSources.name)).toList.map(_.toFile())
298+
)
295299
} else {
296300
val (sources, xsbtiJars) =
297301
allArtifacts.partition(_.toFile.getName.endsWith("-sources.jar"))

frontend/src/test/scala/bloop/BaseCompileSpec.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ abstract class BaseCompileSpec extends bloop.testing.BaseSuite {
7070
}
7171
}
7272

73+
checkCompiles(
74+
"scala3-nightly",
75+
ExitStatus.Ok,
76+
"3.8.0-RC1-bin-20250825-25092c7-NIGHTLY",
77+
"""|class Foo:
78+
| def foo: Int = 1
79+
|""".stripMargin
80+
)
81+
7382
// https://github.com/scala/scala3/issues/22026
7483
checkCompiles(
7584
"scala3-i22026",

frontend/src/test/scala/bloop/util/TestProject.scala

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import bloop.io.RelativePath
2121
import bloop.logging.Logger
2222
import bloop.logging.NoopLogger
2323
import bloop.util.TestUtil.ProjectArchetype
24+
import coursierapi.MavenRepository
2425

2526
final case class TestProject(
2627
config: Config.Project,
@@ -217,10 +218,26 @@ abstract class BaseTestProject {
217218
scalaVersion: Option[String],
218219
allJars: Seq[AbsolutePath],
219220
logger: Logger
220-
): ScalaInstance =
221+
): ScalaInstance = {
222+
val additionalRepositories = if (scalaVersion.exists(_.contains("NIGHTLY"))) {
223+
List(MavenRepository.of("https://repo.scala-lang.org/artifactory/maven-nightlies"))
224+
} else {
225+
Nil
226+
}
221227
scalaVersion
222-
.map(v => ScalaInstance.apply(scalaOrg, scalaName, v, allJars, logger))
228+
.map(v =>
229+
ScalaInstance.apply(
230+
scalaOrg,
231+
scalaName,
232+
v,
233+
allJars,
234+
logger,
235+
None,
236+
additionalRepositories
237+
)
238+
)
223239
.getOrElse(TestUtil.scalaInstance)
240+
}
224241

225242
def populateWorkspaceInConfigDir(
226243
configDir: AbsolutePath,

0 commit comments

Comments
 (0)