mirror of https://github.com/sbt/sbt.git
[2.x and 1.x] Respect `scalaOrganization` in compiler bridge resolution
**Problem** `scalaOrganization` was ignored during compiler bridge resolution because `ZincLmUtil.getDefaultBridgeModule` hard-coded `ScalaArtifacts.Organization` (`org.scala-lang`). **Solution** Add a `scalaOrganization` parameter to `ZincLmUtil` methods, and passing `scalaOrganization` value to those methods. I'm wondering how can we test this change, we can write scripted tests that resolves `io.github.scala-wasm` repo, but relying on external repositories might be fragile? Generated-by: Claude Opus 4.6
This commit is contained in:
parent
6d94d6db61
commit
e31df21730
|
|
@ -749,6 +749,7 @@ object Defaults extends BuildCommon {
|
|||
val r = dependencyResolution.value
|
||||
val uc = updateConfiguration.value
|
||||
val jar = ZincLmUtil.fetchDefaultBridgeModule(
|
||||
scalaOrganization.value,
|
||||
sv,
|
||||
r,
|
||||
uc,
|
||||
|
|
@ -768,12 +769,14 @@ object Defaults extends BuildCommon {
|
|||
if b.nonEmpty then Def.task { b }
|
||||
else Compiler.scalaCompilerBridgeJarsTask(scalaCompilerBridgeSource, s.log)
|
||||
}).value,
|
||||
scalaCompilerBridgeSource := ZincLmUtil.getDefaultBridgeSourceModule(scalaVersion.value),
|
||||
scalaCompilerBridgeSource := ZincLmUtil
|
||||
.getDefaultBridgeSourceModule(scalaOrganization.value, scalaVersion.value),
|
||||
auxiliaryClassFiles ++= {
|
||||
if (ScalaArtifacts.isScala3(scalaVersion.value)) List(TastyFiles.instance)
|
||||
else Nil
|
||||
},
|
||||
consoleProject / scalaCompilerBridgeSource := ZincLmUtil.getDefaultBridgeSourceModule(
|
||||
ScalaArtifacts.Organization,
|
||||
appConfiguration.value.provider.scalaProvider.version
|
||||
),
|
||||
classpathOptions := ClasspathOptionsUtil.noboot(scalaVersion.value),
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import sbt.internal.util.Attributed
|
|||
import sbt.internal.util.appmacro.ContextUtil
|
||||
import sbt.internal.server.BuildServerEvalReporter
|
||||
import sbt.io.{ GlobFilter, IO }
|
||||
import sbt.librarymanagement.{ Configuration, Configurations, IvyPaths, Resolver }
|
||||
import sbt.librarymanagement.{ Configuration, Configurations, IvyPaths, Resolver, ScalaArtifacts }
|
||||
import sbt.nio.Settings
|
||||
import sbt.util.{ Logger, Show }
|
||||
import xsbti.{ FileConverter, HashedVirtualFileRef, VirtualFile }
|
||||
|
|
@ -105,7 +105,8 @@ private[sbt] object Load {
|
|||
componentProvider = app.provider.components,
|
||||
secondaryCacheDir = Option(zincDir),
|
||||
dependencyResolution = dependencyResolution,
|
||||
compilerBridgeSource = ZincLmUtil.getDefaultBridgeSourceModule(scalaProvider.version),
|
||||
compilerBridgeSource =
|
||||
ZincLmUtil.getDefaultBridgeSourceModule(ScalaArtifacts.Organization, scalaProvider.version),
|
||||
scalaJarsTarget = zincDir,
|
||||
state.get(BasicKeys.classLoaderCache),
|
||||
log = log
|
||||
|
|
|
|||
|
|
@ -71,7 +71,12 @@ private[sbt] object ZincComponentCompiler {
|
|||
override def fetchCompiledBridge(scalaInstance: XScalaInstance, logger: Logger): File = {
|
||||
val scalaVersion = scalaInstance.actualVersion()
|
||||
val bridgeSources = userProvidedBridgeSources
|
||||
.getOrElse(ZincLmUtil.getDefaultBridgeSourceModule(scalaVersion))
|
||||
.getOrElse(
|
||||
ZincLmUtil.getDefaultBridgeSourceModule(
|
||||
sbt.librarymanagement.ScalaArtifacts.Organization,
|
||||
scalaVersion
|
||||
)
|
||||
)
|
||||
compiledBridge(bridgeSources, scalaInstance, logger)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,13 +84,14 @@ object ZincLmUtil {
|
|||
compilerBridgeProvider.fetchCompiledBridge(scalaInstance, log) :: Nil
|
||||
|
||||
def fetchDefaultBridgeModule(
|
||||
scalaOrganization: String,
|
||||
scalaVersion: String,
|
||||
dependencyResolution: DependencyResolution,
|
||||
updateConfiguration: UpdateConfiguration,
|
||||
warningConfig: UnresolvedWarningConfiguration,
|
||||
logger: Logger
|
||||
): File = {
|
||||
val bridgeModule = getDefaultBridgeModule(scalaVersion)
|
||||
val bridgeModule = getDefaultBridgeModule(scalaOrganization, scalaVersion)
|
||||
val descriptor = dependencyResolution.wrapDependencyInModule(bridgeModule)
|
||||
dependencyResolution
|
||||
.update(descriptor, updateConfiguration, warningConfig, logger)
|
||||
|
|
@ -108,12 +109,12 @@ object ZincLmUtil {
|
|||
.getOrElse(throw new MessageOnlyException(s"Missing $bridgeModule"))
|
||||
}
|
||||
|
||||
def getDefaultBridgeModule(scalaVersion: String): ModuleID = {
|
||||
def getDefaultBridgeModule(scalaOrganization: String, scalaVersion: String): ModuleID = {
|
||||
if (ScalaArtifacts.isScala3(scalaVersion)) {
|
||||
ModuleID(ScalaArtifacts.Organization, "scala3-sbt-bridge", scalaVersion)
|
||||
ModuleID(scalaOrganization, "scala3-sbt-bridge", scalaVersion)
|
||||
.withConfigurations(Some(Compile.name))
|
||||
} else if (hasScala2SbtBridge(scalaVersion)) {
|
||||
ModuleID(ScalaArtifacts.Organization, "scala2-sbt-bridge", scalaVersion)
|
||||
ModuleID(scalaOrganization, "scala2-sbt-bridge", scalaVersion)
|
||||
.withConfigurations(Some(Compile.name))
|
||||
} else {
|
||||
val compilerBridgeId = scalaVersion match {
|
||||
|
|
@ -128,6 +129,6 @@ object ZincLmUtil {
|
|||
}
|
||||
}
|
||||
|
||||
def getDefaultBridgeSourceModule(scalaVersion: String): ModuleID =
|
||||
getDefaultBridgeModule(scalaVersion).sources()
|
||||
def getDefaultBridgeSourceModule(scalaOrganization: String, scalaVersion: String): ModuleID =
|
||||
getDefaultBridgeModule(scalaOrganization, scalaVersion).sources()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ abstract class IvyBridgeProviderSpecification
|
|||
case Some(v: String) => v
|
||||
case _ => throw new IllegalStateException("No zinc version specified")
|
||||
}
|
||||
val bridge0 = ZincLmUtil.getDefaultBridgeSourceModule(scalaVersion)
|
||||
val bridge0 = ZincLmUtil.getDefaultBridgeSourceModule(ScalaArtifacts.Organization, scalaVersion)
|
||||
// redefine the compiler bridge version
|
||||
// using the version of zinc used during testing
|
||||
// this way when building with zinc as a source dependency
|
||||
|
|
|
|||
Loading…
Reference in New Issue