diff --git a/sbt/src/sbt-test/dependency-management/pom-scope/build.sbt b/sbt/src/sbt-test/dependency-management/pom-scope/build.sbt new file mode 100644 index 000000000..c562e6403 --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/pom-scope/build.sbt @@ -0,0 +1,42 @@ +lazy val custom = config("custom") + +lazy val root = (project in file(".")). + configs(custom). + settings( + TaskKey[Unit]("check-pom") <<= checkPom, + libraryDependencies ++= Seq( + "a" % "a" % "1.0", + "b" % "b" % "1.0" % "runtime,optional", + "c" % "c" % "1.0" % "optional", + "d" % "d" % "1.0" % "test", + "e" % "e" % "1.0" % "custom", + "f" % "f" % "1.0" % "custom,optional,runtime", + "g" % "g" % "1.0" % "custom,runtime" classifier "foo", + "h" % "h" % "1.0" % "custom,optional,runtime" classifier "foo" + ) + ) + +def checkPom = makePom map { pom => + val expected = Seq( + ("a", None, false, None), + ("b", Some("runtime"), true, None), + ("c", None, true, None), + ("d", Some("test"), false, None), + ("e", None, false, None), + ("f", Some("runtime"), true, None), + ("g", Some("runtime"), false, Some("foo")), + ("h", Some("runtime"), true, Some("foo")) + ) + val loaded = xml.XML.loadFile(pom) + val deps = loaded \\ "dependency" + expected foreach { case (id, scope, opt, classifier) => + val dep = deps.find(d => (d \ "artifactId").text == id).getOrElse( sys.error("Dependency '" + id + "' not written to pom:\n" + loaded)) + val actualOpt = java.lang.Boolean.parseBoolean( (dep \\ "optional").text ) + assert(opt == actualOpt, "Invalid 'optional' section '" + (dep \\ "optional") + "' for " + id + ", expected optional=" + opt) + + val actualScope = (dep \\ "scope") match { case Seq() => None; case x => Some(x.text) } + val actualClassifier = (dep \\ "classifier") match { case Seq() => None; case x => Some(x.text) } + assert(actualScope == scope, "Invalid 'scope' section '" + (dep \\ "scope") + "' for " + id + ", expected scope=" + scope) + assert(actualClassifier == classifier, "Invalid 'classifier' section '" + (dep \\ "classifier") + "' for " + id + ", expected classifier=" + classifier) + } +} diff --git a/sbt/src/sbt-test/dependency-management/pom-scope/project/PomTest.scala b/sbt/src/sbt-test/dependency-management/pom-scope/project/PomTest.scala deleted file mode 100644 index 6f9b5b7f6..000000000 --- a/sbt/src/sbt-test/dependency-management/pom-scope/project/PomTest.scala +++ /dev/null @@ -1,48 +0,0 @@ -import sbt._ -import Keys._ -import Import._ - -object PomTest extends Build -{ - lazy val custom = config("custom") - lazy val root = Project("root", file("root")) configs(custom) settings( - TaskKey[Unit]("check-pom") <<= checkPom, - libraryDependencies ++= Seq( - "a" % "a" % "1.0", - "b" % "b" % "1.0" % "runtime,optional", - "c" % "c" % "1.0" % "optional", - "d" % "d" % "1.0" % "test", - "e" % "e" % "1.0" % "custom", - "f" % "f" % "1.0" % "custom,optional,runtime", - "g" % "g" % "1.0" % "custom,runtime" classifier "foo", - "h" % "h" % "1.0" % "custom,optional,runtime" classifier "foo" - ) - ) - - - - def checkPom = makePom map { pom => - val expected = Seq( - ("a", None, false, None), - ("b", Some("runtime"), true, None), - ("c", None, true, None), - ("d", Some("test"), false, None), - ("e", None, false, None), - ("f", Some("runtime"), true, None), - ("g", Some("runtime"), false, Some("foo")), - ("h", Some("runtime"), true, Some("foo")) - ) - val loaded = xml.XML.loadFile(pom) - val deps = loaded \\ "dependency" - expected foreach { case (id, scope, opt, classifier) => - val dep = deps.find(d => (d \ "artifactId").text == id).getOrElse( sys.error("Dependency '" + id + "' not written to pom:\n" + loaded)) - val actualOpt = java.lang.Boolean.parseBoolean( (dep \\ "optional").text ) - assert(opt == actualOpt, "Invalid 'optional' section '" + (dep \\ "optional") + "' for " + id + ", expected optional=" + opt) - - val actualScope = (dep \\ "scope") match { case Seq() => None; case x => Some(x.text) } - val actualClassifier = (dep \\ "classifier") match { case Seq() => None; case x => Some(x.text) } - assert(actualScope == scope, "Invalid 'scope' section '" + (dep \\ "scope") + "' for " + id + ", expected scope=" + scope) - assert(actualClassifier == classifier, "Invalid 'classifier' section '" + (dep \\ "classifier") + "' for " + id + ", expected classifier=" + classifier) - } - } -}