Skip to content

Commit c4d4fe1

Browse files
committed
sbt-dotty: fix dotty retrieval when bootstrapping dotty
In the dotty build, we rely on sbt-dotty to get the reference compiler and its dependencies. But when using a locally-published dotty as the reference compiler I ran into a situation where sbt-dotty failed to get some of the artifacts. It seems that this happens because it confuses the locally-published projects with the projects in the current build. Fixed by tweaking the way sbt-dotty retrieves dotty to make sure it never considers projects from the current build.
1 parent 91fc151 commit c4d4fe1

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,15 @@ object DottyPlugin extends AutoPlugin {
404404

405405
/** Create a scalaInstance task that uses Dotty based on `moduleName`. */
406406
def dottyScalaInstanceTask(moduleName: String): Initialize[Task[ScalaInstance]] = Def.task {
407+
val ivyConfig0 = mkIvyConfiguration.value
408+
// When compiling non-bootstrapped projects in the build of Dotty itself,
409+
// dependency resolution might pick a local project which is not what we
410+
// want. We avoid this by dropping the inter-project resolver.
411+
val ivyConfig1 = ivyConfig0.withResolvers(ivyConfig0.resolvers.filter(_.name != "inter-project"))
407412
val updateReport =
408413
fetchArtifactsOf(
409414
scalaOrganization.value %% moduleName % scalaVersion.value,
410-
dependencyResolution.value,
415+
ivy.IvyDependencyResolution(ivyConfig1),
411416
scalaModuleInfo.value,
412417
updateConfiguration.value,
413418
(unresolvedWarningConfiguration in update).value,
@@ -431,6 +436,25 @@ object DottyPlugin extends AutoPlugin {
431436
)
432437
}
433438

439+
// Copy-pasted from sbt until we upgrade to a version of sbt
440+
// with https://github.com/sbt/sbt/pull/5271 in.
441+
def mkIvyConfiguration: Initialize[Task[InlineIvyConfiguration]] =
442+
Def.task {
443+
val (rs, other) = (fullResolvers.value.toVector, otherResolvers.value.toVector)
444+
val s = streams.value
445+
Classpaths.warnResolversConflict(rs ++: other, s.log)
446+
InlineIvyConfiguration()
447+
.withPaths(ivyPaths.value)
448+
.withResolvers(rs)
449+
.withOtherResolvers(other)
450+
.withModuleConfigurations(moduleConfigurations.value.toVector)
451+
.withLock(Defaults.lock(appConfiguration.value))
452+
.withChecksums((checksums in update).value.toVector)
453+
.withResolutionCacheDir(crossTarget.value / "resolution-cache")
454+
.withUpdateOptions(updateOptions.value)
455+
.withLog(s.log)
456+
}
457+
434458
def makeScalaInstance(
435459
state: State, dottyVersion: String, scalaLibrary: File, dottyLibrary: File, compiler: File, all: Seq[File]
436460
): ScalaInstance = {

0 commit comments

Comments
 (0)