Fixes #2686 by resetting scalaVersion for updateSbtClassifiers

Ref #2634

updateSbtClassifiers uses an artificially created dependency graph set
in classifiersModule. The problem is that ivyScala instance is reused
from the outer scope that has the user project's scalaVersion as
demonstrated as follows:

    scala> val is = (ivyScala in updateSbtClassifiers).eval
    is: Option[sbt.IvyScala] =
Some(IvyScala(2.9.3,2.9.3,List(),true,false,true,org.scala-lang))

This change fixes #2686 by redefining ivyScala with scalaVersion and
scalaBinaryVersion scoped to updateSbtClassifiers task. The existing
scripted test was modified to reproduce the bug.
This commit is contained in:
Eugene Yokota 2016-08-05 01:21:06 -04:00
parent a98ec6b779
commit ca12418eb8
3 changed files with 11 additions and 2 deletions

View File

@ -1322,6 +1322,14 @@ object Classpaths {
val pluginIDs: Seq[ModuleID] = pluginJars.flatMap(_ get moduleID.key)
GetClassifiersModule(pid, sbtDep +: pluginIDs, Configurations.Default :: Nil, classifiers)
},
// Redefine scalaVersion and scalaBinaryVersion specifically for the dependency graph used for updateSbtClassifiers task.
// to fix https://github.com/sbt/sbt/issues/2686
scalaVersion := appConfiguration.value.provider.scalaProvider.version,
scalaBinaryVersion := binaryScalaVersion(scalaVersion.value),
ivyScala := {
Some(new IvyScala(scalaVersion.value, scalaBinaryVersion.value, Nil, filterImplicit = false, checkExplicit = false,
overrideScalaVersion = true, scalaOrganization = scalaOrganization.value))
},
updateSbtClassifiers in TaskGlobal <<= Def.task {
val s = streams.value
val is = ivySbt.value
@ -1332,7 +1340,7 @@ object Classpaths {
val uwConfig = (unresolvedWarningConfiguration in update).value
val depDir = dependencyCacheDirectory.value
withExcludes(out, mod.classifiers, lock(app)) { excludes =>
val noExplicitCheck = ivyScala.value.map(_.copy(checkExplicit = false))
val noExplicitCheck = ivyScala.value
IvyActions.transitiveScratch(is, "sbt", GetClassifiersConfiguration(mod, excludes, c, noExplicitCheck), uwConfig, LogicalClock(state.value.hashCode), Some(depDir), s.log)
}
} tag (Tags.Update, Tags.Network)

View File

@ -0,0 +1 @@
scalaVersion := "2.9.2"

View File

@ -1 +1 @@
> update-sbt-classifiers
> updateSbtClassifiers