diff --git a/sbt/src/sbt-test/project/provided/build.sbt b/sbt/src/sbt-test/project/provided/build.sbt new file mode 100644 index 000000000..f4565ac12 --- /dev/null +++ b/sbt/src/sbt-test/project/provided/build.sbt @@ -0,0 +1,36 @@ +lazy val superRoot = (project in file("super")). + dependsOn(rootRef) + +lazy val root = (project in file(".")). + dependsOn(sub % "provided->test"). + settings( + rootSettings + ) + +lazy val sub = project + +lazy val rootRef = LocalProject("root") + +def rootSettings = Defaults.defaultSettings :+ ( TaskKey[Unit]("check") <<= checkTask ) +def checkTask = (fullClasspath in (rootRef, Compile), fullClasspath in (rootRef, Runtime), fullClasspath in (rootRef, Test), fullClasspath in (sub, Test), fullClasspath in (superRoot, Compile)) map { (rc, rr, rt, st, pr) => + check0(st, "sub test", true) + check0(pr, "superRoot main", false) + check0(rc, "root main", true) + check0(rr, "root runtime", false) + check0(rt, "root test", true) +} + +def check0(cp: Seq[Attributed[File]], label: String, shouldSucceed: Boolean): Unit = +{ + val loader = classpath.ClasspathUtilities.toLoader(cp.files) + println("Checking " + label) + val err = try { Class.forName("org.example.ProvidedTest", false, loader); None } + catch { case e: Exception => Some(e) } + + (err, shouldSucceed) match + { + case (None, true) | (Some(_), false) => () + case (None, false) => sys.error("Expected failure") + case (Some(x), true) => throw x + } +} diff --git a/sbt/src/sbt-test/project/provided/project/P.scala b/sbt/src/sbt-test/project/provided/project/P.scala deleted file mode 100644 index a59b7658e..000000000 --- a/sbt/src/sbt-test/project/provided/project/P.scala +++ /dev/null @@ -1,33 +0,0 @@ -import sbt._ -import Import._ -import Keys._ - -object P extends Build -{ - lazy val superRoot = Project("super-root", file("super")) dependsOn(root) - lazy val root: Project = Project("root", file("."), settings = rootSettings, dependencies = (sub % "provided->test") :: Nil) - lazy val sub = Project("sub", file("sub")) - - def rootSettings = Defaults.defaultSettings :+ ( TaskKey[Unit]("check") <<= checkTask ) - def checkTask = (fullClasspath in (root, Compile), fullClasspath in (root, Runtime), fullClasspath in (root, Test), fullClasspath in (sub, Test), fullClasspath in (superRoot, Compile)) map { (rc, rr, rt, st, pr) => - check0(st, "sub test", true) - check0(pr, "super main", false) - check0(rc, "root main", true) - check0(rr, "root runtime", false) - check0(rt, "root test", true) - } - def check0(cp: Seq[Attributed[File]], label: String, shouldSucceed: Boolean): Unit = - { - val loader = classpath.ClasspathUtilities.toLoader(cp.files) - println("Checking " + label) - val err = try { Class.forName("org.example.ProvidedTest", false, loader); None } - catch { case e: Exception => Some(e) } - - (err, shouldSucceed) match - { - case (None, true) | (Some(_), false) => () - case (None, false) => sys.error("Expected failure") - case (Some(x), true) => throw x - } - } -}