From 1f73d9eadc1ffc4ff91ed26c4c201fc864932a60 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 29 Mar 2016 00:56:59 -0400 Subject: [PATCH] Port dependency-management/provided --- .../dependency-management/provided/build.sbt | 30 ++++++++++++++++ .../provided/project/TestProject.scala | 35 ------------------- 2 files changed, 30 insertions(+), 35 deletions(-) create mode 100644 sbt/src/sbt-test/dependency-management/provided/build.sbt delete mode 100644 sbt/src/sbt-test/dependency-management/provided/project/TestProject.scala diff --git a/sbt/src/sbt-test/dependency-management/provided/build.sbt b/sbt/src/sbt-test/dependency-management/provided/build.sbt new file mode 100644 index 000000000..c5d4a8def --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/provided/build.sbt @@ -0,0 +1,30 @@ +import complete.DefaultParsers._ + +val provided = SettingKey[Boolean]("provided") +val check = InputKey[Unit]("check") + +lazy val root = (project in 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 sys.error("Invalid config: " + conf) + checkServletAPI(cp.files, expected, conf) + } + } + ) + +def checkServletAPI(paths: Seq[File], shouldBeIncluded: Boolean, label: String) = + { + val servletAPI = paths.find(_.getName contains "servlet-api") + if(shouldBeIncluded) + { + if(servletAPI.isEmpty) + sys.error("Servlet API should have been included in " + label + ".") + } + else + servletAPI.foreach(s => sys.error(s + " incorrectly included in " + label + ".")) + } diff --git a/sbt/src/sbt-test/dependency-management/provided/project/TestProject.scala b/sbt/src/sbt-test/dependency-management/provided/project/TestProject.scala deleted file mode 100644 index bdff38488..000000000 --- a/sbt/src/sbt-test/dependency-management/provided/project/TestProject.scala +++ /dev/null @@ -1,35 +0,0 @@ -import sbt._ -import Import._ -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 sys.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) - sys.error("Servlet API should have been included in " + label + ".") - } - else - servletAPI.foreach(s => sys.error(s + " incorrectly included in " + label + ".")) - } -}