mirror of https://github.com/sbt/sbt.git
reintegrate dependency-management/provided,provided-multi tests
This commit is contained in:
parent
dd4ab4e078
commit
f38d6aa7f4
|
|
@ -1,19 +1,14 @@
|
|||
import sbt._
|
||||
|
||||
class P(info: ProjectInfo) extends ParentProject(info)
|
||||
import Keys._
|
||||
object P extends Build
|
||||
{
|
||||
val a = project("a", "A", new A(_))
|
||||
val b = project("b", "B", new B(_), a)
|
||||
val declared = SettingKey[Boolean]("declared")
|
||||
lazy val a = Project("A", file("a")) settings(
|
||||
libraryDependencies += "org.scala-tools.sbinary" %% "sbinary" % "0.4.0" % "provided"
|
||||
)
|
||||
|
||||
def aLibrary = "org.scala-tools.sbinary" %% "sbinary" % "0.3" % "provided"
|
||||
|
||||
class A(info: ProjectInfo) extends DefaultProject(info)
|
||||
{
|
||||
val a = aLibrary
|
||||
}
|
||||
class B(info: ProjectInfo) extends DefaultWebProject(info)
|
||||
{
|
||||
override def libraryDependencies =
|
||||
if("declare.lib".asFile.exists) Set(aLibrary) else Set()
|
||||
}
|
||||
lazy val b = Project("B", file("b")) dependsOn(a) settings(
|
||||
libraryDependencies <<= declared(d => if(d) Seq("org.scala-tools.sbinary" %% "sbinary" % "0.4.0" % "provided") else Nil),
|
||||
declared <<= baseDirectory(_ / "declare.lib" exists)
|
||||
)
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
project.name=Multi Project Provided
|
||||
project.version=1.0
|
||||
|
|
@ -1,21 +1,11 @@
|
|||
> set build.scala.versions 2.7.7
|
||||
$ copy-file changes/P.scala project/build/P.scala
|
||||
$ copy-file changes/P.scala project/P.scala
|
||||
$ copy-file changes/A.scala a/src/main/scala/A.scala
|
||||
$ copy-file changes/B.scala b/src/main/scala/B.scala
|
||||
> reload
|
||||
|
||||
> project A
|
||||
-> compile
|
||||
> update
|
||||
> compile
|
||||
|
||||
> project B
|
||||
-> compile
|
||||
> update
|
||||
-> compile
|
||||
> A/compile
|
||||
-> B/compile
|
||||
|
||||
$ touch b/declare.lib
|
||||
> reload
|
||||
-> compile
|
||||
> update
|
||||
> compile
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
import complete.DefaultParsers._
|
||||
|
||||
object TestProject extends Build
|
||||
{
|
||||
val provided = SettingKey[Boolean]("provided")
|
||||
val check = InputKey[Unit]("check")
|
||||
|
||||
lazy val root = Project("root", file(".")) settings(
|
||||
provided <<= baseDirectory(_ / "useProvided" exists),
|
||||
configuration <<= provided(p => if(p) Provided else Compile),
|
||||
libraryDependencies <+= configuration(c => "javax.servlet" % "servlet-api" % "2.5" % c.name),
|
||||
managedClasspath in Provided <<= (classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) },
|
||||
check <<= InputTask(_ => Space ~> token(Compile.name.id | Runtime.name | Provided.name | Test.name) ~ token(Space ~> Bool)) { result =>
|
||||
(result, managedClasspath in Provided, fullClasspath in Runtime, fullClasspath in Compile, fullClasspath in Test) map { case ((conf, expected), p, r, c, t) =>
|
||||
val cp = if(conf == Compile.name) c else if(conf == Runtime.name) r else if(conf == Provided.name) p else if(conf == Test.name) t else error("Invalid config: " + conf)
|
||||
checkServletAPI(cp.files, expected, conf)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
private def checkServletAPI(paths: Seq[File], shouldBeIncluded: Boolean, label: String) =
|
||||
{
|
||||
val servletAPI = paths.find(_.getName contains "servlet-api")
|
||||
if(shouldBeIncluded)
|
||||
{
|
||||
if(servletAPI.isEmpty)
|
||||
error("Servlet API should have been included in " + label + ".")
|
||||
}
|
||||
else
|
||||
servletAPI.foreach(s => error(s + " incorrectly included in " + label + "."))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
project.version=2.0
|
||||
project.name=Test
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
import sbt._
|
||||
|
||||
class TestProject(info: ProjectInfo) extends DefaultWebProject(info)
|
||||
{
|
||||
override def useMavenConfigurations = true
|
||||
private val provided = "useProvided".asFile.exists
|
||||
private val configuration = if(provided) Configurations.Provided else Configurations.Compile
|
||||
val j = "javax.servlet" % "servlet-api" % "2.5" % (configuration.name + "->default")
|
||||
|
||||
lazy val checkPublic = check(publicClasspath, !provided)
|
||||
lazy val checkRun = check(runClasspath, true)
|
||||
lazy val checkCompile = check(compileClasspath, true)
|
||||
lazy val checkProvided = check(fullClasspath(Configurations.Provided), provided)
|
||||
|
||||
private def check(classpath: PathFinder, shouldBeIncluded: Boolean) =
|
||||
task { checkServletAPI(shouldBeIncluded, "classpath")(classpath.get) }
|
||||
|
||||
lazy val checkWar = task { Control.thread(FileUtilities.unzip(warPath, outputPath / "exploded", log))(checkServletAPI(!provided, "war")) }
|
||||
private def checkServletAPI(shouldBeIncluded: Boolean, label: String)(paths: Iterable[Path]) =
|
||||
{
|
||||
val servletAPI = paths.find(_.asFile.getName.contains("servlet-api"))
|
||||
if(shouldBeIncluded)
|
||||
{
|
||||
if(servletAPI.isEmpty)
|
||||
Some("Servlet API should have been included in " + label + ".")
|
||||
else
|
||||
None
|
||||
}
|
||||
else
|
||||
servletAPI.map(_ + " incorrectly included in " + label + ".")
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +1,16 @@
|
|||
> show update
|
||||
|
||||
# verify that the classpaths are correct for when a dependency is in the compile configuration
|
||||
> check runtime true
|
||||
> check compile true
|
||||
> check provided false
|
||||
> check test true
|
||||
|
||||
# verify that the classpaths are correct for when a dependency is in the provided configuration
|
||||
$ touch useProvided
|
||||
> reload
|
||||
|
||||
> update
|
||||
|
||||
> check-run
|
||||
> check-compile
|
||||
> check-provided
|
||||
> check-public
|
||||
|
||||
> package
|
||||
> check-war
|
||||
|
||||
# verify that the classpaths are correct for when a dependency is in the compile configuration
|
||||
$ delete useProvided
|
||||
> reload
|
||||
|
||||
> update
|
||||
|
||||
> check-run
|
||||
> check-compile
|
||||
> check-provided
|
||||
> check-public
|
||||
|
||||
# prepare-webapp is last modified based, so we need to force it to do work
|
||||
$ delete target
|
||||
|
||||
> package
|
||||
> check-war
|
||||
> check runtime false
|
||||
> check compile true
|
||||
> check test true
|
||||
> check provided true
|
||||
|
|
|
|||
Loading…
Reference in New Issue