mirror of https://github.com/sbt/sbt.git
reintegrate a dependency-management test
This commit is contained in:
parent
738e32b9c6
commit
444cbbeb37
|
|
@ -0,0 +1,24 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object PomTest extends Build
|
||||
{
|
||||
override def settings = super.settings :+ (TaskKey[Unit]("check-pom") <<= checkPom)
|
||||
|
||||
lazy val subJar = Project("Sub Jar", file("subJar"))
|
||||
lazy val subWar = Project("Sub War", file("subWar")) settings( warArtifact)
|
||||
lazy val subParent = Project("Sub Parent", file("subParent")) settings( publishArtifact in Compile := false )
|
||||
|
||||
def art(p: ProjectReference) = makePom in p
|
||||
def checkPom = (art(subJar), art(subWar), art(subParent)) map { (jar, war, pom) =>
|
||||
checkPackaging(jar, "jar")
|
||||
checkPackaging(war, "war")
|
||||
checkPackaging(pom, "pom")
|
||||
}
|
||||
def checkPackaging(pom: File, expected: String) =
|
||||
{
|
||||
val packaging = (xml.XML.loadFile(pom) \\ "packaging").text
|
||||
if(packaging != expected) error("Incorrect packaging for '" + pom + "'. Expected '" + expected + "', but got '" + packaging + "'")
|
||||
}
|
||||
def warArtifact = artifact in (Compile, packageBin) ~= { _.copy(`type` = "war", extension = "war") }
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
project.name=Pom Test
|
||||
project.version=1.0
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
import sbt._
|
||||
|
||||
class PomTest(info: ProjectInfo) extends ParentProject(info) with BasicManagedProject
|
||||
{
|
||||
val subJar = project("subJar", "Sub Jar", new DefaultProject(_))
|
||||
val subWar = project("subWar", "Sub War", new DefaultWebProject(_))
|
||||
val subParent = project("subParent", "Sub Parent", i => new ParentProject(i) with BasicManagedProject)
|
||||
|
||||
def readPom(path: Path) = xml.XML.loadFile(path.asFile)
|
||||
lazy val checkPom = task {
|
||||
checkPackaging(subJar.pomPath, "jar") orElse
|
||||
checkPackaging(subWar.pomPath, "war") orElse
|
||||
checkPackaging(subParent.pomPath, "pom") orElse
|
||||
checkPackaging(pomPath, "pom")
|
||||
}
|
||||
def checkPackaging(pom: Path, expected: String) =
|
||||
{
|
||||
val packaging = (readPom(pom) \\ "packaging").text
|
||||
if(packaging == expected) None else Some("Incorrect packaging for '" + pom + "'. Expected '" + expected + "', but got '" + packaging + "'")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1 @@
|
|||
-> check-pom
|
||||
> package
|
||||
> make-pom
|
||||
> check-pom
|
||||
Loading…
Reference in New Issue