Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

work around 'data has not been loaded' exception when direct dependen…

…cy overridden by newer version
  • Loading branch information...
commit 5fa93ca9f97fc09d27981d1f1667d699c4886208 1 parent 6312978
@harrah authored
View
18 ivy/Ivy.scala
@@ -141,9 +141,9 @@ final class IvySbt(val configuration: IvyConfiguration)
log.debug("Using inline dependencies specified in Scala" + (if(ivyXML.isEmpty) "." else " and XML."))
val parser = IvySbt.parseIvyXML(ivy.getSettings, IvySbt.wrapped(module, ivyXML), moduleID, defaultConf.name, validate)
- IvySbt.addDependencies(moduleID, dependencies, parser)
IvySbt.addMainArtifact(moduleID)
- IvySbt.addOverrides(moduleID, overrides, ivy.getSettings.getMatcher(PatternMatcher.EXACT_OR_REGEXP))
+ IvySbt.addOverrides(moduleID, overrides, ivy.getSettings.getMatcher(PatternMatcher.EXACT))
+ IvySbt.addDependencies(moduleID, IvySbt.overrideDirect(dependencies, overrides), parser)
(moduleID, parser.getDefaultConf)
}
private def newConfiguredModuleID(module: ModuleID, moduleInfo: ModuleInfo, configurations: Iterable[Configuration]) =
@@ -440,6 +440,20 @@ private object IvySbt
val overrideWith = new OverrideDependencyDescriptorMediator(null, overrideDef.revision)
moduleID.addDependencyDescriptorMediator(overrideID, matcher, overrideWith)
}
+ /** It is necessary to explicitly modify direct dependencies because Ivy gives
+ * "IllegalStateException: impossible to get artifacts when data has not been loaded."
+ * when a direct dependency is overridden with a newer version."*/
+ def overrideDirect(dependencies: Seq[ModuleID], overrides: Set[ModuleID]): Seq[ModuleID] =
+ {
+ def key(id: ModuleID) = (id.organization, id.name)
+ val overridden = overrides.map(id => (key(id), id.revision)).toMap
+ dependencies map { dep =>
+ overridden get key(dep) match {
+ case Some(rev) => dep.copy(revision = rev)
+ case None => dep
+ }
+ }
+ }
/** This method is used to add inline artifacts to the provided module. */
def addArtifacts(moduleID: DefaultModuleDescriptor, artifacts: Iterable[Artifact]): Unit =
View
6 sbt/src/sbt-test/dependency-management/override/build.sbt
@@ -1,6 +1,10 @@
autoScalaLibrary := false
-libraryDependencies += "junit" % "junit" % "4.5" % "test"
+ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache")))
+
+ivyScala <<= (scalaVersion in update, scalaBinaryVersion in update) { (fv, bv) =>
+ Some(new IvyScala(fv, bv, Nil, filterImplicit = false, checkExplicit = false, overrideScalaVersion = false))
+}
InputKey[Unit]("check") <<= inputTask { args =>
(update, args) map {
View
13 sbt/src/sbt-test/dependency-management/override/test
@@ -1,8 +1,19 @@
+> 'set libraryDependencies := Seq("junit" % "junit" % "3.8.1" % "test")'
+> check 3.8.1
+> 'set dependencyOverrides := Set("junit" % "junit" % "4.5")'
+> check 4.5
+
+> 'set libraryDependencies := Seq("junit" % "junit" % "4.5" % "test")'
> check 4.5
> 'set dependencyOverrides := Set("junit" % "junit" % "3.8.1")'
> check 3.8.1
-> 'set libraryDependencies := Seq("net.databinder" %% "dispatch-http" % "0.8.7" intransitive())'
+> 'set libraryDependencies := Seq("net.databinder" %% "dispatch-http" % "0.8.7")'
> check 0.8.7
> 'set dependencyOverrides := Set("net.databinder" %% "dispatch-http" % "0.8.6")'
> check 0.8.6
+
+> 'set libraryDependencies := Seq("net.databinder" %% "dispatch-http" % "0.8.6")'
+> check 0.8.6
+> 'set dependencyOverrides := Set("net.databinder" %% "dispatch-http" % "0.8.7")'
+> check 0.8.7
View
7 sbt/src/sbt-test/dependency-management/override2/build.sbt
@@ -0,0 +1,7 @@
+sbtBinaryVersion := "0.11.2"
+
+addSbtPlugin("com.typesafe.sbtscalariform" % "sbtscalariform" % "0.3.0")
+
+resolvers += Classpaths.typesafeResolver
+
+dependencyOverrides := Set("com.typesafe.sbtscalariform" % "sbtscalariform" % "0.3.1")
View
1  sbt/src/sbt-test/dependency-management/override2/test
@@ -0,0 +1 @@
+> update
Please sign in to comment.
Something went wrong with that request. Please try again.