From 91354497ab24f780a9bdf18bd67c02b40d98dcd9 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 11 Apr 2017 13:28:51 +0100 Subject: [PATCH] Drop deprecated InputTask apply method --- .../src/main/scala/sbt/InputTask.scala | 4 -- .../pom-advanced/build.sbt | 5 ++- .../pom-classpaths/build.sbt | 22 +++++----- .../dependency-management/provided/build.sbt | 44 ++++++++++--------- 4 files changed, 39 insertions(+), 36 deletions(-) diff --git a/main-settings/src/main/scala/sbt/InputTask.scala b/main-settings/src/main/scala/sbt/InputTask.scala index 6e2e1ffdf..60e489c84 100644 --- a/main-settings/src/main/scala/sbt/InputTask.scala +++ b/main-settings/src/main/scala/sbt/InputTask.scala @@ -91,10 +91,6 @@ object InputTask { separate(p)(act) } - @deprecated("Use another InputTask constructor or the `Def.inputTask` macro.", "0.13.0") - def apply[I, T](p: State => Parser[I])(action: TaskKey[I] => Initialize[Task[T]]): Initialize[InputTask[T]] = - apply(Def.value(p))(action) - /** * The proper solution is to have a Manifest context bound and accept slight source incompatibility, * The affected InputTask construction methods are all deprecated and so it is better to keep complete diff --git a/sbt/src/sbt-test/dependency-management/pom-advanced/build.sbt b/sbt/src/sbt-test/dependency-management/pom-advanced/build.sbt index 4fa6a2805..6059f882a 100644 --- a/sbt/src/sbt-test/dependency-management/pom-advanced/build.sbt +++ b/sbt/src/sbt-test/dependency-management/pom-advanced/build.sbt @@ -3,7 +3,10 @@ import complete.DefaultParsers._ lazy val root = (project in file(".")). settings( resolvers ++= Seq(local, Resolver.sonatypeRepo("releases"), Resolver.sonatypeRepo("snapshots")), - InputKey[Unit]("checkPom") := (InputTask(_ => spaceDelimited("")) { result => (makePom, result, streams) map checkPomRepositories }).evaluated, + InputKey[Unit]("checkPom") := { + val result = spaceDelimited("").parsed + checkPomRepositories(makePom.value, result, streams.value) + }, makePomConfiguration := ((makePomConfiguration, baseDirectory) { (conf, base) => conf.copy(filterRepositories = pomIncludeRepository(base, conf.filterRepositories) ) }).value, diff --git a/sbt/src/sbt-test/dependency-management/pom-classpaths/build.sbt b/sbt/src/sbt-test/dependency-management/pom-classpaths/build.sbt index ea5889151..9bcdc496a 100644 --- a/sbt/src/sbt-test/dependency-management/pom-classpaths/build.sbt +++ b/sbt/src/sbt-test/dependency-management/pom-classpaths/build.sbt @@ -9,17 +9,17 @@ lazy val root = (project in file(".")). managedClasspath in Provided := ((classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) }).value ) -def checkTask = InputTask(_ => parser ) { result => - (result, managedClasspath in Provided, fullClasspath in Compile, fullClasspath in Test, fullClasspath in Runtime) map { case ((conf, names), p, c, t, r) => - println("Checking: " + conf.name) - checkClasspath(conf match { - case Provided => p - case Compile => c - case Test => t - case Runtime => r - }, names.toSet) - } - } +def checkTask = Def.inputTask { + val result = parser.parsed + val (conf, names) = result + println("Checking: " + conf.name) + checkClasspath(conf match { + case Provided => managedClasspath in Provided value + case Compile => fullClasspath in Compile value + case Test => fullClasspath in Test value + case Runtime => fullClasspath in Runtime value + }, names.toSet) +} lazy val check = InputKey[Unit]("check") def parser: Parser[(Configuration,Seq[String])] = (Space ~> token(cp(Compile) | cp(Runtime) | cp(Provided) | cp(Test))) ~ spaceDelimited("") diff --git a/sbt/src/sbt-test/dependency-management/provided/build.sbt b/sbt/src/sbt-test/dependency-management/provided/build.sbt index fd7634e61..3f01f3c0d 100644 --- a/sbt/src/sbt-test/dependency-management/provided/build.sbt +++ b/sbt/src/sbt-test/dependency-management/provided/build.sbt @@ -5,26 +5,30 @@ val check = InputKey[Unit]("check") lazy val root = (project in file(".")). settings( - provided := baseDirectory(_ / "useProvided" exists).value, - configuration := provided(p => if(p) Provided else Compile).value, - libraryDependencies += configuration(c => "javax.servlet" % "servlet-api" % "2.5" % c.name).value, - managedClasspath in Provided := ((classpathTypes, update) map { (cpts, report) => Classpaths.managedJars(Provided, cpts, report) }).value, - 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) + provided := (baseDirectory.value / "useProvided" exists), + configuration := (if (provided.value) Provided else Compile), + libraryDependencies += "javax.servlet" % "servlet-api" % "2.5" % configuration.value.name, + managedClasspath in Provided := Classpaths.managedJars(Provided, classpathTypes.value, update.value), + check := { + val result = ( + Space ~> token(Compile.name.id | Runtime.name | Provided.name | Test.name) ~ token(Space ~> Bool) + ).parsed + val (conf, expected) = result + val cp = conf match { + case Compile.name => (fullClasspath in Compile).value + case Runtime.name => (fullClasspath in Runtime).value + case Provided.name => (managedClasspath in Provided).value + case Test.name => (fullClasspath in Test).value + case _ => sys.error(s"Invalid config: $conf") } - }).evaluated + 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 + ".")) - } +def checkServletAPI(paths: Seq[File], shouldBeIncluded: Boolean, label: String) = { + val servletAPI = paths.find(_.getName contains "servlet-api") + if (shouldBeIncluded) { + if (servletAPI.isEmpty) sys.error(s"Servlet API should have been included in $label.") + } else + servletAPI foreach (s => sys.error(s"$s incorrectly included in $label.")) +}