mirror of https://github.com/sbt/sbt.git
more work on dependency management tests
This commit is contained in:
parent
de2d26d94c
commit
fee9429b03
|
|
@ -336,7 +336,7 @@ private object IvySbt
|
|||
{
|
||||
import module._
|
||||
<ivy-module version="2.0">
|
||||
{ if(hasInfo(dependencies))
|
||||
{ if(hasInfo(module, dependencies))
|
||||
NodeSeq.Empty
|
||||
else
|
||||
<info organisation={organization} module={name} revision={revision}/>
|
||||
|
|
@ -348,7 +348,24 @@ private object IvySbt
|
|||
}
|
||||
</ivy-module>
|
||||
}
|
||||
private def hasInfo(x: scala.xml.NodeSeq) = !(<g>{x}</g> \ "info").isEmpty
|
||||
private def hasInfo(module: ModuleID, x: scala.xml.NodeSeq) =
|
||||
{
|
||||
val info = <g>{x}</g> \ "info"
|
||||
if(!info.isEmpty)
|
||||
{
|
||||
def check(found: NodeSeq, expected: String, label: String) =
|
||||
if(found.isEmpty)
|
||||
error("Missing " + label + " in inline Ivy XML.")
|
||||
else {
|
||||
val str = found.text
|
||||
if(str != expected) error("Inconsistent " + label + " in inline Ivy XML. Expected '" + expected + "', got '" + str + "'")
|
||||
}
|
||||
check(info \ "@organisation", module.organization, "organisation")
|
||||
check(info \ "@module", module.name, "name")
|
||||
check(info \ "@revision", module.revision, "version")
|
||||
}
|
||||
!info.isEmpty
|
||||
}
|
||||
/** Parses the given in-memory Ivy file 'xml', using the existing 'moduleID' and specifying the given 'defaultConfiguration'. */
|
||||
private def parseIvyXML(settings: IvySettings, xml: scala.xml.NodeSeq, moduleID: DefaultModuleDescriptor, defaultConfiguration: String, validate: Boolean): CustomXmlParser.CustomParser =
|
||||
parseIvyXML(settings, xml.toString, moduleID, defaultConfiguration, validate)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ object Defaults
|
|||
def nameForSrc(config: String) = if(config == "compile") "main" else config
|
||||
def prefix(config: String) = if(config == "compile") "" else config + "-"
|
||||
|
||||
def lock(app: xsbti.AppConfiguration): xsbti.GlobalLock = app.provider.scalaProvider.launcher.globalLock
|
||||
|
||||
def extractAnalysis[T](a: Attributed[T]): (T, inc.Analysis) =
|
||||
(a.data, a.metadata get Keys.analysis getOrElse inc.Analysis.Empty)
|
||||
|
||||
|
|
@ -521,8 +523,7 @@ object Classpaths
|
|||
updateConfiguration <<= (retrieveConfiguration, ivyLoggingLevel)((conf,level) => new UpdateConfiguration(conf, false, level) ),
|
||||
retrieveConfiguration <<= (managedDirectory, retrievePattern, retrieveManaged) { (libm, pattern, enabled) => if(enabled) Some(new RetrieveConfiguration(libm, pattern)) else None },
|
||||
ivyConfiguration <<= (fullResolvers, ivyPaths, otherResolvers, moduleConfigurations, offline, checksums, appConfiguration, streams) map { (rs, paths, other, moduleConfs, off, check, app, s) =>
|
||||
val lock = app.provider.scalaProvider.launcher.globalLock
|
||||
new InlineIvyConfiguration(paths, rs, other, moduleConfs, off, Some(lock), check, s.log)
|
||||
new InlineIvyConfiguration(paths, rs, other, moduleConfs, off, Some(lock(app)), check, s.log)
|
||||
},
|
||||
ivyConfigurations <<= (autoCompilerPlugins, thisProject) { (auto, project) =>
|
||||
project.configurations ++ (if(auto) CompilerPlugin :: Nil else Nil)
|
||||
|
|
|
|||
|
|
@ -7,16 +7,19 @@ object InfoTest extends Build
|
|||
lazy val projects = Seq(root)
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
ivyPaths <<= (baseDirectory, target)( (dir, t) => new IvyPaths(dir, Some(t / "ivy-cache"))),
|
||||
ivyXML <<= (baseDirectory, organization, moduleID) apply inlineXML,
|
||||
ivyXML <<= (customInfo, organization, moduleID, version) apply inlineXML,
|
||||
projectID ~= (_ cross false),
|
||||
customInfo <<= baseDirectory{_ / "info" exists },
|
||||
TaskKey("check-download") <<= checkDownload,
|
||||
delivered <<= deliverLocal map XML.loadFile,
|
||||
TaskKey("check-info") <<= checkInfo
|
||||
)
|
||||
lazy val delivered = TaskKey[NodeSeq]("delivered")
|
||||
lazy val customInfo = SettingKey[Boolean]("custom-info")
|
||||
|
||||
def inlineXML(baseDirectory: File, organization: String, moduleID: String): NodeSeq =
|
||||
if(baseDirectory / "info" exists)
|
||||
(<info organisation={organization} module={moduleID} revision="1.0">
|
||||
def inlineXML(addInfo: Boolean, organization: String, moduleID: String, version: String): NodeSeq =
|
||||
if(addInfo)
|
||||
(<info organisation={organization} module={moduleID} revision={version}>
|
||||
<license name="Two-clause BSD-style" url="http://github.com/szeiger/scala-query/blob/master/LICENSE.txt" />
|
||||
<description homepage="http://github.com/szeiger/scala-query/">
|
||||
ScalaQuery is a type-safe database query API for Scala.
|
||||
|
|
@ -26,14 +29,13 @@ object InfoTest extends Build
|
|||
else
|
||||
<dependency org="org.scalacheck" name="scalacheck" rev="1.5"/>
|
||||
|
||||
def customInfo = file("info").exists
|
||||
def checkDownload = (dependencyClasspath in Compile) map { cp => if(cp.isEmpty) error("Dependency not downloaded") }
|
||||
def checkInfo = delivered map { d =>
|
||||
def checkInfo = (customInfo, delivered) map { (addInfo, d) =>
|
||||
if((d \ "info").isEmpty)
|
||||
error("No info tag generated")
|
||||
else if(customInfo)
|
||||
else if(addInfo) {
|
||||
if( !deliveredWithCustom(d) ) error("Expected 'license' and 'description' tags in info tag, got: \n" + (d \ "info"))
|
||||
else
|
||||
} else
|
||||
if( deliveredWithCustom(d) ) error("Expected empty 'info' tag, got: \n" + (d \ "info"))
|
||||
}
|
||||
def deliveredWithCustom(d: NodeSeq) = !(d \ "info" \ "license").isEmpty && !(d \ "info" \ "description").isEmpty
|
||||
|
|
|
|||
|
|
@ -5,5 +5,7 @@
|
|||
$ touch info
|
||||
> reload
|
||||
|
||||
> show custom-info
|
||||
> check-download
|
||||
> show custom-info
|
||||
> check-info
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
import sbt._
|
||||
|
||||
class TestProject(info: ProjectInfo) extends ParentProject(info)
|
||||
{
|
||||
val addRepo = "Extra Test Repository" at "http://dev.camptocamp.com/files/m2_repo/"
|
||||
val sub = project("sub", "Sub Project", new SubProject(_))
|
||||
override def ivyCacheDirectory = Some(outputPath / "ivy-cache")
|
||||
|
||||
class SubProject(info: ProjectInfo) extends DefaultProject(info)
|
||||
{
|
||||
override def ivyCacheDirectory = Some(outputPath / "ivy-cache")
|
||||
override def ivyXML =
|
||||
<dependencies>
|
||||
<dependency org="com.camptocamp.tl.caltar" name="core" rev="0.5" transitive="false"/>
|
||||
</dependencies>
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import sbt._
|
||||
|
||||
class TestProject(info: ProjectInfo) extends ParentProject(info)
|
||||
{
|
||||
val addRepo = "Extra Test Repository" at "http://dev.camptocamp.com/files/m2_repo/"
|
||||
val sub = project("sub", "Sub Project", new SubProject(_))
|
||||
override def ivyCacheDirectory = Some(outputPath / "ivy-cache")
|
||||
|
||||
class SubProject(info: ProjectInfo) extends DefaultProject(info)
|
||||
{
|
||||
val addRepo = "Extra Test Repository" at "http://dev.camptocamp.com/files/m2_repo/"
|
||||
|
||||
override def ivyCacheDirectory = Some(outputPath / "ivy-cache")
|
||||
override def ivyXML =
|
||||
<dependencies>
|
||||
<dependency org="com.camptocamp.tl.caltar" name="core" rev="0.5" transitive="false"/>
|
||||
</dependencies>
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import sbt._
|
||||
|
||||
class TestProject(info: ProjectInfo) extends ParentProject(info)
|
||||
{
|
||||
val addRepo = "Extra Test Repository" at "http://dev.camptocamp.com/files/m2_repo/"
|
||||
val sub = project("sub", "Sub Project", new SubProject(_))
|
||||
override def ivyCacheDirectory = Some(outputPath / "ivy-cache")
|
||||
|
||||
class SubProject(info: ProjectInfo) extends DefaultProject(info)
|
||||
{
|
||||
val addRepo = "Extra Test Repository" at "http://dev.camptocamp.com/files/m2_repo/"
|
||||
|
||||
override def ivyCacheDirectory = Some(outputPath / "ivy-cache")
|
||||
override def ivyXML =
|
||||
<dependencies>
|
||||
<dependency org="com.camptocamp.tl.caltar" name="core" rev="0.5" transitive="false"/>
|
||||
</dependencies>
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
resolvers += "Extra Test Repository" at "http://dev.camptocamp.com/files/m2_repo/"
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object TestProject extends Build
|
||||
{
|
||||
override lazy val settings = super.settings :+
|
||||
( ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home"))) )
|
||||
|
||||
lazy val projects = Seq(a, b)
|
||||
lazy val a = Project("a", file("a")) delegateTo(b) settings(
|
||||
libraryDependencies += "com.camptocamp.tl.caltar" % "core" % "0.5" intransitive()
|
||||
)
|
||||
lazy val b = Project("b", file("b"))
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#Project properties
|
||||
#Wed Apr 29 17:43:40 EDT 2009
|
||||
project.organization=sbt
|
||||
project.name=Repository Inheritance
|
||||
project.version=1.0
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
import sbt._
|
||||
|
||||
class TestProject(info: ProjectInfo) extends ParentProject(info)
|
||||
{
|
||||
val sub = project("sub", "Sub Project", new SubProject(_))
|
||||
override def ivyCacheDirectory = Some(outputPath / "ivy-cache")
|
||||
|
||||
class SubProject(info: ProjectInfo) extends DefaultProject(info)
|
||||
{
|
||||
override def ivyCacheDirectory = Some(outputPath / "ivy-cache")
|
||||
override def ivyXML =
|
||||
<dependencies>
|
||||
<dependency org="com.camptocamp.tl.caltar" name="core" rev="0.5" transitive="false"/>
|
||||
</dependencies>
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,21 @@
|
|||
# This should fail because the sub project declares a dependency that exists in an extra repository, which we haven't declared
|
||||
# This should fail because project A declares a dependency that exists in an extra repository, which we haven't declared
|
||||
-> update
|
||||
|
||||
# Copy the project definition with the extra repository declared in the parent and reload
|
||||
$ copy-file changes/CorrectProject.scala project/build/src/TestProject.scala
|
||||
# Copy the project definition with the extra repository declared in project B and with A delegating to B and reload
|
||||
$ copy-file changes/WithRepository.sbt b/build.sbt
|
||||
> reload
|
||||
|
||||
# Try updating again, which should work because the repository declared in the parent should be inherited by the child
|
||||
# Try updating again, which should work because the repository declared in B should be shared by A
|
||||
> update
|
||||
|
||||
# Copy the project definition with the extra repository declared in the child and parent and reload
|
||||
$ copy-file changes/CorrectProject2.scala project/build/src/TestProject.scala
|
||||
# Copy the project definition with the extra repository declared in both A and B and reload
|
||||
$ copy-file changes/WithRepository.sbt a/build.sbt
|
||||
> reload
|
||||
|
||||
> update
|
||||
|
||||
# Copy the project definition with the extra repository declared in the child and reload
|
||||
$ copy-file changes/CorrectProject3.scala project/build/src/TestProject.scala
|
||||
# Copy the project definition with the extra repository declared in A only and reload
|
||||
$ delete b/build.sbt
|
||||
> reload
|
||||
|
||||
> update
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
libraryDependencies += "org.scalacheck" % "scalacheck" % "1.5"
|
||||
|
||||
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home")))
|
||||
|
||||
TaskKey("check") <<= update map { report =>
|
||||
val files = report.matching( moduleFilter(organization = "org.scalacheck", name = "scalacheck", revision = "1.5") )
|
||||
assert(!files.isEmpty, "ScalaCheck module not found in update report")
|
||||
val missing = files.filter(! _.exists)
|
||||
assert(missing.isEmpty, "Reported ScalaCheck artifact files don't exist: " + missing.mkString(", "))
|
||||
}
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
> update
|
||||
> check
|
||||
|
||||
$ exists lib_managed/compile/scalacheck-1.5.jar
|
||||
> set retrieveManaged := true
|
||||
|
||||
> check
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
ivyPaths <<= baseDirectory( dir => new IvyPaths(dir, Some(dir / "ivy-home")))
|
||||
|
||||
seq(externalIvySettings(), externalIvyFile())
|
||||
|
||||
TaskKey("check") <<= update map { report =>
|
||||
val files = report.matching( moduleFilter(organization = "org.scalacheck", name = "scalacheck", revision = "1.5") )
|
||||
if(shouldExist)
|
||||
assert(!files.isEmpty, "ScalaCheck module not found in update report")
|
||||
else
|
||||
assert(files.isEmpty, "ScalaCheck module found in update report unexpectedly")
|
||||
}
|
||||
Loading…
Reference in New Issue