diff --git a/sbt-app/src/sbt-test/actions/call/build.sbt b/sbt-app/src/sbt-test/actions/call/build.sbt index 8ff9b8f9d..720ea3346 100644 --- a/sbt-app/src/sbt-test/actions/call/build.sbt +++ b/sbt-app/src/sbt-test/actions/call/build.sbt @@ -3,7 +3,7 @@ sbtPlugin := true val copyOutputDir = taskKey[Unit]("Copies the compiled classes to a root-level directory") copyOutputDir := { - val cd = (classDirectory in Compile).value + val cd = (Compile / classDirectory).value val to = baseDirectory.value / "out spaced" IO.copyDirectory(cd, to) } diff --git a/sbt-app/src/sbt-test/actions/clean-managed/build.sbt b/sbt-app/src/sbt-test/actions/clean-managed/build.sbt index cedf36e1c..1505d55f0 100644 --- a/sbt-app/src/sbt-test/actions/clean-managed/build.sbt +++ b/sbt-app/src/sbt-test/actions/clean-managed/build.sbt @@ -1,9 +1,11 @@ import sbt.nio.file.Glob -Compile / sourceGenerators += Def.task { - val files = Seq(sourceManaged.value / "foo.txt", sourceManaged.value / "bar.txt") - files.foreach(IO.touch(_)) - files +Compile / sourceGenerators += { + Def.task { + val files = Seq(sourceManaged.value / "foo.txt", sourceManaged.value / "bar.txt") + files.foreach(IO.touch(_)) + files + } } cleanKeepGlobs += Glob(sourceManaged.value, "bar.txt") diff --git a/sbt-app/src/sbt-test/actions/compile-clean/build.sbt b/sbt-app/src/sbt-test/actions/compile-clean/build.sbt index 0b40a6eb6..d76c2ffb2 100644 --- a/sbt-app/src/sbt-test/actions/compile-clean/build.sbt +++ b/sbt-app/src/sbt-test/actions/compile-clean/build.sbt @@ -1,4 +1,4 @@ import sbt.nio.file.Glob -cleanKeepGlobs in Compile += - Glob((classDirectory in Compile in compile).value, "X.class") +Compile / cleanKeepGlobs += + Glob((Compile / compile / classDirectory).value, "X.class") diff --git a/sbt-app/src/sbt-test/actions/compile-time-only/build.sbt b/sbt-app/src/sbt-test/actions/compile-time-only/build.sbt index f8d308a29..108396ca6 100644 --- a/sbt-app/src/sbt-test/actions/compile-time-only/build.sbt +++ b/sbt-app/src/sbt-test/actions/compile-time-only/build.sbt @@ -6,9 +6,8 @@ libraryDependencies += "org.scala-sbt" % "sbt" % sbtVersion.value lazy val expectErrorNotCrash = taskKey[Unit]("Ensures that sbt properly set types on Trees so that the compiler doesn't crash on a bad reference to .value, but gives a proper error instead.") expectErrorNotCrash := { - val fail = (compileIncremental in Compile).failure.value - fail.directCause match { - case Some(x: xsbti.CompileFailed) => () - case _ => sys.error("Compiler crashed instead of providing a compile-time-only exception.") - } + val fail = (Compile / compileIncremental).failure.value + fail.directCause match + case Some(x: xsbti.CompileFailed) => () + case _ => sys.error("Compiler crashed instead of providing a compile-time-only exception.") } diff --git a/sbt-app/src/sbt-test/actions/compile/test b/sbt-app/src/sbt-test/actions/compile/test index 0c25100b6..9978a9516 100644 --- a/sbt-app/src/sbt-test/actions/compile/test +++ b/sbt-app/src/sbt-test/actions/compile/test @@ -1,5 +1,5 @@ -> compile -> 'set sources in (Compile, compile) := { val src = (sources in (Compile, compile)).value; src.filterNot(_.getName contains "C") }' +> 'set Compile / compile / sources := { val src = (Compile / compile / sources).value; src.filterNot(_.getName contains "C") }' > compile diff --git a/sbt-app/src/sbt-test/actions/configuration-delegation/build.sbt b/sbt-app/src/sbt-test/actions/configuration-delegation/build.sbt index 029644912..bc45e0058 100644 --- a/sbt-app/src/sbt-test/actions/configuration-delegation/build.sbt +++ b/sbt-app/src/sbt-test/actions/configuration-delegation/build.sbt @@ -3,15 +3,13 @@ lazy val foo = taskKey[Unit]("Runs the foo task") lazy val bar = taskKey[Unit]("Runs the bar task") def makeFoo(config: Configuration): Setting[_] = - foo in config := IO.write(file(s"${config.name}-foo"), "foo") + config / foo := IO.write(file(s"${config.name}-foo"), "foo") lazy val PerformanceTest = (config("pt") extend Test) -lazy val root = ( - (project in file(".")) +lazy val root = (project in file(".")) .configs(PerformanceTest) .settings(Seq(Compile, Test, Runtime, PerformanceTest).map(makeFoo) :_*) .settings( - bar in PerformanceTest := IO.write(file("pt-bar"), "bar") + PerformanceTest / bar := IO.write(file("pt-bar"), "bar") ) -) \ No newline at end of file diff --git a/sbt-app/src/sbt-test/actions/doc/build.sbt b/sbt-app/src/sbt-test/actions/doc/build.sbt index 8f1b96ff9..7036a6f1e 100644 --- a/sbt-app/src/sbt-test/actions/doc/build.sbt +++ b/sbt-app/src/sbt-test/actions/doc/build.sbt @@ -9,11 +9,11 @@ lazy val root = (project in file(".")) scalaVersion := "2.12.12", Compile / doc / scalacOptions += "-Xfatal-warnings", commands += Command.command("excludeB") { s => - val impl = """val src = (sources in Compile).value; src.filterNot(_.getName.contains("B"))""" - s"set sources in (Compile, doc) := { $impl }" :: s + val impl = """val src = (Compile / sources).value; src.filterNot(_.getName.contains("B"))""" + s"set Compile / doc / sources := { $impl }" :: s }, commands += Command.arb(_ => ("setDocExtension": Parser[String]) ~> " " ~> matched(any.*)) { (s, filter: String) => - val impl = s"""val src = (sources in Compile).value; src.filter(_.getName.endsWith("$filter"))""" - s"set sources in (Compile, doc) := { $impl }" :: s + val impl = s"""val src = (Compile / sources).value; src.filter(_.getName.endsWith("$filter"))""" + s"set Compile / doc / sources := { $impl }" :: s }, ) diff --git a/sbt-app/src/sbt-test/actions/eval-is-safe-and-sound/build.sbt b/sbt-app/src/sbt-test/actions/eval-is-safe-and-sound/build.sbt index 12bedf524..5e339bf95 100644 --- a/sbt-app/src/sbt-test/actions/eval-is-safe-and-sound/build.sbt +++ b/sbt-app/src/sbt-test/actions/eval-is-safe-and-sound/build.sbt @@ -18,7 +18,7 @@ lazy val checkDifferentConfigClasses = taskKey[Unit]("Checks that the number of configClassCountFile := (target.value / "config-count") numConfigClasses := { - val cdir = (baseDirectory in ThisBuild).value / "project/target/config-classes" + val cdir = (ThisBuild / baseDirectory).value / "project/target/config-classes" (cdir.allPaths --- cdir).get.length } diff --git a/sbt-app/src/sbt-test/actions/external-doc/build.sbt b/sbt-app/src/sbt-test/actions/external-doc/build.sbt index fe2d502d8..23cc3290f 100644 --- a/sbt-app/src/sbt-test/actions/external-doc/build.sbt +++ b/sbt-app/src/sbt-test/actions/external-doc/build.sbt @@ -2,31 +2,31 @@ ThisBuild / useCoursier := false Seq( - autoAPIMappings in ThisBuild := true, - publishArtifact in (ThisBuild, packageDoc) := false, - publishArtifact in packageSrc := false, - organization in ThisBuild := "org.example", - version := "1.0" + ThisBuild / autoAPIMappings := true, + ThisBuild / packageDoc / publishArtifact := false, + packageSrc / publishArtifact := false, + ThisBuild / organization := "org.example", + version := "1.0", ) val aPublishResolver = Def.setting { - Resolver.file("a-resolver", baseDirectory.in(ThisBuild).value / "a-repo") + Resolver.file("a-resolver", (ThisBuild / baseDirectory).value / "a-repo") } val aResolver = Def.setting { - val dir = baseDirectory.in(ThisBuild).value - "a-resolver" at s"file://${dir.getAbsolutePath}/a-repo" + val dir = (ThisBuild / baseDirectory).value + "a-resolver" at s"file://${dir.getAbsolutePath}/a-repo" } val bResolver = Def.setting { - val dir = baseDirectory.in(ThisBuild).value / "b-repo" - Resolver.file("b-resolver", dir)(Resolver.defaultIvyPatterns) + val dir = (ThisBuild / baseDirectory).value / "b-repo" + Resolver.file("b-resolver", dir)(Resolver.defaultIvyPatterns) } val apiBaseSetting = apiURL := Some(apiBase(name.value)) def apiBase(projectName: String) = url(s"http://example.org/${projectName}") def scalaLibraryBase(v: String) = url(s"https://www.scala-lang.org/api/$v/") def addDep(projectName: String) = - libraryDependencies += organization.value %% projectName % version.value + libraryDependencies += organization.value %% projectName % version.value val checkApiMappings = taskKey[Unit]("Verifies that the API mappings are collected as expected.") @@ -34,44 +34,44 @@ val checkApiMappings = taskKey[Unit]("Verifies that the API mappings are collect def expectedMappings = Def.task { val version = scalaVersion.value val binVersion = scalaBinaryVersion.value - val ms = update.value.configuration(Compile).get.modules.flatMap { mod => - mod.artifacts.flatMap { case (a,f) => - val n = a.name.stripSuffix("_" + binVersion) - n match { - case "a" | "b" | "c" => (f, apiBase(n)) :: Nil - case "scala-library" => (f, scalaLibraryBase(version)) :: Nil - case _ => Nil - } - } - } - val mc = (classDirectory in (c,Compile)).value -> apiBase("c") - (mc +: ms).toMap + val ms = update.value.configuration(Compile).get.modules.flatMap { mod => + mod.artifacts.flatMap { case (a,f) => + val n = a.name.stripSuffix("_" + binVersion) + n match { + case "a" | "b" | "c" => (f, apiBase(n)) :: Nil + case "scala-library" => (f, scalaLibraryBase(version)) :: Nil + case _ => Nil + } + } + } + val mc = (Compile / c / classDirectory).value -> apiBase("c") + (mc +: ms).toMap } val a = project.settings( - apiBaseSetting, - publishMavenStyle := true, - publishTo := Some(aPublishResolver.value) + apiBaseSetting, + publishMavenStyle := true, + publishTo := Some(aPublishResolver.value) ) val b = project.settings( - apiBaseSetting, - publishMavenStyle := false, - publishTo := Some(bResolver.value) + apiBaseSetting, + publishMavenStyle := false, + publishTo := Some(bResolver.value) ) val c = project.settings(apiBaseSetting) val d = project.dependsOn( c ).settings( - externalResolvers := Seq(aResolver.value, bResolver.value), - addDep("a"), - addDep("b"), - checkApiMappings := { - val actual = apiMappings.in(Compile,doc).value - println("Actual API Mappings: " + actual.mkString("\n\t", "\n\t", "")) - val expected = expectedMappings.value - println("Expected API Mappings: " + expected.mkString("\n\t", "\n\t", "")) - assert(actual == expected) - } + externalResolvers := Seq(aResolver.value, bResolver.value), + addDep("a"), + addDep("b"), + checkApiMappings := { + val actual = (Compile / doc / apiMappings).value + println("Actual API Mappings: " + actual.mkString("\n\t", "\n\t", "")) + val expected = expectedMappings.value + println("Expected API Mappings: " + expected.mkString("\n\t", "\n\t", "")) + assert(actual == expected) + } ) diff --git a/sbt-app/src/sbt-test/actions/generator/build.sbt b/sbt-app/src/sbt-test/actions/generator/build.sbt index d9139f3a0..56dbe41e1 100644 --- a/sbt-app/src/sbt-test/actions/generator/build.sbt +++ b/sbt-app/src/sbt-test/actions/generator/build.sbt @@ -9,6 +9,6 @@ lazy val root = (project in file(".")) IO.write(file, "object BuildInfo") file :: Nil }, - sourceGenerators in Compile += buildInfo, - sourceGenerators in Compile += Def.task { Nil } + Compile / sourceGenerators += buildInfo, + Compile / sourceGenerators += Def.task { Nil }, ) diff --git a/sbt-app/src/sbt-test/actions/input-task-dyn/build.sbt b/sbt-app/src/sbt-test/actions/input-task-dyn/build.sbt index 46d9578d5..d87e3f2d0 100644 --- a/sbt-app/src/sbt-test/actions/input-task-dyn/build.sbt +++ b/sbt-app/src/sbt-test/actions/input-task-dyn/build.sbt @@ -10,7 +10,7 @@ lazy val root = (project in file(".")). name := "run-test", runFoo := Def.inputTaskDyn { val args = Def.spaceDelimited().parsed - (runMain in Compile).toTask(s" Foo " + args.mkString(" ")) + (Compile / runMain).toTask(s" Foo " + args.mkString(" ")) }.evaluated, check := { val x = runFoo.toTask(" hi ho").value diff --git a/sbt-app/src/sbt-test/actions/input-task/build.sbt b/sbt-app/src/sbt-test/actions/input-task/build.sbt index 3d61bdf90..f19e32f7b 100644 --- a/sbt-app/src/sbt-test/actions/input-task/build.sbt +++ b/sbt-app/src/sbt-test/actions/input-task/build.sbt @@ -12,9 +12,9 @@ lazy val root = (project in file(".")). settings( name := "run-test", run2 := { - val one = (run in Compile).evaluated + val one = (Compile / run).evaluated val sep = separator.parsed - val two = (run in Compile).evaluated + val two = (Compile / run).evaluated }, check := { val x = run2.toTask(" a b -- c d").value diff --git a/sbt-app/src/sbt-test/actions/join/build.sbt b/sbt-app/src/sbt-test/actions/join/build.sbt index ac73e48c3..bef19f465 100644 --- a/sbt-app/src/sbt-test/actions/join/build.sbt +++ b/sbt-app/src/sbt-test/actions/join/build.sbt @@ -3,18 +3,18 @@ lazy val intTask = taskKey[Int]("int") lazy val root = (project in file(".")). dependsOn(b, c). settings( - intTask in Compile := { + Compile / intTask := { // a sequence of tasks could be joined together - Seq(b, c).map(p => intTask in (p, Compile)).join.map( as => (1 /: as)(_ + _) ).value + Seq(b, c).map(p => Cmpile / p / intTask).join.map( as => (1 /: as)(_ + _) ).value } ) lazy val b = (project in file("b")). settings( - intTask in Compile := 1 + Compile / intTask := 1 ) lazy val c = (project in file("c")). settings{ - intTask in Compile := 2 + Compile / intTask := 2 } diff --git a/sbt-app/src/sbt-test/actions/multi-scope/build.sbt b/sbt-app/src/sbt-test/actions/multi-scope/build.sbt index 654c75d38..fd5bc2492 100644 --- a/sbt-app/src/sbt-test/actions/multi-scope/build.sbt +++ b/sbt-app/src/sbt-test/actions/multi-scope/build.sbt @@ -59,15 +59,15 @@ lazy val b = project lazy val c = project.settings( taskX := cGlobal, - taskX in Compile := cCompile, - taskX in Test := cTest + Compile / taskX := cCompile, + Test / taskX := cTest ) lazy val d = project.settings( taskX := dGlobal, - taskX in (Compile,console) := dConsole, + Compile / console / taskX := dConsole, // these shouldn't get picked up - taskX in (Compile,compile) := Set(32366), - taskX in compile := Set(548686), - taskX in Configurations.IntegrationTest := Set(11111) -) \ No newline at end of file + Compile / compile / taskX := Set(32366), + compile / taskX := Set(548686), + Configurations.IntegrationTest / taskX := Set(11111), +) diff --git a/sbt-app/src/sbt-test/actions/previous/scopes.sbt b/sbt-app/src/sbt-test/actions/previous/scopes.sbt index 8062b1df1..16af91fad 100644 --- a/sbt-app/src/sbt-test/actions/previous/scopes.sbt +++ b/sbt-app/src/sbt-test/actions/previous/scopes.sbt @@ -9,39 +9,38 @@ lazy val subB = project x := 3 -x in Compile in y := 7 +Compile / y / x := 7 -x in Runtime in y := 13 +Runtime / y / x := 13 -x in subA in Compile := { - val xcy = (x in Compile in y).previous getOrElse 0 // 7 - // verify that This is properly resolved to Global and not the defining key's scope - val xg = x.previous getOrElse 0 // 3 - println(s"xcy=$xcy, xg=$xg") - xcy * xg +subA / Compile / x := { + val xcy = (Compile / y / x).previous getOrElse 0 // 7 + // verify that This is properly resolved to Global and not the defining key's scope + val xg = x.previous getOrElse 0 // 3 + println(s"xcy=$xcy, xg=$xg") + xcy * xg } - inConfig(Compile)(Seq( - y in subB := { - // verify that the referenced key gets delegated - val xty = (x in Test in y).previous getOrElse 0 // 13 - // verify that inConfig gets applied - val xcy = (x in y).previous getOrElse 0 // 7 - println(s"xcy=$xcy, xty=$xty") - xty * xcy - } + subB / y := { + // verify that the referenced key gets delegated + val xty = (Test / y / x).previous getOrElse 0 // 13 + // verify that inConfig gets applied + val xcy = (y / x).previous getOrElse 0 // 7 + println(s"xcy=$xcy, xty=$xty") + xty * xcy + } )) def parser = { - import complete.DefaultParsers._ - (Space ~> IntBasic) ~ (Space ~> IntBasic) + import complete.DefaultParsers._ + (Space ~> IntBasic) ~ (Space ~> IntBasic) } checkScopes := { - val (expectedX, expectedY) = parser.parsed - val actualX = (x in subA in Compile).value - val actualY = (y in subB in Test).value - assert(actualX == expectedX, s"Expected 'x' to be $expectedX, got $actualX") - assert(actualY == expectedY, s"Expected 'y' to be $expectedY, got $actualY") + val (expectedX, expectedY) = parser.parsed + val actualX = (subA/ Compile / x).value + val actualY = (subB / Test / y).value + assert(actualX == expectedX, s"Expected 'x' to be $expectedX, got $actualX") + assert(actualY == expectedY, s"Expected 'y' to be $expectedY, got $actualY") } diff --git a/sbt-app/src/sbt-test/actions/remote-cache/build.sbt b/sbt-app/src/sbt-test/actions/remote-cache/build.sbt index 920bc2e0c..43766a055 100644 --- a/sbt-app/src/sbt-test/actions/remote-cache/build.sbt +++ b/sbt-app/src/sbt-test/actions/remote-cache/build.sbt @@ -42,7 +42,7 @@ lazy val root = (project in file(".")) recordPreviousIterations := { val log = streams.value.log CompileState.previousIterations = { - val previousAnalysis = (previousCompile in Compile).value.analysis.asScala + val previousAnalysis = (Compile / previousCompile).value.analysis.asScala previousAnalysis match { case None => log.info("No previous analysis detected") @@ -53,7 +53,7 @@ lazy val root = (project in file(".")) }, checkIterations := { val expected: Int = (Space ~> NatBasic).parsed - val actual: Int = ((compile in Compile).value match { case a: Analysis => a.compilations.allCompilations.size }) - CompileState.previousIterations + val actual: Int = ((Compile / compile).value match { case a: Analysis => a.compilations.allCompilations.size }) - CompileState.previousIterations assert(expected == actual, s"Expected $expected compilations, got $actual") } ) diff --git a/sbt-app/src/sbt-test/actions/run-task/build.sbt b/sbt-app/src/sbt-test/actions/run-task/build.sbt index 69fb3e613..4f0a4ed3a 100644 --- a/sbt-app/src/sbt-test/actions/run-task/build.sbt +++ b/sbt-app/src/sbt-test/actions/run-task/build.sbt @@ -1,7 +1,7 @@ val demo = taskKey[Unit]("Demo run task") fullRunTask(demo, Compile, "A", "1", "1") -fork in demo := true -javaOptions in demo := "-Dsbt.check.forked=true" :: Nil +demo / fork := true +demo / javaOptions := "-Dsbt.check.forked=true" :: Nil val demoIn = InputKey[Unit]("demoIn", "Demo run input task", demo) fullRunInputTask(demoIn, Compile, "A", "1") diff --git a/sbt-app/src/sbt-test/apiinfo/extracted/build.sbt b/sbt-app/src/sbt-test/apiinfo/extracted/build.sbt index 37533b32a..eab867380 100644 --- a/sbt-app/src/sbt-test/apiinfo/extracted/build.sbt +++ b/sbt-app/src/sbt-test/apiinfo/extracted/build.sbt @@ -44,11 +44,11 @@ def testInputTask[T](name: String, expected: String, task: InputKey[T], arg: Str myInputTask := argFunction(_.toUpperCase(Locale.ENGLISH)).evaluated testInputTask("testRunInputTaskRoot", "FOO", myInputTask, "foo") -myInputTask in Compile := argFunction(_.toLowerCase(Locale.ENGLISH)).evaluated +Compile / myInputTask := argFunction(_.toLowerCase(Locale.ENGLISH)).evaluated testInputTask("testRunInputTaskRootCompile", "foo", myInputTask in Compile, "FOO") -myInputTask in sub := argFunction(_.head.toString).evaluated +sub / myInputTask := argFunction(_.head.toString).evaluated testInputTask("testRunInputTaskSub", "f", myInputTask in sub, "foo") -myInputTask in (sub, Compile) := argFunction(_.tail).evaluated +sub / Compile / myInputTask := argFunction(_.tail).evaluated testInputTask("testRunInputTaskSubCompile", "oo", myInputTask in (sub, Compile), "foo") diff --git a/sbt-app/src/sbt-test/apiinfo/show-circular-structure/build.sbt b/sbt-app/src/sbt-test/apiinfo/show-circular-structure/build.sbt index 6d28ec8e9..21146aa3d 100644 --- a/sbt-app/src/sbt-test/apiinfo/show-circular-structure/build.sbt +++ b/sbt-app/src/sbt-test/apiinfo/show-circular-structure/build.sbt @@ -5,9 +5,9 @@ logLevel := Level.Debug incOptions ~= { _.withApiDebug(true) } TaskKey[Unit]("show-apis") := { - val a = (compile in Compile).value match { case a: Analysis => a } - val scalaSrc = (scalaSource in Compile).value - val javaSrc = (javaSource in Compile).value + val a = (Compile / compile).value match { case a: Analysis => a } + val scalaSrc = (Compile / scalaSource).value + val javaSrc = (Compile / javaSource).value val aApi = a.apis.internalAPI("test.A").api.classApi val jApi = a.apis.internalAPI("test.J").api.classApi import xsbt.api.DefaultShowAPI diff --git a/sbt-app/src/sbt-test/apiinfo/unstable-existential-names/build.sbt b/sbt-app/src/sbt-test/apiinfo/unstable-existential-names/build.sbt index 1036709cc..3888dda98 100644 --- a/sbt-app/src/sbt-test/apiinfo/unstable-existential-names/build.sbt +++ b/sbt-app/src/sbt-test/apiinfo/unstable-existential-names/build.sbt @@ -6,7 +6,7 @@ val recordPreviousIterations = taskKey[Unit]("Record previous iterations.") recordPreviousIterations := { val log = streams.value.log CompileState.previousIterations = { - val previousAnalysis = (previousCompile in Compile).value.analysis.asScala + val previousAnalysis = (Compile / previousCompile).value.analysis.asScala previousAnalysis match { case None => log.info("No previous analysis detected") @@ -20,6 +20,6 @@ val checkIterations = inputKey[Unit]("Verifies the accumulated number of iterati checkIterations := { val expected: Int = (Space ~> NatBasic).parsed - val actual: Int = ((compile in Compile).value match { case a: Analysis => a.compilations.allCompilations.size }) - CompileState.previousIterations + val actual: Int = ((Compile / compile).value match { case a: Analysis => a.compilations.allCompilations.size }) - CompileState.previousIterations assert(expected == actual, s"Expected $expected compilations, got $actual") } diff --git a/sbt-app/src/sbt-test/compiler-project/inc-package-class-dependency/build.sbt b/sbt-app/src/sbt-test/compiler-project/inc-package-class-dependency/build.sbt index a9b970121..ce36e14da 100644 --- a/sbt-app/src/sbt-test/compiler-project/inc-package-class-dependency/build.sbt +++ b/sbt-app/src/sbt-test/compiler-project/inc-package-class-dependency/build.sbt @@ -1,8 +1,8 @@ import sbt.internal.inc.Analysis TaskKey[Unit]("verify-binary-deps") := { - val a = (compile in Compile).value match { case a: Analysis => a } - val classDir = (classDirectory in Compile).value + val a = (Compile / compile).value match { case a: Analysis => a } + val classDir = (Compile / classDirectory).value val base = baseDirectory.value val nestedPkgClass = classDir / "test/nested.class" val fooSrc = base / "src/main/scala/test/nested/Foo.scala" diff --git a/sbt-app/src/sbt-test/compiler-project/inc-pickled-existential/build.sbt b/sbt-app/src/sbt-test/compiler-project/inc-pickled-existential/build.sbt index 1284c994c..aa808c75e 100644 --- a/sbt-app/src/sbt-test/compiler-project/inc-pickled-existential/build.sbt +++ b/sbt-app/src/sbt-test/compiler-project/inc-pickled-existential/build.sbt @@ -8,7 +8,7 @@ val recordPreviousIterations = taskKey[Unit]("Record previous iterations.") recordPreviousIterations := { val log = streams.value.log CompileState.previousIterations = { - val previousAnalysis = (previousCompile in Compile).value.analysis.asScala + val previousAnalysis = (Compile / previousCompile).value.analysis.asScala previousAnalysis match { case None => log.info("No previous analysis detected") @@ -22,6 +22,6 @@ val checkIterations = inputKey[Unit]("Verifies the accumulated number of iterati checkIterations := { val expected: Int = (Space ~> NatBasic).parsed - val actual: Int = ((compile in Compile).value match { case a: Analysis => a.compilations.allCompilations.size }) - CompileState.previousIterations + val actual: Int = ((Compile / compile).value match { case a: Analysis => a.compilations.allCompilations.size }) - CompileState.previousIterations assert(expected == actual, s"Expected $expected compilations, got $actual") } diff --git a/sbt-app/src/sbt-test/compiler-project/inc-pickled-refinement/build.sbt b/sbt-app/src/sbt-test/compiler-project/inc-pickled-refinement/build.sbt index 1036709cc..b27b7f236 100644 --- a/sbt-app/src/sbt-test/compiler-project/inc-pickled-refinement/build.sbt +++ b/sbt-app/src/sbt-test/compiler-project/inc-pickled-refinement/build.sbt @@ -6,7 +6,7 @@ val recordPreviousIterations = taskKey[Unit]("Record previous iterations.") recordPreviousIterations := { val log = streams.value.log CompileState.previousIterations = { - val previousAnalysis = (previousCompile in Compile).value.analysis.asScala + val previousAnalysis = (Compile / previousCompile).value.analysis.asScala previousAnalysis match { case None => log.info("No previous analysis detected") @@ -20,6 +20,6 @@ val checkIterations = inputKey[Unit]("Verifies the accumulated number of iterati checkIterations := { val expected: Int = (Space ~> NatBasic).parsed - val actual: Int = ((compile in Compile).value match { case a: Analysis => a.compilations.allCompilations.size }) - CompileState.previousIterations + val actual: Int = ((Compile / compile).value match { case a: Analysis => a.compilations.allCompilations.size }) - CompileState.previousIterations assert(expected == actual, s"Expected $expected compilations, got $actual") } diff --git a/sbt-app/src/sbt-test/compiler-project/macro-config/build.sbt b/sbt-app/src/sbt-test/compiler-project/macro-config/build.sbt index 248b7cb45..15598d96a 100644 --- a/sbt-app/src/sbt-test/compiler-project/macro-config/build.sbt +++ b/sbt-app/src/sbt-test/compiler-project/macro-config/build.sbt @@ -19,15 +19,15 @@ lazy val root = (project in file(".")) inConfig(Macro)(Defaults.configSettings), // puts the compiled macro on the classpath for the main sources - unmanagedClasspath in Compile ++= - (fullClasspath in Macro).value, + Compile / unmanagedClasspath ++= + (Macro / fullClasspath).value, // includes sources in src/macro/ in the main source package - mappings in (Compile, packageSrc) ++= - (mappings in (Macro, packageSrc)).value, + Compile / packageSrc / mappings ++= + (Macro / packageSrc / mappings).value, // Includes classes compiled from src/macro/ in the main binary // This can be omitted if the classes in src/macro/ aren't used at runtime - mappings in (Compile, packageBin) ++= - (mappings in (Macro, packageBin)).value + Compile / packageBin / mappings ++= + (Macro / packageBin / mappings).value ) diff --git a/sbt-app/src/sbt-test/compiler-project/semantic-errors/build.sbt b/sbt-app/src/sbt-test/compiler-project/semantic-errors/build.sbt index 019d06f89..913667f36 100644 --- a/sbt-app/src/sbt-test/compiler-project/semantic-errors/build.sbt +++ b/sbt-app/src/sbt-test/compiler-project/semantic-errors/build.sbt @@ -1,6 +1,6 @@ TaskKey[Unit]("checkJavaFailures") := { val reporter = savedReporter.value - val ignore = (compile in Compile).failure.value + val ignore = (Compile / compile).failure.value val ps = reporter.problems assert(!ps.isEmpty, "Failed to report any problems!") // First error should be on a specific line/file @@ -13,7 +13,7 @@ TaskKey[Unit]("checkJavaFailures") := { TaskKey[Unit]("checkScalaFailures") := { val reporter = savedReporter.value - val ignore = (compile in Compile).failure.value + val ignore = (Compile / compile).failure.value val ps = reporter.problems assert(!ps.isEmpty, "Failed to report any problems!") // First error should be on a specific line/file diff --git a/sbt-app/src/sbt-test/compiler-project/semantic-errors/project/src/main/scala/sbt/TestPlugin.scala b/sbt-app/src/sbt-test/compiler-project/semantic-errors/project/src/main/scala/sbt/TestPlugin.scala index d8c5e0c59..165405526 100644 --- a/sbt-app/src/sbt-test/compiler-project/semantic-errors/project/src/main/scala/sbt/TestPlugin.scala +++ b/sbt-app/src/sbt-test/compiler-project/semantic-errors/project/src/main/scala/sbt/TestPlugin.scala @@ -14,7 +14,7 @@ object TestPlugin extends AutoPlugin { import autoImport._ override def projectSettings = Seq( savedReporter := new CollectingReporter, - compilerReporter in (Compile, compile) := savedReporter.value, + Compile / compile / compilerReporter := savedReporter.value, problems := savedReporter.value.problems ) } diff --git a/sbt-app/src/sbt-test/compiler-project/separate-analysis-per-scala/build.sbt b/sbt-app/src/sbt-test/compiler-project/separate-analysis-per-scala/build.sbt index 804a1206d..77191747f 100644 --- a/sbt-app/src/sbt-test/compiler-project/separate-analysis-per-scala/build.sbt +++ b/sbt-app/src/sbt-test/compiler-project/separate-analysis-per-scala/build.sbt @@ -9,7 +9,7 @@ lazy val root = (project in file(".")) incOptions := incOptions.value.withClassfileManagerType( Option(xsbti.compile.TransactionalManagerType.of( crossTarget.value / "classes.bak", - (streams in (Compile, compile)).value.log + (Compile / compile / streams).value.log ): xsbti.compile.ClassFileManagerType).asJava ) ) diff --git a/sbt-app/src/sbt-test/package/manifest/build.sbt b/sbt-app/src/sbt-test/package/manifest/build.sbt index 73ac1427d..2711329b8 100644 --- a/sbt-app/src/sbt-test/package/manifest/build.sbt +++ b/sbt-app/src/sbt-test/package/manifest/build.sbt @@ -9,11 +9,11 @@ crossPaths := false mainClass := Some("jartest.Main") -packageOptions in (Compile, packageBin) := { +Compile / packageBin / packageOptions := { def manifestExtra = { val mf = new Manifest mf.getMainAttributes.put(Attributes.Name.CLASS_PATH, makeString(scalaInstance.value.libraryJars)) mf } - (packageOptions in (Compile, packageBin)).value :+ Package.JarManifest(manifestExtra) + (Compile / packageBin / packageOptions).value :+ Package.JarManifest(manifestExtra) } diff --git a/sbt-app/src/sbt-test/package/mappings/build.sbt b/sbt-app/src/sbt-test/package/mappings/build.sbt index dc930b4ae..81c727e70 100644 --- a/sbt-app/src/sbt-test/package/mappings/build.sbt +++ b/sbt-app/src/sbt-test/package/mappings/build.sbt @@ -2,7 +2,7 @@ name := "Mappings Test" version := "0.2" -mappings in (Compile, packageBin) ++= { +Compile / packageBin / mappings ++= { val test = file("test") Seq( test -> "test1", @@ -13,5 +13,5 @@ mappings in (Compile, packageBin) ++= { lazy val unzipPackage = taskKey[Unit]("extract jar file") unzipPackage := { - IO.unzip((packageBin in Compile).value, target.value / "extracted") -} \ No newline at end of file + IO.unzip((Compile / packageBin).value, target.value / "extracted") +} diff --git a/sbt-app/src/sbt-test/package/resources/src/main/scala/jartest/Main.scala b/sbt-app/src/sbt-test/package/resources/src/main/scala/jartest/Main.scala index 1998ccc6d..4c92d0fa7 100644 --- a/sbt-app/src/sbt-test/package/resources/src/main/scala/jartest/Main.scala +++ b/sbt-app/src/sbt-test/package/resources/src/main/scala/jartest/Main.scala @@ -1,10 +1,6 @@ package jartest -object Main -{ - def main(args: Array[String]) - { - if(getClass.getResource("main_resource_test") == null) - System.exit(1) - } -} \ No newline at end of file +object Main: + def main(args: Array[String]): Unit = + if(getClass.getResource("main_resource_test") == null) + System.exit(1) diff --git a/sbt-app/src/sbt-test/project/auto-import/project/P.scala b/sbt-app/src/sbt-test/project/auto-import/project/P.scala index 70e309a38..38b2f9949 100644 --- a/sbt-app/src/sbt-test/project/auto-import/project/P.scala +++ b/sbt-app/src/sbt-test/project/auto-import/project/P.scala @@ -22,8 +22,8 @@ package name.example { import autoImport._ override def projectSettings = Seq[Setting[_]]( - checkMaxErrors := (Keys.maxErrors map { me => assert(me == xyz, "Expected maxErrors to be " + xyz + ", but it was " + me ) }).value, - checkName := (Keys.name map { n => assert(n == "Demo", "Expected name to be 'Demo', but it was '" + n + "'" ) }).value + checkMaxErrors := (Keys.maxErrors mapN { me => assert(me == xyz, "Expected maxErrors to be " + xyz + ", but it was " + me ) }).value, + checkName := (Keys.name mapN { n => assert(n == "Demo", "Expected name to be 'Demo', but it was '" + n + "'" ) }).value ) } } diff --git a/sbt-app/src/sbt-test/project/auto-plugins-default-requires-jvmplugin/build.sbt b/sbt-app/src/sbt-test/project/auto-plugins-default-requires-jvmplugin/build.sbt index bea5471fd..a6062b24c 100644 --- a/sbt-app/src/sbt-test/project/auto-plugins-default-requires-jvmplugin/build.sbt +++ b/sbt-app/src/sbt-test/project/auto-plugins-default-requires-jvmplugin/build.sbt @@ -1,5 +1,5 @@ val test123 = project in file(".") enablePlugins TestP settings( - resourceGenerators in Compile += Def.task { + Compile / resourceGenerators += Def.task { streams.value.log info "resource generated in settings" Nil } diff --git a/sbt-app/src/sbt-test/project/auto-plugins-default-requires-jvmplugin/project/TestP.scala b/sbt-app/src/sbt-test/project/auto-plugins-default-requires-jvmplugin/project/TestP.scala index c52417af9..7b4cad897 100644 --- a/sbt-app/src/sbt-test/project/auto-plugins-default-requires-jvmplugin/project/TestP.scala +++ b/sbt-app/src/sbt-test/project/auto-plugins-default-requires-jvmplugin/project/TestP.scala @@ -2,7 +2,7 @@ import sbt._, Keys._ object TestP extends AutoPlugin { override def projectSettings: Seq[Setting[_]] = Seq( - resourceGenerators in Compile += Def.task { + Compile / resourceGenerators += Def.task { streams.value.log info "resource generated in plugin" Nil } diff --git a/sbt-app/src/sbt-test/project/auto-plugins/build.sbt b/sbt-app/src/sbt-test/project/auto-plugins/build.sbt index f564d4879..60025752b 100644 --- a/sbt-app/src/sbt-test/project/auto-plugins/build.sbt +++ b/sbt-app/src/sbt-test/project/auto-plugins/build.sbt @@ -29,44 +29,44 @@ lazy val projI = project.enablePlugins(TopC) lazy val disableAutoNoRequirePlugin = project.disablePlugins(OrgPlugin) check := { - // Ensure organization on root is overridable. - val rorg = (organization).value // Should be None - same(rorg, "override", "organization") - // this will pass when the raw disablePlugin works. - val dversion = (projectID in projD).?.value // Should be None - same(dversion, None, "projectID in projD") + // Ensure organization on root is overridable. + val rorg = (organization).value // Should be None + same(rorg, "override", "organization") + // this will pass when the raw disablePlugin works. + val dversion = (projD / projectID).?.value // Should be None + same(dversion, None, "projectID in projD") -// Ensure with multiple .sbt files that disabling/enabling works across them - val fDel = (del in Quux in projF).?.value - same(fDel, Some(" Q"), "del in Quux in projF") -// - val adel = (del in projA).?.value // should be None - same(adel, None, "del in projA") - val bdel = (del in projB).?.value // should be None - same(bdel, None, "del in projB") - val ddel = (del in projD).?.value // should be None - same(ddel, None, "del in projD") -// - val buildValue = (demo in ThisBuild).value - same(buildValue, "build 0", "demo in ThisBuild") - val globalValue = (demo in Global).value - same(globalValue, "global 0", "demo in Global") - val projValue = (demo in projC).?.value - same(projValue, Some("project projC Q R"), "demo in projC") - val qValue = (del in projC in Quux).?.value - same(qValue, Some(" Q R"), "del in projC in Quux") - val optInValue = (del in projE in Quux).value - same(optInValue, " Q S R", "del in projE in Quux") - val overrideOrgValue = (organization in projE).value - same(overrideOrgValue, "S", "organization in projE") -// tests for top level plugins - val topLevelAValueG = (topLevelDemo in projG).value + // Ensure with multiple .sbt files that disabling/enabling works across them + val fDel = (projF / Quux / del).?.value + same(fDel, Some(" Q"), "del in Quux in projF") + // + val adel = (projA / del).?.value // should be None + same(adel, None, "del in projA") + val bdel = (projB / del).?.value // should be None + same(bdel, None, "del in projB") + val ddel = (projD / del).?.value // should be None + same(ddel, None, "del in projD") + // + val buildValue = (ThisBuild / demo).value + same(buildValue, "build 0", "demo in ThisBuild") + val globalValue = (Global / demo).value + same(globalValue, "global 0", "demo in Global") + val projValue = (projC / demo).?.value + same(projValue, Some("project projC Q R"), "demo in projC") + val qValue = (Quux / del in projC)(projC / del).?.value + same(qValue, Some(" Q R"), "del in projC in Quux") + val optInValue = (Quux / del in projE)(projE / del).value + same(optInValue, " Q S R", "del in projE in Quux") + val overrideOrgValue = (projE / organization).value + same(overrideOrgValue, "S", "organization in projE") + // tests for top level plugins + val topLevelAValueG = (projG / topLevelDemo).value same(topLevelAValueG, "TopA: topLevelDemo project projG", "topLevelDemo in projG") - val demoValueG = (demo in projG).value + val demoValueG = (projG / demo).value same(demoValueG, "TopA: demo project projG", "demo in projG") - val topLevelBValueH = (topLevelDemo in projH).value + val topLevelBValueH = (projH / topLevelDemo).value same(topLevelBValueH, "TopB: topLevelDemo project projH", "topLevelDemo in projH") - val hdel = (del in projH).?.value + val hdel = (projH / del).?.value same(hdel, None, "del in projH") } @@ -75,5 +75,5 @@ keyTest := "foo" topLevelKeyTest := "bar" def same[T](actual: T, expected: T, label: String): Unit = { - assert(actual == expected, s"Expected '$expected' for `$label`, got '$actual'") + assert(actual == expected, s"Expected '$expected' for `$label`, got '$actual'") } diff --git a/sbt-app/src/sbt-test/project/auto-plugins/project/Q.scala b/sbt-app/src/sbt-test/project/auto-plugins/project/Q.scala index 001fd1eae..40bbc3569 100644 --- a/sbt-app/src/sbt-test/project/auto-plugins/project/Q.scala +++ b/sbt-app/src/sbt-test/project/auto-plugins/project/Q.scala @@ -1,97 +1,92 @@ package sbttest // you need package https://stackoverflow.com/questions/9822008/ - import sbt._, Keys._ - import java.util.concurrent.atomic.{AtomicInteger => AInt} +import sbt._, Keys._ +import java.util.concurrent.atomic.{AtomicInteger => AInt} - object A extends AutoPlugin { override def requires: Plugins = empty } - object B extends AutoPlugin { override def requires: Plugins = empty } - object E extends AutoPlugin { override def requires: Plugins = empty } +object A extends AutoPlugin { override def requires: Plugins = empty } +object B extends AutoPlugin { override def requires: Plugins = empty } +object E extends AutoPlugin { override def requires: Plugins = empty } -object Imports -{ - lazy val Quux = config("q") - lazy val Pippy = config("p").extend(Quux) +object Imports { + lazy val Quux = config("q") + lazy val Pippy = config("p").extend(Quux) - lazy val demo = settingKey[String]("A demo setting.") - lazy val del = settingKey[String]("Another demo setting.") + lazy val demo = settingKey[String]("A demo setting.") + lazy val del = settingKey[String]("Another demo setting.") - lazy val check = taskKey[Unit]("Verifies settings are as they should be.") + lazy val check = taskKey[Unit]("Verifies settings are as they should be.") } -object OrgPlugin extends AutoPlugin { - override def trigger = allRequirements - override def requires: Plugins = empty - override def projectSettings = Seq( +object OrgPlugin extends AutoPlugin: + override def trigger = allRequirements + override def requires: Plugins = empty + override def projectSettings = Seq( organization := "override" - ) -} + ) object X extends AutoPlugin { - val autoImport = Imports + val autoImport = Imports } - import Imports._ +import Imports._ object D extends AutoPlugin { - override def requires: Plugins = E - override def trigger = allRequirements + override def requires: Plugins = E + override def trigger = allRequirements - object autoImport { - lazy val keyTest = settingKey[String]("Another demo setting.") - } + object autoImport { + lazy val keyTest = settingKey[String]("Another demo setting.") + } } -object Q extends AutoPlugin -{ - override def requires: Plugins = A && B - override def trigger = allRequirements +object Q extends AutoPlugin { + override def requires: Plugins = A && B + override def trigger = allRequirements - override def projectConfigurations: Seq[Configuration] = - Pippy :: - Quux :: - Nil + override def projectConfigurations: Seq[Configuration] = + Pippy :: + Quux :: + Nil override def projectSettings: Seq[Setting[_]] = - (demo := s"project ${name.value}") :: - (del in Quux := " Q") :: - Nil + (demo := s"project ${name.value}") :: + (Quux / del := " Q") :: + Nil override def buildSettings: Seq[Setting[_]] = - (demo := s"build ${buildCount.getAndIncrement}") :: - Nil + (demo := s"build ${buildCount.getAndIncrement}") :: + Nil override def globalSettings: Seq[Setting[_]] = - (demo := s"global ${globalCount.getAndIncrement}") :: - Nil + (demo := s"global ${globalCount.getAndIncrement}") :: + Nil - // used to ensure the build-level and global settings are only added once - private[this] val buildCount = new AInt(0) - private[this] val globalCount = new AInt(0) + // used to ensure the build-level and global settings are only added once + private[this] val buildCount = new AInt(0) + private[this] val globalCount = new AInt(0) } -object R extends AutoPlugin -{ - // NOTE - Only plugins themselves support exclusions... - override def requires = Q - override def trigger = allRequirements +object R extends AutoPlugin { + // NOTE - Only plugins themselves support exclusions... + override def requires = Q + override def trigger = allRequirements - override def projectSettings = Seq( - // tests proper ordering: R requires Q, so Q settings should come first - del in Quux += " R", - // tests that configurations are properly registered, enabling delegation from p to q - demo += (del in Pippy).value - ) + override def projectSettings = Seq( + // tests proper ordering: R requires Q, so Q settings should come first + Quux / del += " R", + // tests that configurations are properly registered, enabling delegation from p to q + demo += (del in Pippy).value + ) } // This is an opt-in plugin with a requirement // Unless explicitly loaded by the build user, this will not be activated. -object S extends AutoPlugin -{ - override def requires = Q - override def trigger = noTrigger +object S extends AutoPlugin { + override def requires = Q + override def trigger = noTrigger - override def projectSettings = Seq( - del in Quux += " S", - organization := "S" - ) + override def projectSettings = Seq( + Quux / del += " S", + organization := "S" + ) } diff --git a/sbt-app/src/sbt-test/project/binary-plugin/common.sbt b/sbt-app/src/sbt-test/project/binary-plugin/common.sbt index 4b30c03d6..6d24d8274 100644 --- a/sbt-app/src/sbt-test/project/binary-plugin/common.sbt +++ b/sbt-app/src/sbt-test/project/binary-plugin/common.sbt @@ -1,7 +1,5 @@ -organization in ThisBuild := "org.example" +ThisBuild / organization := "org.example" // We have to use snapshot because this is publishing to our local ivy cache instead of // an integration cache, so we're in danger land. -version in ThisBuild := "3.4-SNAPSHOT" - - +ThisBuild / version := "3.4-SNAPSHOT" diff --git a/sbt-app/src/sbt-test/project/build-deps/changes/b.sbt b/sbt-app/src/sbt-test/project/build-deps/changes/b.sbt index 334917dea..80ff9307e 100644 --- a/sbt-app/src/sbt-test/project/build-deps/changes/b.sbt +++ b/sbt-app/src/sbt-test/project/build-deps/changes/b.sbt @@ -1,5 +1,5 @@ -buildDependencies in Global := - (buildDependencies in Global).value.addClasspath( - (thisProjectRef in LocalProject("a")).value, +Global / buildDependencies := + (Global / buildDependencies).value.addClasspath( + (LocalProject("a") / thisProjectRef).value, ResolvedClasspathDependency(thisProjectRef.value, None) ) diff --git a/sbt-app/src/sbt-test/project/circular/build.sbt b/sbt-app/src/sbt-test/project/circular/build.sbt index f254811cc..da3f9877c 100644 --- a/sbt-app/src/sbt-test/project/circular/build.sbt +++ b/sbt-app/src/sbt-test/project/circular/build.sbt @@ -7,12 +7,12 @@ lazy val root = (project in file(".")). lazy val sub: Project = project. dependsOn(LocalProject("root")). settings( - name := (name in LocalProject("root")).value + "sub" + name := (LocalProject("root") / name).value + "sub" ) lazy val foo: Project = project. aggregate(LocalProject("root")). dependsOn(LocalProject("root")). settings(List( - name := (name in LocalProject("root")).value + "foo" + name := (LocalProject("root") / name).value + "foo" ): _*) diff --git a/sbt-app/src/sbt-test/project/cross-plugins-defaults/build.sbt b/sbt-app/src/sbt-test/project/cross-plugins-defaults/build.sbt index 2179dcf9e..07ff57632 100644 --- a/sbt-app/src/sbt-test/project/cross-plugins-defaults/build.sbt +++ b/sbt-app/src/sbt-test/project/cross-plugins-defaults/build.sbt @@ -1,8 +1,8 @@ val baseSbt = "1." val buildCrossList = List("2.10.7", "2.11.12", "2.12.12") -scalaVersion in ThisBuild := "2.12.12" -crossScalaVersions in ThisBuild := buildCrossList +(ThisBuild / scalaVersion) := "2.12.12" +(ThisBuild / crossScalaVersions) := buildCrossList addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0") @@ -16,8 +16,8 @@ lazy val root = (project in file(".")) lazy val app = (project in file("app")) def mkCheck(scalaBinV: String, sbtBinVer: String, sbtVerPrefix: String) = Def.task { - val crossV = (sbtVersion in pluginCrossBuild).value - val crossBinV = (sbtBinaryVersion in pluginCrossBuild).value + val crossV = (pluginCrossBuild / sbtVersion).value + val crossBinV = (pluginCrossBuild / sbtBinaryVersion).value val sv = projectID.value.extraAttributes("e:scalaVersion") assert(sbtVersion.value startsWith baseSbt, s"Wrong sbt version: ${sbtVersion.value}") assert(sv == scalaBinV, s"Wrong e:scalaVersion: $sv") @@ -33,8 +33,8 @@ def mkCheck(scalaBinV: String, sbtBinVer: String, sbtVerPrefix: String) = Def.ta assert(plugSbtV == sbtBinVer, s"Wrong plugin sbtVersion: $plugSbtV") // crossScalaVersions in app should not be affected, per se or after ^^ - val appCrossScalaVersions = (crossScalaVersions in app).value.toList - val appScalaVersion = (scalaVersion in app).value + val appCrossScalaVersions = (app / crossScalaVersions).value.toList + val appScalaVersion = (app / scalaVersion).value assert(appCrossScalaVersions == buildCrossList, s"Wrong `crossScalaVersions in app`: $appCrossScalaVersions") assert(appScalaVersion startsWith "2.12", s"Wrong `scalaVersion in app`: $appScalaVersion") } diff --git a/sbt-app/src/sbt-test/project/cross-plugins-source/build.sbt b/sbt-app/src/sbt-test/project/cross-plugins-source/build.sbt index 874d2da9d..5bb39c396 100644 --- a/sbt-app/src/sbt-test/project/cross-plugins-source/build.sbt +++ b/sbt-app/src/sbt-test/project/cross-plugins-source/build.sbt @@ -1,6 +1,6 @@ lazy val root = (project in file(".")) .settings( sbtPlugin := true, - sbtVersion in pluginCrossBuild := "0.13.15", + pluginCrossBuild / sbtVersion := "0.13.15", resolvers += Resolver.typesafeIvyRepo("releases") ) diff --git a/sbt-app/src/sbt-test/project/generated-root-no-publish/build.sbt b/sbt-app/src/sbt-test/project/generated-root-no-publish/build.sbt index 218d90089..d97e40622 100644 --- a/sbt-app/src/sbt-test/project/generated-root-no-publish/build.sbt +++ b/sbt-app/src/sbt-test/project/generated-root-no-publish/build.sbt @@ -3,7 +3,7 @@ ThisBuild / csrCacheDirectory := (ThisBuild / baseDirectory).value / "coursier-c val commonSettings = Seq( organization := "com.example", version := "0.1.0", - ivyPaths := IvyPaths((baseDirectory in LocalRootProject).value, Some((target in LocalRootProject).value / "ivy-cache")) + ivyPaths := IvyPaths((LocalRootProject / baseDirectory).value, Some((LocalRootProject / target).value / "ivy-cache")) ) lazy val app = (project in file("app")). diff --git a/sbt-app/src/sbt-test/project/lint/build.sbt b/sbt-app/src/sbt-test/project/lint/build.sbt index b8ba55e05..bdf757b50 100644 --- a/sbt-app/src/sbt-test/project/lint/build.sbt +++ b/sbt-app/src/sbt-test/project/lint/build.sbt @@ -12,8 +12,8 @@ lazy val root = (project in file(".")) .settings( lintBuildTest := { val state = Keys.state.value - val includeKeys = (lintIncludeFilter in Global).value - val excludeKeys = (lintExcludeFilter in Global).value + val includeKeys = (Global / lintIncludeFilter).value + val excludeKeys = (Global / lintExcludeFilter).value val result = sbt.internal.LintUnused.lintUnused(state, includeKeys, excludeKeys) result foreach { case (_, "ThisBuild / doc / scalacOptions", _) => () diff --git a/sbt-app/src/sbt-test/project/load-hooks/build.sbt b/sbt-app/src/sbt-test/project/load-hooks/build.sbt index c5d44543c..9e12fedd5 100644 --- a/sbt-app/src/sbt-test/project/load-hooks/build.sbt +++ b/sbt-app/src/sbt-test/project/load-hooks/build.sbt @@ -6,8 +6,8 @@ s.put(key, previous + 1) } Seq( - onLoad in Global ~= (f(loadCount) compose _), - onUnload in Global ~= (f(unloadCount) compose _) + Global / onLoad ~= (f(loadCount) compose _), + Global / onUnload ~= (f(unloadCount) compose _) ) } diff --git a/sbt-app/src/sbt-test/project/provided/build.sbt b/sbt-app/src/sbt-test/project/provided/build.sbt index af6bf0a3f..49a4c3edb 100644 --- a/sbt-app/src/sbt-test/project/provided/build.sbt +++ b/sbt-app/src/sbt-test/project/provided/build.sbt @@ -2,15 +2,17 @@ val rootRef = LocalProject("root") val sub = project val superRoot = project in file("super") dependsOn rootRef -val root = project in file(".") dependsOn (sub % "provided->test") settings ( - TaskKey[Unit]("check") := { - check0((fullClasspath in (sub, Test)).value, "sub test", true) - check0((fullClasspath in (superRoot, Compile)).value, "superRoot main", false) - check0((fullClasspath in (rootRef, Compile)).value, "root main", true) - check0((fullClasspath in (rootRef, Runtime)).value, "root runtime", false) - check0((fullClasspath in (rootRef, Test)).value, "root test", true) - } -) +val root = (project in file(".")). + dependsOn(sub % "provided->test"). + settings ( + TaskKey[Unit]("check") := { + check0((sub / Test / fullClasspath).value, "sub test", true) + check0((superRoot / Compile / fullClasspath).value, "superRoot main", false) + check0((rootRef / Compile / fullClasspath).value, "root main", true) + check0((rootRef / Runtime / fullClasspath).value, "root runtime", false) + check0((rootRef / Test / fullClasspath).value, "root test", true) + } + ) def check0(cp: Seq[Attributed[File]], label: String, shouldSucceed: Boolean): Unit = { import sbt.internal.inc.classpath.ClasspathUtilities diff --git a/sbt-app/src/sbt-test/project/sequential/build.sbt b/sbt-app/src/sbt-test/project/sequential/build.sbt index cd4cb1eac..f4ff7fa42 100644 --- a/sbt-app/src/sbt-test/project/sequential/build.sbt +++ b/sbt-app/src/sbt-test/project/sequential/build.sbt @@ -34,6 +34,6 @@ lazy val root = project. val t = testFile.value IO.append(t, "2") }, - foo := Def.sequential(compile in Compile, sideEffect0, sideEffect1, sideEffect2, test in Test, bar).value, + foo := Def.sequential(Compile / compile, sideEffect0, sideEffect1, sideEffect2, Test / test, bar).value, bar := 1 ) diff --git a/sbt-app/src/sbt-test/tests/arguments/build.sbt b/sbt-app/src/sbt-test/tests/arguments/build.sbt index 34877ddf4..ac9bfeafa 100644 --- a/sbt-app/src/sbt-test/tests/arguments/build.sbt +++ b/sbt-app/src/sbt-test/tests/arguments/build.sbt @@ -14,7 +14,7 @@ lazy val root = (project in file(".")) }, libraryDependencies += scalatest % Test, // testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-f", "result.txt", "-eNDXEHLO") - testOptions in Configurations.Test ++= { + Configurations.Test / testOptions ++= { def args(path: String, args: String*): Seq[TestOption] = if(file(path).exists) Tests.Argument(args : _*) :: Nil else Nil diff --git a/sbt-app/src/sbt-test/tests/bak/build.sbt b/sbt-app/src/sbt-test/tests/bak/build.sbt index 40b598c48..63777d713 100644 --- a/sbt-app/src/sbt-test/tests/bak/build.sbt +++ b/sbt-app/src/sbt-test/tests/bak/build.sbt @@ -24,22 +24,22 @@ val p1 = project .configs(CustomConfigs: _*) .settings( t := { - (compile in Config_0).value - (compile in Config_1).value - (compile in Config_2).value - (compile in Config_3).value - (compile in Config_4).value - (compile in Config_5).value - (compile in Config_6).value - (compile in Config_7).value - (compile in Config_8).value - (compile in Config_9).value - (compile in Config_10).value - (compile in Config_11).value - (compile in Config_12).value - (compile in Config_13).value - (compile in Config_14).value - (compile in Config_15).value + (Config_0 / compile).value + (Config_1 / compile).value + (Config_2 / compile).value + (Config_3 / compile).value + (Config_4 / compile).value + (Config_5 / compile).value + (Config_6 / compile).value + (Config_7 / compile).value + (Config_8 / compile).value + (Config_9 / compile).value + (Config_10 / compile).value + (Config_11 / compile).value + (Config_12 / compile).value + (Config_13 / compile).value + (Config_14 / compile).value + (Config_15 / compile).value } ) .settings(CustomConfigs.flatMap(c => inConfig(c)(Defaults.testSettings))) diff --git a/sbt-app/src/sbt-test/tests/empty/build.sbt b/sbt-app/src/sbt-test/tests/empty/build.sbt index a4448f16f..e9ed5a04a 100644 --- a/sbt-app/src/sbt-test/tests/empty/build.sbt +++ b/sbt-app/src/sbt-test/tests/empty/build.sbt @@ -1,5 +1,5 @@ testGrouping := { - val tests = (definedTests in Test).value + val tests = (Test / definedTests).value tests map { test => new Tests.Group( name = test.name, diff --git a/sbt-app/src/sbt-test/tests/fork-parallel/build.sbt b/sbt-app/src/sbt-test/tests/fork-parallel/build.sbt index 2d60ab369..5a762a03d 100644 --- a/sbt-app/src/sbt-test/tests/fork-parallel/build.sbt +++ b/sbt-app/src/sbt-test/tests/fork-parallel/build.sbt @@ -7,7 +7,7 @@ val check = taskKey[Unit]("Check that tests are executed in parallel") lazy val root = (project in file(".")) .settings( libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test, - fork in Test := true, + Test / fork := true, check := { val nbProc = java.lang.Runtime.getRuntime().availableProcessors() val log = streams.value.log diff --git a/sbt-app/src/sbt-test/tests/fork-uncaught2/build.sbt b/sbt-app/src/sbt-test/tests/fork-uncaught2/build.sbt index 2eba9d278..533b61158 100644 --- a/sbt-app/src/sbt-test/tests/fork-uncaught2/build.sbt +++ b/sbt-app/src/sbt-test/tests/fork-uncaught2/build.sbt @@ -6,7 +6,7 @@ testFrameworks := new TestFramework("build.MyFramework") :: Nil fork := true -definedTests in Test += new sbt.TestDefinition( +Test / definedTests += new sbt.TestDefinition( "my", // marker fingerprint since there are no test classes // to be discovered by sbt: diff --git a/sbt-app/src/sbt-test/tests/fork/build.sbt b/sbt-app/src/sbt-test/tests/fork/build.sbt index 77c74e51b..bfefc042b 100644 --- a/sbt-app/src/sbt-test/tests/fork/build.sbt +++ b/sbt-app/src/sbt-test/tests/fork/build.sbt @@ -16,8 +16,8 @@ ThisBuild / organization := "org.example" lazy val root = (project in file(".")) .settings( - testGrouping in Test := { - val tests = (definedTests in Test).value + Test / testGrouping := { + val tests = (Test / definedTests).value assert(tests.size == 3) for (idx <- 0 until groups) yield new Group( @@ -32,7 +32,7 @@ lazy val root = (project in file(".")) file(groupPrefix(i) + j) val (exist, absent) = files.partition(_.exists) exist.foreach(_.delete()) - if(absent.nonEmpty) + if (absent.nonEmpty) sys.error("Files were not created:\n\t" + absent.mkString("\n\t")) }, concurrentRestrictions := Tags.limit(Tags.ForkedTestGroup, 2) :: Nil, diff --git a/sbt-app/src/sbt-test/tests/junit/test b/sbt-app/src/sbt-test/tests/junit/test index 73534741b..60912fdb7 100644 --- a/sbt-app/src/sbt-test/tests/junit/test +++ b/sbt-app/src/sbt-test/tests/junit/test @@ -10,5 +10,5 @@ $ copy-file changes/Failure.scala src/test/scala/Failure.scala -> testOnly com.foo.junit.test.blah.Failure > testOnly com.foo.junit.test.blah.Success -> set fork in Test := true +> set Test / fork := true > testOnly com.foo.junit.test.blah.Success diff --git a/sbt-app/src/sbt-test/tests/set-every/build.sbt b/sbt-app/src/sbt-test/tests/set-every/build.sbt index 718db97a1..8423f693f 100644 --- a/sbt-app/src/sbt-test/tests/set-every/build.sbt +++ b/sbt-app/src/sbt-test/tests/set-every/build.sbt @@ -3,14 +3,14 @@ val a = project.settings(version := "2.8.1") val trySetEvery = taskKey[Unit]("Tests \"set every\"") trySetEvery := { - val s = state.value - val extracted = Project.extract(s) - import extracted._ - val allProjs = structure.allProjectRefs - val Some(aProj) = allProjs.find(_.project == "a") - val aVer = (version in aProj get structure.data).get - if (aVer != "1.0") { - println("Version of project a: " + aVer + ", expected: 1.0") - sys.error("\"set every\" did not change the version of all projects.") - } + val s = state.value + val extracted = Project.extract(s) + import extracted._ + val allProjs = structure.allProjectRefs + val Some(aProj) = allProjs.find(_.project == "a") + val aVer = ((aProj / version) get structure.data).get + if (aVer != "1.0") { + println("Version of project a: " + aVer + ", expected: 1.0") + sys.error("\"set every\" did not change the version of all projects.") + } } diff --git a/sbt-app/src/sbt-test/watch/custom-config/project/Build.scala b/sbt-app/src/sbt-test/watch/custom-config/project/Build.scala index 7d88ac738..cc75af3a9 100644 --- a/sbt-app/src/sbt-test/watch/custom-config/project/Build.scala +++ b/sbt-app/src/sbt-test/watch/custom-config/project/Build.scala @@ -16,29 +16,34 @@ object Build { val Seq(stringFile, string) = Def.spaceDelimited().parsed assert(IO.read(file(stringFile)) == string) } - lazy val foo = project.settings( - watchStartMessage := { (count: Int, _, _) => Some(s"FOO $count") }, - Compile / compile / watchTriggers += baseDirectory.value.toGlob / "foo.txt", - Compile / compile / watchStartMessage := { (count: Int, _, _) => - // this checks that Compile / compile / watchStartMessage - // is preferred to Compile / watchStartMessage - val outputFile = baseDirectory.value / "foo.txt" - IO.write(outputFile, "compile") - Some(s"compile $count") - }, - Compile / watchStartMessage := { (count: Int, _, _) => Some(s"Compile $count") }, - Runtime / watchStartMessage := { (count: Int, _, _) => Some(s"Runtime $count") }, - setStringValue := { - val _ = (fileInputs in (bar, setStringValue)).value - setStringValueImpl.evaluated - }, - checkStringValue := checkStringValueImpl.evaluated, - watchOnFileInputEvent := { (_, _) => Watch.CancelWatch } - ) - lazy val bar = project.settings( - fileInputs in setStringValue += baseDirectory.value.toGlob / "foo.txt" - ) - lazy val root = (project in file(".")).aggregate(foo, bar).settings( - watchOnFileInputEvent := { (_, _) => Watch.CancelWatch } - ) + lazy val foo = project + .settings( + watchStartMessage := { (count: Int, _, _) => Some(s"FOO $count") }, + Compile / compile / watchTriggers += baseDirectory.value.toGlob / "foo.txt", + Compile / compile / watchStartMessage := { (count: Int, _, _) => + // this checks that Compile / compile / watchStartMessage + // is preferred to Compile / watchStartMessage + val outputFile = baseDirectory.value / "foo.txt" + IO.write(outputFile, "compile") + Some(s"compile $count") + }, + Compile / watchStartMessage := { (count: Int, _, _) => Some(s"Compile $count") }, + Runtime / watchStartMessage := { (count: Int, _, _) => Some(s"Runtime $count") }, + setStringValue := { + val _ = (bar / setStringValue / fileInputs).value + setStringValueImpl.evaluated + }, + checkStringValue := checkStringValueImpl.evaluated, + watchOnFileInputEvent := { (_, _) => Watch.CancelWatch } + ) + + lazy val bar = project + .settings( + setStringValue / fileInputs += baseDirectory.value.toGlob / "foo.txt" + ) + + lazy val root = (project in file(".")) + .aggregate(foo, bar).settings( + watchOnFileInputEvent := { (_, _) => Watch.CancelWatch } + ) } diff --git a/sbt-app/src/sbt-test/watch/file-input-aggregation/project/Build.scala b/sbt-app/src/sbt-test/watch/file-input-aggregation/project/Build.scala index 32b999320..2f42332a4 100644 --- a/sbt-app/src/sbt-test/watch/file-input-aggregation/project/Build.scala +++ b/sbt-app/src/sbt-test/watch/file-input-aggregation/project/Build.scala @@ -33,7 +33,7 @@ object Build { lazy val foo = project .settings( setStringValue := { - val _ = (fileInputs in (bar, setStringValue)).value + val _ = (bar / setStringValue / fileInputs).value setStringValueImpl.evaluated }, checkStringValue := checkStringValueImpl.evaluated, @@ -92,6 +92,7 @@ object Build { assert(testTriggers == compileTriggers) }, ) + lazy val root = (project in file(".")) .aggregate(foo, bar) .settings(