Fixes #1616. Fixes the "latest snapshot" chain resolver

The "latest snapshot" chain resolver was assuming that there's at least
one artifact per module. I think that was the root cause of #1616.
This commit is contained in:
Eugene Yokota 2015-12-30 04:46:20 -05:00
parent 883255b05a
commit 7f2ab136e5
4 changed files with 39 additions and 46 deletions

View File

@ -1,12 +1,14 @@
[@eed3si9n]: https://github.com/eed3si9n
[1514]: https://github.com/sbt/sbt/issues/1514
[1616]: https://github.com/sbt/sbt/issues/1616
[2313]: https://github.com/sbt/sbt/pull/2313
### Fixes with compatibility implications
- Fixes update option's `withLatestSnapshots` so it handles modules without an artifact. This flag will be enabled by default.
[#1514][1514]/[#1616][1616]/[#2313][2313] by [@eed3si9n][@eed3si9n]
### Improvements
### Bug fixes
- Turns update option's `withLatestSnapshots` flag `true` by default.
[#1514][1514] by [@eed3si9n][@eed3si9n]

View File

@ -1,44 +1,31 @@
name := "test-parent-pom"
val localMavenRepo = file("local-repo")
val cleanExampleCache = taskKey[Unit]("Cleans the example cache.")
resolvers +=
MavenRepository("Maven2 Local Test", localMavenRepo.toURI.toString)
libraryDependencies +=
"com.example" % "example-child" % "1.0-SNAPSHOT"
libraryDependencies += "org.apache.geronimo.specs" % "geronimo-jta_1.1_spec" % "1.1.1"
version := "1.0-SNAPSHOT"
cleanExampleCache := {
ivySbt.value.withIvy(streams.value.log) { ivy =>
val cacheDir = ivy.getSettings.getDefaultRepositoryCacheBasedir
// TODO - Is this actually ok?
IO.delete(cacheDir / "com.example")
}
}
val checkIvyXml = taskKey[Unit]("Checks the ivy.xml transform was correct")
lazy val root = (project in file(".")).
settings(
name := "test-parent-pom",
ivyPaths := new IvyPaths( (baseDirectory in ThisBuild).value, Some((target in LocalRootProject).value / "ivy-cache")),
resolvers += MavenCache("Maven2 Local Test", baseDirectory.value / "local-repo"),
libraryDependencies += "com.example" % "example-child" % "1.0-SNAPSHOT",
libraryDependencies += "org.apache.geronimo.specs" % "geronimo-jta_1.1_spec" % "1.1.1",
version := "1.0-SNAPSHOT",
autoScalaLibrary := false,
checkIvyXml := {
ivySbt.value.withIvy(streams.value.log) { ivy =>
val cacheDir = ivy.getSettings.getDefaultRepositoryCacheBasedir
val xmlFile =
cacheDir / "org.apache.geronimo.specs" / "geronimo-jta_1.1_spec" / "ivy-1.1.1.xml"
val lines = IO.read(xmlFile)
if(lines.isEmpty) sys.error(s"Unable to read $xmlFile, could not resolve geronimo...")
// Note: We do not do this if the maven plguin is enabled, because there is no rewrite of ivy.xml, extra attribtues
// are handled in a different mechanism. This is a hacky mechanism to detect that.
val isMavenResolver = updateOptions.value.resolverConverter != PartialFunction.empty
if(!isMavenResolver) assert(lines contains "xmlns:e", s"Failed to appropriately modify ivy.xml file for sbt extra attributes!\n$lines")
checkIvyXml := {
ivySbt.value.withIvy(streams.value.log) { ivy =>
val cacheDir = ivy.getSettings.getDefaultRepositoryCacheBasedir
// TODO - Is this actually ok?
val xmlFile =
cacheDir / "org.apache.geronimo.specs" / "geronimo-jta_1.1_spec" / "ivy-1.1.1.xml"
//cacheDir / "com.example" / "example-child" / "ivy-1.0-SNAPSHOT.xml"
val lines = IO.read(xmlFile)
if(lines.isEmpty) sys.error(s"Unable to read $xmlFile, could not resolve geronimo...")
// Note: We do not do this if the maven plguin is enabled, because there is no rewrite of ivy.xml, extra attribtues
// are handled in a different mechanism. This is a hacky mechanism to detect that.
val isMavenResolver = updateOptions.value.resolverConverter != PartialFunction.empty
if(!isMavenResolver) assert(lines contains "xmlns:e", s"Failed to appropriately modify ivy.xml file for sbt extra attributes!\n$lines")
}
}
val xmlFile2 = cacheDir / "com.example" / "example-child" / "ivy-1.0-SNAPSHOT.xml"
val lines2 = IO.read(xmlFile2)
if (!isMavenResolver) {
assert(lines2 contains "Apache-2.0", s"Failed to roll up license from the parent POM!\n$lines2")
}
}
}
)

View File

@ -6,5 +6,10 @@
<artifactId>example-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<licenses>
<license>
<name>Apache-2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
</project>

View File

@ -1,3 +1,2 @@
> cleanExampleCache
> update
> checkIvyXml