diff --git a/main-settings/src/main/scala/sbt/Previous.scala b/main-settings/src/main/scala/sbt/Previous.scala index aaa61c320..acd6ba18f 100644 --- a/main-settings/src/main/scala/sbt/Previous.scala +++ b/main-settings/src/main/scala/sbt/Previous.scala @@ -10,6 +10,7 @@ package sbt import sbt.Def.{ Initialize, ScopedKey } import sbt.Previous._ import sbt.Scope.Global +import sbt.SlashSyntax0._ import sbt.internal.util._ import sbt.std.TaskExtra._ import sbt.util.StampedFormat @@ -146,7 +147,7 @@ object Previous { /** Public as a macro implementation detail. Do not call directly. */ def runtime[T](skey: TaskKey[T])(implicit format: JsonFormat[T]): Initialize[Task[Option[T]]] = { - val inputs = (cache in Global) zip Def.validated(skey, selfRefOk = true) zip (references in Global) + val inputs = (Global / cache) zip Def.validated(skey, selfRefOk = true) zip (Global / references) inputs { case ((prevTask, resolved), refs) => val key = Key(resolved, resolved) @@ -159,9 +160,9 @@ object Previous { def runtimeInEnclosingTask[T](skey: TaskKey[T])( implicit format: JsonFormat[T] ): Initialize[Task[Option[T]]] = { - val inputs = (cache in Global) + val inputs = (Global / cache) .zip(Def.validated(skey, selfRefOk = true)) - .zip(references in Global) + .zip(Global / references) .zip(Def.resolvedScoped) inputs { case (((prevTask, resolved), refs), inTask: ScopedKey[Task[_]] @unchecked) => diff --git a/main-settings/src/main/scala/sbt/Scope.scala b/main-settings/src/main/scala/sbt/Scope.scala index 28c3daa3d..4fa31f51c 100644 --- a/main-settings/src/main/scala/sbt/Scope.scala +++ b/main-settings/src/main/scala/sbt/Scope.scala @@ -20,16 +20,29 @@ final case class Scope( task: ScopeAxis[AttributeKey[_]], extra: ScopeAxis[AttributeMap] ) { + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(project: Reference, config: ConfigKey): Scope = copy(project = Select(project), config = Select(config)) + + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(config: ConfigKey, task: AttributeKey[_]): Scope = copy(config = Select(config), task = Select(task)) + + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(project: Reference, task: AttributeKey[_]): Scope = copy(project = Select(project), task = Select(task)) + + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(project: Reference, config: ConfigKey, task: AttributeKey[_]): Scope = copy(project = Select(project), config = Select(config), task = Select(task)) + + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(project: Reference): Scope = copy(project = Select(project)) + + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(config: ConfigKey): Scope = copy(config = Select(config)) + + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(task: AttributeKey[_]): Scope = copy(task = Select(task)) override def toString: String = this match { @@ -43,6 +56,9 @@ object Scope { val Global: Scope = Scope(Zero, Zero, Zero, Zero) val GlobalScope: Scope = Global + private[sbt] final val inIsDeprecated = + "`in` is deprecated; migrate to slash syntax - https://www.scala-sbt.org/1.x/docs/Migrating-from-sbt-013x.html#slash" + def resolveScope(thisScope: Scope, current: URI, rootProject: URI => String): Scope => Scope = resolveProject(current, rootProject) compose replaceThis(thisScope) compose subThisProject diff --git a/main-settings/src/main/scala/sbt/SlashSyntax.scala b/main-settings/src/main/scala/sbt/SlashSyntax.scala index db940e220..ae774b30a 100644 --- a/main-settings/src/main/scala/sbt/SlashSyntax.scala +++ b/main-settings/src/main/scala/sbt/SlashSyntax.scala @@ -9,6 +9,7 @@ package sbt import sbt.librarymanagement.Configuration import sbt.internal.util.AttributeKey +import scala.annotation.nowarn /** * SlashSyntax implements the slash syntax to scope keys for build.sbt DSL. @@ -60,19 +61,25 @@ object SlashSyntax { sealed trait HasSlashKey { protected def scope: Scope + @nowarn final def /[K](key: Scoped.ScopingSetting[K]): K = key in scope } sealed trait HasSlashKeyOrAttrKey extends HasSlashKey { + @nowarn final def /(key: AttributeKey[_]): RichScope = new RichScope(scope in key) } /** RichReference wraps a reference to provide the `/` operator for scoping. */ final class RichReference(protected val scope: Scope) extends HasSlashKeyOrAttrKey { + @nowarn def /(c: ConfigKey): RichConfiguration = new RichConfiguration(scope in c) + + @nowarn def /(c: Configuration): RichConfiguration = new RichConfiguration(scope in c) // This is for handling `Zero / Zero / name`. + @nowarn def /(configAxis: ScopeAxis[ConfigKey]): RichConfiguration = new RichConfiguration(scope.copy(config = configAxis)) } @@ -85,7 +92,7 @@ object SlashSyntax { } /** RichScope wraps a general scope to provide the `/` operator for scoping. */ - final class RichScope(protected val scope: Scope) extends HasSlashKey + final class RichScope(protected val scope: Scope) extends HasSlashKeyOrAttrKey } diff --git a/main-settings/src/main/scala/sbt/Structure.scala b/main-settings/src/main/scala/sbt/Structure.scala index 83c57ec16..6ac79293a 100644 --- a/main-settings/src/main/scala/sbt/Structure.scala +++ b/main-settings/src/main/scala/sbt/Structure.scala @@ -68,6 +68,7 @@ sealed abstract class SettingKey[T] final def scopedKey: ScopedKey[T] = ScopedKey(scope, key) + // @deprecated(Scope.inIsDeprecated, "1.5.0") final def in(scope: Scope): SettingKey[T] = Scoped.scopedSetting(Scope.replaceThis(this.scope)(scope), this.key) @@ -140,6 +141,7 @@ sealed abstract class TaskKey[T] def scopedKey: ScopedKey[Task[T]] = ScopedKey(scope, key) + // @deprecated(Scope.inIsDeprecated, "1.5.0") def in(scope: Scope): TaskKey[T] = Scoped.scopedTask(Scope.replaceThis(this.scope)(scope), this.key) @@ -206,6 +208,7 @@ sealed trait InputKey[T] def scopedKey: ScopedKey[InputTask[T]] = ScopedKey(scope, key) + // @deprecated(Scope.inIsDeprecated, "1.5.0") def in(scope: Scope): InputKey[T] = Scoped.scopedInput(Scope.replaceThis(this.scope)(scope), this.key) @@ -244,18 +247,32 @@ object Scoped { * */ sealed trait ScopingSetting[ResultType] { + // @deprecated(Scope.inIsDeprecated, "1.5.0") def in(s: Scope): ResultType + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(p: Reference): ResultType = in(Select(p), This, This) + + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(t: Scoped): ResultType = in(This, This, Select(t.key)) + + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(c: ConfigKey): ResultType = in(This, Select(c), This) + + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(c: ConfigKey, t: Scoped): ResultType = in(This, Select(c), Select(t.key)) + + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(p: Reference, c: ConfigKey): ResultType = in(Select(p), Select(c), This) + + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(p: Reference, t: Scoped): ResultType = in(Select(p), This, Select(t.key)) + @deprecated(Scope.inIsDeprecated, "1.5.0") def in(p: Reference, c: ConfigKey, t: Scoped): ResultType = in(Select(p), Select(c), Select(t.key)) + @deprecated(Scope.inIsDeprecated, "1.5.0") def in( p: ScopeAxis[Reference], c: ScopeAxis[ConfigKey], diff --git a/main-settings/src/test/scala/sbt/BuildSettingsInstances.scala b/main-settings/src/test/scala/sbt/BuildSettingsInstances.scala index 8d9b32cb0..313459dbb 100644 --- a/main-settings/src/test/scala/sbt/BuildSettingsInstances.scala +++ b/main-settings/src/test/scala/sbt/BuildSettingsInstances.scala @@ -26,6 +26,7 @@ import sbt.ConfigKey import sbt.librarymanagement.syntax._ import sbt.{ InputKey, SettingKey, TaskKey } import sbt.internal.util.{ AttributeKey, AttributeMap } +import scala.annotation.nowarn object BuildSettingsInstances { val genFile: Gen[File] = Gen.oneOf(new File("."), new File("/tmp")) // for now.. @@ -99,6 +100,7 @@ object BuildSettingsInstances { def genSettingKey[A: Manifest]: Gen[SettingKey[A]] = genLabel map (x => SettingKey[A](x.value)) def genTaskKey[A: Manifest]: Gen[TaskKey[A]] = genLabel map (x => TaskKey[A](x.value)) + @nowarn def withScope[K <: Scoped.ScopingSetting[K]](keyGen: Gen[K]): Arbitrary[K] = Arbitrary { Gen.frequency( 5 -> keyGen, diff --git a/main-settings/src/test/scala/sbt/ScopeDisplaySpec.scala b/main-settings/src/test/scala/sbt/ScopeDisplaySpec.scala index 103b62802..c1af590b4 100644 --- a/main-settings/src/test/scala/sbt/ScopeDisplaySpec.scala +++ b/main-settings/src/test/scala/sbt/ScopeDisplaySpec.scala @@ -10,10 +10,13 @@ package sbt import org.scalatest.FlatSpec import sbt.internal.util.{ AttributeKey, AttributeMap } import sbt.io.syntax.file +import scala.annotation.nowarn class ScopeDisplaySpec extends FlatSpec { val project = ProjectRef(file("foo/bar"), "bar") val mangledName = "bar_slash_blah_blah_blah" + + @nowarn val scopedKey = Def.ScopedKey(Scope.Global in project, AttributeKey[Task[String]](mangledName)) val am = AttributeMap.empty.put(Scope.customShowString, "blah") val sanitizedKey = scopedKey.copy(scope = scopedKey.scope.copy(extra = Select(am))) diff --git a/main-settings/src/test/scala/sbt/SlashSyntaxSpec.scala b/main-settings/src/test/scala/sbt/SlashSyntaxSpec.scala index b9035124c..159276235 100644 --- a/main-settings/src/test/scala/sbt/SlashSyntaxSpec.scala +++ b/main-settings/src/test/scala/sbt/SlashSyntaxSpec.scala @@ -16,7 +16,9 @@ import sbt.ConfigKey import sbt.internal.util.AttributeKey import BuildSettingsInstances._ +import scala.annotation.nowarn +@nowarn object SlashSyntaxSpec extends Properties("SlashSyntax") with SlashSyntax { property("Global / key == key in Global") = { forAll((k: Key) => expectValue(k in Global)(Global / k)) diff --git a/main/src/main/scala/sbt/Cross.scala b/main/src/main/scala/sbt/Cross.scala index 21902e4d4..8bb001d04 100644 --- a/main/src/main/scala/sbt/Cross.scala +++ b/main/src/main/scala/sbt/Cross.scala @@ -11,6 +11,7 @@ import java.io.File import sbt.Def.{ ScopedKey, Setting } import sbt.Keys._ +import sbt.SlashSyntax0._ import sbt.internal.Act import sbt.internal.CommandStrings._ import sbt.internal.inc.ScalaInstance @@ -102,9 +103,9 @@ object Cross { private def crossVersions(extracted: Extracted, proj: ResolvedReference): Seq[String] = { import extracted._ - (crossScalaVersions in proj get structure.data) getOrElse { + ((proj / crossScalaVersions) get structure.data) getOrElse { // reading scalaVersion is a one-time deal - (scalaVersion in proj get structure.data).toSeq + ((proj / scalaVersion) get structure.data).toSeq } } @@ -358,16 +359,16 @@ object Cross { instance match { case Some((home, inst)) => Seq( - scalaVersion in scope := version, - crossScalaVersions in scope := scalaVersions, - scalaHome in scope := Some(home), - scalaInstance in scope := inst + scope / scalaVersion := version, + scope / crossScalaVersions := scalaVersions, + scope / scalaHome := Some(home), + scope / scalaInstance := inst ) case None => Seq( - scalaVersion in scope := version, - crossScalaVersions in scope := scalaVersions, - scalaHome in scope := None + scope / scalaVersion := version, + scope / crossScalaVersions := scalaVersions, + scope / scalaHome := None ) } } diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index d8c9fedaf..043aae118 100644 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -135,7 +135,7 @@ object Defaults extends BuildCommon { def configSrcSub(key: SettingKey[File]): Initialize[File] = Def.setting { - (key in ThisScope.copy(config = Zero)).value / nameForSrc(configuration.value.name) + (ThisScope.copy(config = Zero) / key).value / nameForSrc(configuration.value.name) } def nameForSrc(config: String) = if (config == Configurations.Compile.name) "main" else config def prefix(config: String) = if (config == Configurations.Compile.name) "" else config + "-" @@ -191,12 +191,12 @@ object Defaults extends BuildCommon { extraIncOptions :== Seq("JAVA_CLASS_VERSION" -> sys.props("java.class.version")), allowMachinePath :== true, reportAbsolutePath := true, - traceLevel in run :== 0, - traceLevel in runMain :== 0, - traceLevel in bgRun :== 0, - traceLevel in fgRun :== 0, - traceLevel in console :== Int.MaxValue, - traceLevel in consoleProject :== Int.MaxValue, + run / traceLevel :== 0, + runMain / traceLevel :== 0, + bgRun / traceLevel :== 0, + fgRun / traceLevel :== 0, + console / traceLevel :== Int.MaxValue, + consoleProject / traceLevel :== Int.MaxValue, autoCompilerPlugins :== true, scalaHome :== None, apiURL := None, @@ -211,12 +211,12 @@ object Defaults extends BuildCommon { reresolveSbtArtifacts :== false, crossPaths :== true, sourcePositionMappers :== Nil, - artifactClassifier in packageSrc :== Some(SourceClassifier), - artifactClassifier in packageDoc :== Some(DocClassifier), + packageSrc / artifactClassifier :== Some(SourceClassifier), + packageDoc / artifactClassifier :== Some(DocClassifier), includeFilter :== NothingFilter, - includeFilter in unmanagedSources :== ("*.java" | "*.scala"), - includeFilter in unmanagedJars :== "*.jar" | "*.so" | "*.dll" | "*.jnilib" | "*.zip", - includeFilter in unmanagedResources :== AllPassFilter, + unmanagedSources / includeFilter :== ("*.java" | "*.scala"), + unmanagedJars / includeFilter :== "*.jar" | "*.so" | "*.dll" | "*.jnilib" | "*.zip", + unmanagedResources / includeFilter :== AllPassFilter, bgList := { bgJobService.value.jobs }, ps := psTask.value, bgStop := bgStopTask.evaluated, @@ -279,8 +279,8 @@ object Defaults extends BuildCommon { outputStrategy :== None, // TODO - This might belong elsewhere. buildStructure := Project.structure(state.value), settingsData := buildStructure.value.data, - aggregate in checkBuildSources :== false, - aggregate in checkBuildSources / changedInputFiles := false, + checkBuildSources / aggregate :== false, + checkBuildSources / changedInputFiles / aggregate := false, checkBuildSources / Continuous.dynamicInputs := None, checkBuildSources / fileInputs := CheckBuildSources.buildSourceFileInputs.value, checkBuildSources := CheckBuildSources.needReloadImpl.value, @@ -298,7 +298,7 @@ object Defaults extends BuildCommon { // `pluginCrossBuild` scoping is based on sbt-cross-building plugin. // The idea here is to be able to define a `sbtVersion in pluginCrossBuild`, which // directs the dependencies of the plugin to build to the specified sbt plugin version. - sbtVersion in pluginCrossBuild := sbtVersion.value, + pluginCrossBuild / sbtVersion := sbtVersion.value, onLoad := idFun[State], onUnload := idFun[State], onUnload := { s => @@ -572,13 +572,13 @@ object Defaults extends BuildCommon { makePluginCrossSources( sbtPlugin.value, scalaSource.value, - (sbtBinaryVersion in pluginCrossBuild).value, + (pluginCrossBuild / sbtBinaryVersion).value, crossPaths.value ) }, unmanagedSources / fileInputs := { - val include = (includeFilter in unmanagedSources).value - val filter = (excludeFilter in unmanagedSources).value match { + val include = (unmanagedSources / includeFilter).value + val filter = (unmanagedSources / excludeFilter).value match { // Hidden files are already filtered out by the FileStamps method case NothingFilter | HiddenFileFilter => include case exclude => include -- exclude @@ -617,8 +617,8 @@ object Defaults extends BuildCommon { .concatSettings(unmanagedResourceDirectories, managedResourceDirectories) .value, unmanagedResources / fileInputs := { - val include = (includeFilter in unmanagedResources).value - val filter = (excludeFilter in unmanagedResources).value match { + val include = (unmanagedResources / includeFilter).value + val filter = (unmanagedResources / excludeFilter).value match { // Hidden files are already filtered out by the FileStamps method case NothingFilter | HiddenFileFilter => include case exclude => include -- exclude @@ -651,25 +651,25 @@ object Defaults extends BuildCommon { semanticdbTargetRoot := crossTarget.value / (prefix(configuration.value.name) + "meta"), compileAnalysisTargetRoot := crossTarget.value / (prefix(configuration.value.name) + "zinc"), earlyCompileAnalysisTargetRoot := crossTarget.value / (prefix(configuration.value.name) + "early-zinc"), - target in doc := crossTarget.value / (prefix(configuration.value.name) + "api") + doc / target := crossTarget.value / (prefix(configuration.value.name) + "api") ) // This is included into JvmPlugin.projectSettings def compileBase = inTask(console)(compilersSetting :: Nil) ++ compileBaseGlobal ++ Seq( scalaInstance := scalaInstanceTask.value, crossVersion := (if (crossPaths.value) CrossVersion.binary else CrossVersion.disabled), - sbtBinaryVersion in pluginCrossBuild := binarySbtVersion( - (sbtVersion in pluginCrossBuild).value + pluginCrossBuild / sbtBinaryVersion := binarySbtVersion( + (pluginCrossBuild / sbtVersion).value ), // Use (sbtVersion in pluginCrossBuild) to pick the sbt module to depend from the plugin. // Because `sbtVersion in pluginCrossBuild` can be scoped to project level, // this setting needs to be set here too. - sbtDependency in pluginCrossBuild := { + pluginCrossBuild / sbtDependency := { val app = appConfiguration.value val id = app.provider.id - val sv = (sbtVersion in pluginCrossBuild).value - val scalaV = (scalaVersion in pluginCrossBuild).value - val binVersion = (scalaBinaryVersion in pluginCrossBuild).value + val sv = (pluginCrossBuild / sbtVersion).value + val scalaV = (pluginCrossBuild / scalaVersion).value + val binVersion = (pluginCrossBuild / scalaBinaryVersion).value val cross = id.crossVersionedValue match { case CrossValue.Disabled => Disabled() case CrossValue.Full => CrossVersion.full @@ -678,11 +678,11 @@ object Defaults extends BuildCommon { val base = ModuleID(id.groupID, id.name, sv).withCrossVersion(cross) CrossVersion(scalaV, binVersion)(base).withCrossVersion(Disabled()) }, - crossSbtVersions := Vector((sbtVersion in pluginCrossBuild).value), + crossSbtVersions := Vector((pluginCrossBuild / sbtVersion).value), crossTarget := makeCrossTarget( target.value, scalaBinaryVersion.value, - (sbtBinaryVersion in pluginCrossBuild).value, + (pluginCrossBuild / sbtBinaryVersion).value, sbtPlugin.value, crossPaths.value ), @@ -705,7 +705,7 @@ object Defaults extends BuildCommon { auxiliaryClassFiles := Nil, incOptions := IncOptions.of(), classpathOptions :== ClasspathOptionsUtil.boot, - classpathOptions in console :== ClasspathOptionsUtil.repl, + console / classpathOptions :== ClasspathOptionsUtil.repl, compileOrder :== CompileOrder.Mixed, javacOptions :== Nil, scalacOptions :== Nil, @@ -946,7 +946,7 @@ object Defaults extends BuildCommon { // This fork options, scoped to the configuration is used for tests forkOptions := forkOptionsTask.value, selectMainClass := mainClass.value orElse askForMainClass(discoveredMainClasses.value), - mainClass in run := (selectMainClass in run).value, + run / mainClass := (run / selectMainClass).value, mainClass := { val logWarning = state.value.currentCommand .flatMap(_.commandLine.split(" ").headOption.map(_.trim)) @@ -958,8 +958,8 @@ object Defaults extends BuildCommon { }, runMain := foregroundRunMainTask.evaluated, run := foregroundRunTask.evaluated, - fgRun := runTask(fullClasspath, mainClass in run, runner in run).evaluated, - fgRunMain := runMainTask(fullClasspath, runner in run).evaluated, + fgRun := runTask(fullClasspath, (run / mainClass), (run / runner)).evaluated, + fgRunMain := runMainTask(fullClasspath, (run / runner)).evaluated, copyResources := copyResourcesTask.value, // note that we use the same runner and mainClass as plain run mainBgRunMainTaskForConfig(This), @@ -1020,7 +1020,7 @@ object Defaults extends BuildCommon { val msg = watchingMessage.?.value.getOrElse(Watched.defaultWatchingMessage) val trigMsg = triggeredMessage.?.value.getOrElse(Watched.defaultTriggeredMessage) new Watched { - val scoped = watchTransitiveSources in base + val scoped = (base / watchTransitiveSources) val key = scoped.scopedKey override def antiEntropy: FiniteDuration = _antiEntropy override def pollInterval: FiniteDuration = interval @@ -1189,7 +1189,7 @@ object Defaults extends BuildCommon { testListeners :== Nil, testOptions :== Nil, testResultLogger :== TestResultLogger.Default, - testFilter in testOnly :== (selectedFilter _) + testOnly / testFilter :== (selectedFilter _) ) ) lazy val testTasks @@ -1204,27 +1204,27 @@ object Defaults extends BuildCommon { }, definedTests := detectTests.value, definedTestNames := (definedTests map (_.map(_.name).distinct) storeAs definedTestNames triggeredBy compile).value, - testFilter in testQuick := testQuickFilter.value, + testQuick / testFilter := testQuickFilter.value, executeTests := ( Def.taskDyn { allTestGroupsTask( - (streams in test).value, + (test / streams).value, loadedTestFrameworks.value, testLoader.value, - (testGrouping in test).value, - (testExecution in test).value, - (fullClasspath in test).value, + (test / testGrouping).value, + (test / testExecution).value, + (test / fullClasspath).value, testForkedParallel.value, - (javaOptions in test).value, + (test / javaOptions).value, (classLoaderLayeringStrategy).value, projectId = s"${thisProject.value.id} / ", ) } ).value, // ((streams in test, loadedTestFrameworks, testLoader, testGrouping in test, testExecution in test, fullClasspath in test, javaHome in test, testForkedParallel, javaOptions in test) flatMap allTestGroupsTask).value, - testResultLogger in (Test, test) :== TestResultLogger.SilentWhenNoTests, // https://github.com/sbt/sbt/issues/1185 + Test / test / testResultLogger :== TestResultLogger.SilentWhenNoTests, // https://github.com/sbt/sbt/issues/1185 test := { - val trl = (testResultLogger in (Test, test)).value + val trl = (Test / test / testResultLogger).value val taskName = Project.showContextKey(state.value).show(resolvedScoped.value) try trl.run(streams.value.log, executeTests.value, taskName) finally close(testLoader.value) @@ -1264,15 +1264,15 @@ object Defaults extends BuildCommon { streams.value.log, closeableTestLogger( streamsManager.value, - test in resolvedScoped.value.scope, + (resolvedScoped.value.scope / test), logBuffered.value ), Keys.logLevel.?.value.getOrElse(stateLogLevel), ) +: - new TestStatusReporter(succeededFile(streams.in(test).value.cacheDirectory)) +: - testListeners.in(TaskZero).value + new TestStatusReporter(succeededFile((test / streams).value.cacheDirectory)) +: + (TaskZero / testListeners).value }, - testOptions := Tests.Listeners(testListeners.value) +: (testOptions in TaskZero).value, + testOptions := Tests.Listeners(testListeners.value) +: (TaskZero / testOptions).value, testExecution := testExecutionTask(key).value ) ) ++ inScope(GlobalScope)( @@ -1332,16 +1332,16 @@ object Defaults extends BuildCommon { def testExecutionTask(task: Scoped): Initialize[Task[Tests.Execution]] = Def.task { new Tests.Execution( - (testOptions in task).value, - (parallelExecution in task).value, - (tags in task).value + (task / testOptions).value, + (task / parallelExecution).value, + (task / tags).value ) } def testQuickFilter: Initialize[Task[Seq[String] => Seq[String => Boolean]]] = Def.task { - val cp = (fullClasspath in test).value - val s = (streams in test).value + val cp = (test / fullClasspath).value + val s = (test / streams).value val ans: Seq[Analysis] = cp.flatMap(_.metadata get Keys.analysis) map { case a0: Analysis => a0 } @@ -1383,8 +1383,10 @@ object Defaults extends BuildCommon { } def succeededFile(dir: File) = dir / "succeeded_tests" + @nowarn def inputTests(key: InputKey[_]): Initialize[InputTask[Unit]] = inputTests0.mapReferenced(Def.mapScope(_ in key.key)) + private[this] lazy val inputTests0: Initialize[InputTask[Unit]] = { val parser = loadForParser(definedTestNames)((s, i) => testOnlyParser(s, i getOrElse Nil)) Def.inputTaskDyn { @@ -1711,8 +1713,8 @@ object Defaults extends BuildCommon { crossTarget.value / (prefix(configuration.value.name) + extraPrefix) / f( ScalaVersion( - (scalaVersion in artifactName).value, - (scalaBinaryVersion in artifactName).value + (artifactName / scalaVersion).value, + (artifactName / scalaBinaryVersion).value ), projectID.value, art.value @@ -1727,8 +1729,8 @@ object Defaults extends BuildCommon { val f = artifactName.value crossTarget.value / extraPrefix / f( ScalaVersion( - (scalaVersion in artifactName).value, - (scalaBinaryVersion in artifactName).value + (artifactName / scalaVersion).value, + (artifactName / scalaBinaryVersion).value ), projectID.value, art.value @@ -1740,8 +1742,8 @@ object Defaults extends BuildCommon { val f = artifactName.value crossTarget.value / f( ScalaVersion( - (scalaVersion in artifactName).value, - (scalaBinaryVersion in artifactName).value + (artifactName / scalaVersion).value, + (artifactName / scalaBinaryVersion).value ), projectID.value, art.value @@ -1787,7 +1789,7 @@ object Defaults extends BuildCommon { def packageTaskSettings(key: TaskKey[File], mappingsTask: Initialize[Task[Seq[(File, String)]]]) = inTask(key)( Seq( - key in TaskZero := packageTask.value, + (TaskZero / key) := packageTask.value, packageConfiguration := packageConfigurationTask.value, mappings := mappingsTask.value, packagedArtifact := (artifact.value -> key.value), @@ -1881,7 +1883,7 @@ object Defaults extends BuildCommon { Def.inputTask { val service = bgJobService.value val (mainClass, args) = parser.parsed - val hashClasspath = (bgHashClasspath in bgRunMain).value + val hashClasspath = (bgRunMain / bgHashClasspath).value val wrapper = termWrapper(canonicalInput.value, echoInput.value) service.runInBackgroundWithLoader(resolvedScoped.value, state.value) { (logger, workingDir) => val files = @@ -1912,7 +1914,7 @@ object Defaults extends BuildCommon { Def.inputTask { val service = bgJobService.value val mainClass = mainClassTask.value getOrElse sys.error("No main class detected.") - val hashClasspath = (bgHashClasspath in bgRun).value + val hashClasspath = (bgRun / bgHashClasspath).value val wrapper = termWrapper(canonicalInput.value, echoInput.value) service.runInBackgroundWithLoader(resolvedScoped.value, state.value) { (logger, workingDir) => val files = @@ -1990,13 +1992,13 @@ object Defaults extends BuildCommon { if (options.nonEmpty) { val mask = ScopeMask(project = false) val showJavaOptions = Scope.displayMasked( - (javaOptions in resolvedScope).scopedKey.scope, - (javaOptions in resolvedScope).key.label, + (resolvedScope / javaOptions).scopedKey.scope, + (resolvedScope / javaOptions).key.label, mask ) val showFork = Scope.displayMasked( - (fork in resolvedScope).scopedKey.scope, - (fork in resolvedScope).key.label, + (resolvedScope / fork).scopedKey.scope, + (resolvedScope / fork).key.label, mask ) s.log.warn(s"$showJavaOptions will be ignored, $showFork is set to false") @@ -2062,7 +2064,7 @@ object Defaults extends BuildCommon { Seq("-project", project) } else compileOptions }, - key in TaskZero := { + (TaskZero / key) := { val s = streams.value val cs: Compilers = compilers.value val srcs = sources.value @@ -2128,18 +2130,18 @@ object Defaults extends BuildCommon { private[this] def mainBgRunTaskForConfig(c: ScopeAxis[ConfigKey]) = bgRun := bgRunTask( exportedProductJars, - fullClasspathAsJars in (This, c, This), - mainClass in run, - bgCopyClasspath in bgRun, - runner in run + This / c / This / fullClasspathAsJars, + run / mainClass, + bgRun / bgCopyClasspath, + run / runner ).evaluated private[this] def mainBgRunMainTaskForConfig(c: ScopeAxis[ConfigKey]) = bgRunMain := bgRunMainTask( exportedProductJars, - fullClasspathAsJars in (This, c, This), - bgCopyClasspath in bgRunMain, - runner in run + This / c / This / fullClasspathAsJars, + bgRunMain / bgCopyClasspath, + run / runner ).evaluated def discoverMainClasses(analysis: CompileAnalysis): Seq[String] = analysis match { @@ -2149,7 +2151,7 @@ object Defaults extends BuildCommon { def consoleProjectTask = Def.task { - ConsoleProject(state.value, (initialCommands in consoleProject).value)(streams.value.log) + ConsoleProject(state.value, (consoleProject / initialCommands).value)(streams.value.log) println() } @@ -2157,19 +2159,19 @@ object Defaults extends BuildCommon { def consoleQuickTask = consoleTask(externalDependencyClasspath, consoleQuick) def consoleTask(classpath: TaskKey[Classpath], task: TaskKey[_]): Initialize[Task[Unit]] = Def.task { - val si = (scalaInstance in task).value + val si = (task / scalaInstance).value val s = streams.value - val cpFiles = data((classpath in task).value) + val cpFiles = data((task / classpath).value) val fullcp = (cpFiles ++ si.allJars).distinct - val tempDir = IO.createUniqueDirectory((taskTemporaryDirectory in task).value).toPath + val tempDir = IO.createUniqueDirectory((task / taskTemporaryDirectory).value).toPath val loader = ClasspathUtil.makeLoader(fullcp.map(_.toPath), si, tempDir) val compiler = - (compilers in task).value.scalac match { + (task / compilers).value.scalac match { case ac: AnalyzingCompiler => ac.onArgs(exported(s, "scala")) } - val sc = (scalacOptions in task).value - val ic = (initialCommands in task).value - val cc = (cleanupCommands in task).value + val sc = (task / scalacOptions).value + val ic = (task / initialCommands).value + val cc = (task / cleanupCommands).value (new Console(compiler))(cpFiles, sc, loader, ic, cc)()(s.log).get println() } @@ -2332,7 +2334,7 @@ object Defaults extends BuildCommon { else None Setup.of( lookup, - (skip in compile).value, + (compile / skip).value, compileAnalysisFile.value.toPath, compilerCache.value, incOptions.value, @@ -2493,7 +2495,7 @@ object Defaults extends BuildCommon { def noAggregation: Seq[Scoped] = Seq(run, runMain, bgRun, bgRunMain, console, consoleQuick, consoleProject) lazy val disableAggregation = Defaults.globalDefaults(noAggregation map disableAggregate) - def disableAggregate(k: Scoped) = aggregate in k :== false + def disableAggregate(k: Scoped) = (k / aggregate) :== false // 1. runnerSettings is added unscoped via JvmPlugin. // 2. In addition it's added scoped to run task. @@ -2634,8 +2636,8 @@ object Classpaths { unmanagedJars := findUnmanagedJars( configuration.value, unmanagedBase.value, - includeFilter in unmanagedJars value, - excludeFilter in unmanagedJars value + (unmanagedJars / includeFilter) value, + (unmanagedJars / excludeFilter) value ) ).map(exportClasspath) ++ Seq( externalDependencyClasspath / outputFileStamps := { @@ -2698,7 +2700,7 @@ object Classpaths { def defaultPackageKeys = Seq(packageBin, packageSrc, packageDoc) lazy val defaultPackages: Seq[TaskKey[File]] = - for (task <- defaultPackageKeys; conf <- Seq(Compile, Test)) yield (task in conf) + for (task <- defaultPackageKeys; conf <- Seq(Compile, Test)) yield (conf / task) lazy val defaultArtifactTasks: Seq[TaskKey[File]] = makePom +: defaultPackages def findClasspathConfig( @@ -2729,6 +2731,7 @@ object Classpaths { case (a, true) => a }) + @nowarn def forallIn[T]( key: Scoped.ScopingSetting[SettingKey[T]], // should be just SettingKey[T] (mea culpa) pkgTasks: Seq[TaskKey[_]], @@ -2740,7 +2743,7 @@ object Classpaths { Seq( publishMavenStyle :== true, publishArtifact :== true, - publishArtifact in Test :== false + (Test / publishArtifact) :== false ) ) @@ -2759,7 +2762,7 @@ object Classpaths { publisher.makePomFile(ivyModule.value, config, streams.value.log) config.file.get }, - packagedArtifact in makePom := ((artifact in makePom).value -> makePom.value), + (makePom / packagedArtifact) := ((makePom / artifact).value -> makePom.value), deliver := deliverTask(makeIvyXmlConfiguration).value, deliverLocal := deliverTask(makeIvyXmlLocalConfiguration).value, makeIvyXml := deliverTask(makeIvyXmlConfiguration).value, @@ -2936,8 +2939,8 @@ object Classpaths { Def.setting { Option( ScalaModuleInfo( - (scalaVersion in update).value, - (scalaBinaryVersion in update).value, + (update / scalaVersion).value, + (update / scalaBinaryVersion).value, Vector.empty, filterImplicit = false, checkExplicit = true, @@ -2947,9 +2950,9 @@ object Classpaths { ) } )).value, - artifactPath in makePom := artifactPathSetting(artifact in makePom).value, - publishArtifact in makePom := publishMavenStyle.value && publishArtifact.value, - artifact in makePom := Artifact.pom(moduleName.value), + makePom / artifactPath := artifactPathSetting((makePom / artifact)).value, + makePom / publishArtifact := publishMavenStyle.value && publishArtifact.value, + makePom / artifact := Artifact.pom(moduleName.value), projectID := defaultProjectID.value, projectID := pluginProjectID.value, projectDescriptors := depMap.value, @@ -3029,7 +3032,7 @@ object Classpaths { }, moduleSettings := moduleSettings0.value, makePomConfiguration := MakePomConfiguration() - .withFile((artifactPath in makePom).value) + .withFile((makePom / artifactPath).value) .withModuleInfo(projectInfo.value) .withExtra(pomExtra.value) .withProcess(pomPostProcess.value) @@ -3042,7 +3045,7 @@ object Classpaths { sbt.Classpaths.deliverPattern(crossTarget.value), if (isSnapshot.value) "integration" else "release", ivyConfigurations.value.map(c => ConfigRef(c.name)).toVector, - checksums.in(publish).value.toVector, + (publish / checksums).value.toVector, ivyLoggingLevel.value, isSnapshot.value ) @@ -3061,8 +3064,8 @@ object Classpaths { deliverPattern(crossTarget.value), if (isSnapshot.value) "integration" else "release", ivyConfigurations.value.map(c => ConfigRef(c.name)).toVector, - packagedArtifacts.in(publish).value.toVector, - checksums.in(publish).value.toVector, + (publish / packagedArtifacts).value.toVector, + (publish / checksums).value.toVector, getPublishTo(publishTo.value).name, ivyLoggingLevel.value, isSnapshot.value @@ -3074,7 +3077,7 @@ object Classpaths { sbt.Classpaths.deliverPattern(crossTarget.value), if (isSnapshot.value) "integration" else "release", ivyConfigurations.value.map(c => ConfigRef(c.name)).toVector, - checksums.in(publish).value.toVector, + (publish / checksums).value.toVector, ivyLoggingLevel.value, isSnapshot.value, optResolverName = Some("local") @@ -3085,8 +3088,8 @@ object Classpaths { deliverPattern(crossTarget.value), if (isSnapshot.value) "integration" else "release", ivyConfigurations.value.map(c => ConfigRef(c.name)).toVector, - packagedArtifacts.in(publishLocal).value.toVector, - checksums.in(publishLocal).value.toVector, + (publishLocal / packagedArtifacts).value.toVector, + (publishLocal / checksums).value.toVector, logging = ivyLoggingLevel.value, overwrite = isSnapshot.value ), @@ -3095,8 +3098,8 @@ object Classpaths { deliverPattern(crossTarget.value), if (isSnapshot.value) "integration" else "release", ivyConfigurations.value.map(c => ConfigRef(c.name)).toVector, - packagedArtifacts.in(publishM2).value.toVector, - checksums = checksums.in(publishM2).value.toVector, + (publishM2 / packagedArtifacts).value.toVector, + checksums = (publishM2 / checksums).value.toVector, resolverName = Resolver.publishMavenLocal.name, logging = ivyLoggingLevel.value, overwrite = isSnapshot.value @@ -3111,7 +3114,7 @@ object Classpaths { s"update_cache$suffix" }, dependencyPositions := dependencyPositionsTask.value, - unresolvedWarningConfiguration in update := UnresolvedWarningConfiguration( + update / unresolvedWarningConfiguration := UnresolvedWarningConfiguration( dependencyPositions.value ), updateFull := (updateTask tag (Tags.Update, Tags.Network)).value, @@ -3122,8 +3125,8 @@ object Classpaths { ConflictWarning(conflictWarning.value, report, log) report }, - evictionWarningOptions in update := evictionWarningOptions.value, - evictionWarningOptions in evicted := EvictionWarningOptions.full, + update / evictionWarningOptions := evictionWarningOptions.value, + evicted / evictionWarningOptions := EvictionWarningOptions.full, evicted := { import ShowLines._ val report = (updateTask tag (Tags.Update, Tags.Network)).value @@ -3151,7 +3154,7 @@ object Classpaths { }, dependencyResolution := dependencyResolutionTask.value, csrConfiguration := LMCoursier.updateClassifierConfigurationTask.value, - updateClassifiers in TaskGlobal := LibraryManagement.updateClassifiersTask.value, + TaskGlobal / updateClassifiers := LibraryManagement.updateClassifiersTask.value, ) ) ++ Seq( csrProject := CoursierInputsTasks.coursierProjectTask.value, @@ -3178,7 +3181,7 @@ object Classpaths { val base = projectDependencies.value ++ libraryDependencies.value val isPlugin = sbtPlugin.value val sbtdeps = - (sbtDependency in pluginCrossBuild).value.withConfigurations(Some(Provided.name)) + (pluginCrossBuild / sbtDependency).value.withConfigurations(Some(Provided.name)) val pluginAdjust = if (isPlugin) sbtdeps +: base else base @@ -3217,7 +3220,7 @@ object Classpaths { val isPlugin = sbtPlugin.value val app = appConfiguration.value val id = app.provider.id - val sv = (sbtVersion in pluginCrossBuild).value + val sv = (pluginCrossBuild / sbtVersion).value val base = ModuleID(id.groupID, "scripted-plugin", sv).withCrossVersion(CrossVersion.binary) if (isPlugin) Seq(base) else Seq() @@ -3250,7 +3253,7 @@ object Classpaths { private[sbt] def defaultProjectID: Initialize[ModuleID] = Def.setting { val p0 = ModuleID(organization.value, moduleName.value, version.value) - .cross(crossVersion in projectID value) + .cross((projectID / crossVersion) value) .artifacts(artifacts.value: _*) val p1 = apiURL.value match { case Some(u) => p0.extra(SbtPomExtraProperties.POM_API_KEY -> u.toExternalForm) @@ -3269,8 +3272,8 @@ object Classpaths { if (sbtPlugin.value) sbtPluginExtra( projectID.value, - (sbtBinaryVersion in pluginCrossBuild).value, - (scalaBinaryVersion in pluginCrossBuild).value + (pluginCrossBuild / sbtBinaryVersion).value, + (pluginCrossBuild / scalaBinaryVersion).value ) else projectID.value } @@ -3297,7 +3300,7 @@ object Classpaths { private[this] def sbtClassifiersGlobalDefaults = Defaults.globalDefaults( Seq( - transitiveClassifiers in updateSbtClassifiers ~= (_.filter(_ != DocClassifier)) + (updateSbtClassifiers / transitiveClassifiers) ~= (_.filter(_ != DocClassifier)) ) ) def sbtClassifiersTasks = @@ -3347,7 +3350,7 @@ object Classpaths { }, dependencyResolution := dependencyResolutionTask.value, csrConfiguration := LMCoursier.updateSbtClassifierConfigurationTask.value, - updateSbtClassifiers in TaskGlobal := (Def.task { + (TaskGlobal / updateSbtClassifiers) := (Def.task { val lm = dependencyResolution.value val s = streams.value val is = ivySbt.value @@ -3363,7 +3366,7 @@ object Classpaths { val docTypes = docArtifactTypes.value val log = s.log val out = is.withIvy(log)(_.getSettings.getDefaultIvyUserDir) - val uwConfig = (unresolvedWarningConfiguration in update).value + val uwConfig = (update / unresolvedWarningConfiguration).value withExcludes(out, mod.classifiers, lock(app)) { excludes => // val noExplicitCheck = ivy.map(_.withCheckExplicit(false)) LibraryManagement.transitiveScratch( @@ -3560,7 +3563,7 @@ object Classpaths { // Use full level when debug is enabled so that ivy logs are shown. import UpdateLogging.{ Default, DownloadOnly, Full } val conf = updateConfiguration.value - val maybeUpdateLevel = (logLevel in update).?.value + val maybeUpdateLevel = (update / logLevel).?.value val conf1 = maybeUpdateLevel.orElse(state0.get(logLevel.key)) match { case Some(Level.Debug) if conf.logging == Default => conf.withLogging(logging = Full) case Some(_) if conf.logging == Default => conf.withLogging(logging = DownloadOnly) @@ -3589,10 +3592,10 @@ object Classpaths { label = label, updateConf, substituteScalaFiles(scalaOrganization.value, _)(providedScalaJars), - skip = (skip in update).value, + skip = (update / skip).value, force = shouldForce, depsUpdated = transitiveUpdate.value.exists(!_.stats.cached), - uwConfig = (unresolvedWarningConfiguration in update).value, + uwConfig = (update / unresolvedWarningConfiguration).value, evictionLevel = evictionErrorLevel.value, versionSchemeOverrides = libraryDependencySchemes.value, assumedEvictionErrorLevel = assumedEvictionErrorLevel.value, @@ -3616,7 +3619,7 @@ object Classpaths { def modulePositions: Map[ModuleID, SourcePosition] = try { val extracted = (Project extract st) - val sk = (libraryDependencies in (GlobalScope in projRef)).scopedKey + val sk = (projRef / Zero / Zero / libraryDependencies).scopedKey val empty = extracted.structure.data set (sk.scope, sk.key, Nil) val settings = extracted.structure.settings filter { s: Setting[_] => (s.key.key == libraryDependencies.key) && @@ -3775,6 +3778,7 @@ object Classpaths { ) } + @nowarn private[sbt] def depMap( projects: Seq[ProjectRef], data: Settings[Scope], @@ -3836,7 +3840,7 @@ object Classpaths { .withOtherResolvers(other) .withModuleConfigurations(moduleConfigurations.value.toVector) .withLock(lock(appConfiguration.value)) - .withChecksums((checksums in update).value.toVector) + .withChecksums((update / checksums).value.toVector) .withResolutionCacheDir(crossTarget.value / "resolution-cache") .withUpdateOptions(updateOptions.value) .withLog(s.log) @@ -3913,7 +3917,7 @@ object Classpaths { ClasspathImpl.getClasspath(key, dep, conf, data) def defaultConfigurationTask(p: ResolvedReference, data: Settings[Scope]): Configuration = - flatten(defaultConfiguration in p get data) getOrElse Configurations.Default + flatten((p / defaultConfiguration) get data) getOrElse Configurations.Default def flatten[T](o: Option[Option[T]]): Option[T] = o flatMap idFun @@ -3939,7 +3943,7 @@ object Classpaths { Nil def addUnmanagedLibrary: Seq[Setting[_]] = - Seq(unmanagedJars in Compile ++= unmanagedScalaLibrary.value) + Seq((Compile / unmanagedJars) ++= unmanagedScalaLibrary.value) def unmanagedScalaLibrary: Initialize[Task[Seq[File]]] = Def.taskDyn { if (autoScalaLibrary.value && scalaHome.value.isDefined) @@ -4143,7 +4147,7 @@ object Classpaths { def shellPromptFromState: State => String = shellPromptFromState(ITerminal.console.isColorEnabled) def shellPromptFromState(isColorEnabled: Boolean): State => String = { s: State => val extracted = Project.extract(s) - (name in extracted.currentRef).get(extracted.structure.data) match { + (extracted.currentRef / name).get(extracted.structure.data) match { case Some(name) => s"sbt:$name" + Def.withColor(s"> ", Option(scala.Console.CYAN), isColorEnabled) case _ => "> " @@ -4167,7 +4171,7 @@ trait BuildExtra extends BuildCommon with DefExtra { val add = (s: State) => BasicCommands.addAlias(s, name, value) val remove = (s: State) => BasicCommands.removeAlias(s, name) def compose(setting: SettingKey[State => State], f: State => State) = - setting in GlobalScope ~= (_ compose f) + (GlobalScope / setting) ~= (_ compose f) Seq(compose(onLoad, add), compose(onUnload, remove)) } @@ -4208,7 +4212,7 @@ trait BuildExtra extends BuildCommon with DefExtra { */ def addSbtPlugin(dependency: ModuleID, sbtVersion: String): Setting[Seq[ModuleID]] = libraryDependencies += { - val scalaV = (scalaBinaryVersion in update).value + val scalaV = (update / scalaBinaryVersion).value sbtPluginExtra(dependency, sbtVersion, scalaV) } @@ -4218,8 +4222,8 @@ trait BuildExtra extends BuildCommon with DefExtra { */ def addSbtPlugin(dependency: ModuleID): Setting[Seq[ModuleID]] = libraryDependencies += { - val sbtV = (sbtBinaryVersion in pluginCrossBuild).value - val scalaV = (scalaBinaryVersion in update).value + val sbtV = (pluginCrossBuild / sbtBinaryVersion).value + val scalaV = (update / scalaBinaryVersion).value sbtPluginExtra(dependency, sbtV, scalaV) } @@ -4331,8 +4335,8 @@ trait BuildExtra extends BuildCommon with DefExtra { ): Initialize[InputTask[Unit]] = Def.inputTask { import Def._ - val r = (runner in (config, run)).value - val cp = (fullClasspath in config).value + val r = (config / run / runner).value + val cp = (config / fullClasspath).value val args = spaceDelimited().parsed r.run(mainClass, data(cp), baseArguments ++ args, streams.value.log).get } @@ -4343,14 +4347,15 @@ trait BuildExtra extends BuildCommon with DefExtra { arguments: String* ): Initialize[Task[Unit]] = Def.task { - val cp = (fullClasspath in config).value - val r = (runner in (config, run)).value + val cp = (config / fullClasspath).value + val r = (config / run / runner).value val s = streams.value r.run(mainClass, data(cp), arguments, s.log).get } // public API /** Returns a vector of settings that create custom run input task. */ + @nowarn def fullRunInputTask( scoped: InputKey[Unit], config: Configuration, @@ -4370,7 +4375,7 @@ trait BuildExtra extends BuildCommon with DefExtra { initScoped( scoped.scopedKey, ClassLoaders.runner mapReferenced Project.mapScope(s => s.in(config)) - ).zipWith(Def.task { ((fullClasspath in config).value, streams.value, result.value) }) { + ).zipWith(Def.task { ((config / fullClasspath).value, streams.value, result.value) }) { (rTask, t) => (t, rTask) map { case ((cp, s, args), r) => @@ -4378,11 +4383,12 @@ trait BuildExtra extends BuildCommon with DefExtra { } } }.evaluated - ) ++ inTask(scoped)(forkOptions in config := forkOptionsTask.value) + ) ++ inTask(scoped)((config / forkOptions) := forkOptionsTask.value) } // public API /** Returns a vector of settings that create custom run task. */ + @nowarn def fullRunTask( scoped: TaskKey[Unit], config: Configuration, @@ -4393,7 +4399,7 @@ trait BuildExtra extends BuildCommon with DefExtra { scoped := initScoped( scoped.scopedKey, ClassLoaders.runner mapReferenced Project.mapScope(s => s.in(config)) - ).zipWith(Def.task { ((fullClasspath in config).value, streams.value) }) { + ).zipWith(Def.task { ((config / fullClasspath).value, streams.value) }) { case (rTask, t) => (t, rTask) map { case ((cp, s), r) => @@ -4401,7 +4407,7 @@ trait BuildExtra extends BuildCommon with DefExtra { } } .value - ) ++ inTask(scoped)(forkOptions in config := forkOptionsTask.value) + ) ++ inTask(scoped)((config / forkOptions) := forkOptionsTask.value) def initScoped[T](sk: ScopedKey[_], i: Initialize[T]): Initialize[T] = initScope(fillTaskAxis(sk.scope, sk.key), i) diff --git a/main/src/main/scala/sbt/EvaluateTask.scala b/main/src/main/scala/sbt/EvaluateTask.scala index 3005fc639..6a793ba10 100644 --- a/main/src/main/scala/sbt/EvaluateTask.scala +++ b/main/src/main/scala/sbt/EvaluateTask.scala @@ -14,6 +14,7 @@ import sbt.Def.{ ScopedKey, Setting, dummyState } import sbt.Keys.{ TaskProgress => _, name => _, _ } import sbt.Project.richInitializeTask import sbt.Scope.Global +import sbt.SlashSyntax0._ import sbt.internal.Aggregation.KeyValue import sbt.internal.TaskName._ import sbt.internal._ @@ -269,11 +270,11 @@ object EvaluateTask { } // TODO - Should this pull from Global or from the project itself? private[sbt] def forcegc(extracted: Extracted, structure: BuildStructure): Boolean = - getSetting(Keys.forcegc in Global, GCUtil.defaultForceGarbageCollection, extracted, structure) + getSetting((Global / Keys.forcegc), GCUtil.defaultForceGarbageCollection, extracted, structure) // TODO - Should this pull from Global or from the project itself? private[sbt] def minForcegcInterval(extracted: Extracted, structure: BuildStructure): Duration = getSetting( - Keys.minForcegcInterval in Global, + (Global / Keys.minForcegcInterval), GCUtil.defaultMinForcegcInterval, extracted, structure @@ -285,12 +286,12 @@ object EvaluateTask { extracted: Extracted, structure: BuildStructure ): T = - (key in extracted.currentRef).get(structure.data).getOrElse(default) + (extracted.currentRef / key).get(structure.data).getOrElse(default) def injectSettings: Seq[Setting[_]] = Seq( - (state in Global) ::= dummyState, - (streamsManager in Global) ::= Def.dummyStreamsManager, - (executionRoots in Global) ::= dummyRoots, + Global / state ::= dummyState, + Global / streamsManager ::= Def.dummyStreamsManager, + Global / executionRoots ::= dummyRoots, ) @deprecated("Use variant which doesn't take a logger", "1.1.1") @@ -508,7 +509,7 @@ object EvaluateTask { state: State, streams: Streams ): Unit = - for (referenced <- Previous.references in Global get Project.structure(state).data) + for (referenced <- (Global / Previous.references) get Project.structure(state).data) Previous.complete(referenced, results, streams) def applyResults[T]( @@ -589,7 +590,7 @@ object EvaluateTask { // if the return type Seq[Setting[_]] is not explicitly given, scalac hangs val injectStreams: ScopedKey[_] => Seq[Setting[_]] = scoped => if (scoped.key == streams.key) { - Seq(streams in scoped.scope := { + Seq(scoped.scope / streams := { (streamsManager map { mgr => val stream = mgr(scoped) stream.open() diff --git a/main/src/main/scala/sbt/Extracted.scala b/main/src/main/scala/sbt/Extracted.scala index 8be1a1685..cec5beb4c 100644 --- a/main/src/main/scala/sbt/Extracted.scala +++ b/main/src/main/scala/sbt/Extracted.scala @@ -15,6 +15,7 @@ import sbt.internal.util.AttributeKey import sbt.util.Show import std.Transform.DummyTaskMap import sbt.EvaluateTask.extractedTaskConfig +import scala.annotation.nowarn final case class Extracted( structure: BuildStructure, @@ -43,6 +44,7 @@ final case class Extracted( def getOpt[T](key: TaskKey[T]): Option[Task[T]] = structure.data.get(inCurrent(key.scope), key.key) + @nowarn private[this] def inCurrent[T](scope: Scope): Scope = if (scope.project == This) scope in currentRef else scope @@ -110,6 +112,7 @@ final case class Extracted( )(showKey) } + @nowarn private[this] def resolve[K <: Scoped.ScopingSetting[K] with Scoped](key: K): K = key in Scope.resolveScope(GlobalScope, currentRef.build, rootProject)(key.scope) diff --git a/main/src/main/scala/sbt/PluginCross.scala b/main/src/main/scala/sbt/PluginCross.scala index eeaa07abc..679a344dc 100644 --- a/main/src/main/scala/sbt/PluginCross.scala +++ b/main/src/main/scala/sbt/PluginCross.scala @@ -12,16 +12,19 @@ import DefaultParsers._ import sbt.Keys._ import Scope.GlobalScope import Def.ScopedKey +import sbt.SlashSyntax0._ import sbt.internal.Load import sbt.internal.CommandStrings._ import Cross.{ spacedFirst, requireSession } import sbt.librarymanagement.VersionNumber import Project.inScope +import scala.annotation.nowarn /** * Module responsible for plugin cross building. */ private[sbt] object PluginCross { + @nowarn lazy val pluginSwitch: Command = { def switchParser(state: State): Parser[(String, String)] = { lazy val switchArgs = token(NotSpace.examples()) ~ (token( @@ -68,14 +71,14 @@ private[sbt] object PluginCross { def crossVersions(state: State): List[String] = { val x = Project.extract(state) import x._ - ((crossSbtVersions in currentRef) get structure.data getOrElse Nil).toList + ((currentRef / crossSbtVersions) get structure.data getOrElse Nil).toList } Command.arb(requireSession(crossParser), pluginCrossHelp) { case (state, command) => val x = Project.extract(state) import x._ val versions = crossVersions(state) - val current = (sbtVersion in pluginCrossBuild) + val current = (pluginCrossBuild / sbtVersion) .get(structure.data) .map(PluginSwitchCommand + " " + _) .toList @@ -86,7 +89,7 @@ private[sbt] object PluginCross { def scalaVersionSetting: Def.Initialize[String] = Def.setting { val scalaV = scalaVersion.value - val sv = (sbtBinaryVersion in pluginCrossBuild).value + val sv = (pluginCrossBuild / sbtBinaryVersion).value val isPlugin = sbtPlugin.value if (isPlugin) scalaVersionFromSbtBinaryVersion(sv) else scalaV diff --git a/main/src/main/scala/sbt/Project.scala b/main/src/main/scala/sbt/Project.scala index 7ad01fd84..5fd822f01 100755 --- a/main/src/main/scala/sbt/Project.scala +++ b/main/src/main/scala/sbt/Project.scala @@ -36,6 +36,7 @@ import Keys.{ windowsServerSecurityLevel, } import Scope.{ Global, ThisScope } +import sbt.SlashSyntax0._ import Def.{ Flattened, Initialize, ScopedKey, Setting } import sbt.internal.{ Load, @@ -504,7 +505,7 @@ object Project extends ProjectExtra { def orIdentity[T](opt: Option[T => T]): T => T = opt getOrElse idFun def getHook[T](key: SettingKey[T => T], data: Settings[Scope]): T => T = - orIdentity(key in Global get data) + orIdentity((Global / key) get data) def getHooks(data: Settings[Scope]): (State => State, State => State) = (getHook(Keys.onLoad, data), getHook(Keys.onUnload, data)) @@ -515,16 +516,16 @@ object Project extends ProjectExtra { val structure = Project.structure(s) val ref = Project.current(s) Load.getProject(structure.units, ref.build, ref.project) - val msg = Keys.onLoadMessage in ref get structure.data getOrElse "" + val msg = (ref / Keys.onLoadMessage) get structure.data getOrElse "" if (!msg.isEmpty) s.log.info(msg) - def get[T](k: SettingKey[T]): Option[T] = k in ref get structure.data - def commandsIn(axis: ResolvedReference) = commands in axis get structure.data toList + def get[T](k: SettingKey[T]): Option[T] = (ref / k) get structure.data + def commandsIn(axis: ResolvedReference) = (axis / commands) get structure.data toList - val allCommands = commandsIn(ref) ++ commandsIn(BuildRef(ref.build)) ++ (commands in Global get structure.data toList) + val allCommands = commandsIn(ref) ++ commandsIn(BuildRef(ref.build)) ++ ((Global / commands) get structure.data toList) val history = get(historyPath) flatMap idFun val prompt = get(shellPrompt) val newPrompt = get(colorShellPrompt) - val trs = (templateResolverInfos in Global get structure.data).toList.flatten + val trs = ((Global / templateResolverInfos) get structure.data).toList.flatten val startSvr: Option[Boolean] = get(autoStartServer) val host: Option[String] = get(serverHost) val port: Option[Int] = get(serverPort) @@ -532,8 +533,8 @@ object Project extends ProjectExtra { val timeout: Option[Option[FiniteDuration]] = get(serverIdleTimeout) val authentication: Option[Set[ServerAuthentication]] = get(serverAuthentication) val connectionType: Option[ConnectionType] = get(serverConnectionType) - val srvLogLevel: Option[Level.Value] = (logLevel in (ref, serverLog)).get(structure.data) - val hs: Option[Seq[ServerHandler]] = get(fullServerHandlers in ThisBuild) + val srvLogLevel: Option[Level.Value] = (ref / serverLog / logLevel).get(structure.data) + val hs: Option[Seq[ServerHandler]] = get(ThisBuild / fullServerHandlers) val commandDefs = allCommands.distinct.flatten[Command].map(_ tag (projectCommand, true)) val newDefinedCommands = commandDefs ++ BasicCommands.removeTagged( s.definedCommands, diff --git a/main/src/main/scala/sbt/ScriptedPlugin.scala b/main/src/main/scala/sbt/ScriptedPlugin.scala index 584786bbc..b250dee46 100644 --- a/main/src/main/scala/sbt/ScriptedPlugin.scala +++ b/main/src/main/scala/sbt/ScriptedPlugin.scala @@ -14,6 +14,7 @@ import sbt.Def._ import sbt.Keys._ import sbt.nio.Keys._ import sbt.Project._ +import sbt.SlashSyntax0._ import sbt.internal.inc.ModuleUtilities import sbt.internal.inc.classpath.ClasspathUtil import sbt.internal.librarymanagement.cross.CrossVersionUtil @@ -60,7 +61,7 @@ object ScriptedPlugin extends AutoPlugin { override lazy val projectSettings: Seq[Setting[_]] = Seq( ivyConfigurations ++= Seq(ScriptedConf, ScriptedLaunchConf), - scriptedSbt := (sbtVersion in pluginCrossBuild).value, + scriptedSbt := (pluginCrossBuild / sbtVersion).value, sbtLauncher := getJars(ScriptedLaunchConf).map(_.get.head).value, sbtTestDirectory := sourceDirectory.value / "sbt-test", libraryDependencies ++= (CrossVersion.partialVersion(scriptedSbt.value) match { @@ -92,12 +93,12 @@ object ScriptedPlugin extends AutoPlugin { scriptedRun := scriptedRunTask.value, scriptedDependencies := { def use[A](@deprecated("unused", "") x: A*): Unit = () // avoid unused warnings - val analysis = (Keys.compile in Test).value + val analysis = (Test / Keys.compile).value val pub = (publishLocal).value use(analysis, pub) }, scripted := scriptedTask.evaluated, - watchTriggers in scripted += Glob(sbtTestDirectory.value, RecursiveGlob) + scripted / watchTriggers += Glob(sbtTestDirectory.value, RecursiveGlob) ) private[sbt] def scriptedTestsTask: Initialize[Task[AnyRef]] = diff --git a/main/src/main/scala/sbt/TemplateCommandUtil.scala b/main/src/main/scala/sbt/TemplateCommandUtil.scala index f9ee797ca..34b1181ef 100644 --- a/main/src/main/scala/sbt/TemplateCommandUtil.scala +++ b/main/src/main/scala/sbt/TemplateCommandUtil.scala @@ -12,6 +12,7 @@ import java.nio.file.Path import java.io.File import sbt.BasicCommandStrings.TerminateAction +import sbt.SlashSyntax0._ import sbt.io._, syntax._ import sbt.util._ import sbt.internal.util.complete.{ DefaultParsers, Parser }, DefaultParsers._ @@ -48,7 +49,7 @@ private[sbt] object TemplateCommandUtil { val log = state.globalLogging.full val extracted = (Project extract state) val (s2, ivyConf) = extracted.runTask(Keys.ivyConfiguration, state) - val scalaModuleInfo = extracted.get(Keys.scalaModuleInfo in Keys.updateSbtClassifiers) + val scalaModuleInfo = extracted.get(Keys.updateSbtClassifiers / Keys.scalaModuleInfo) val arguments = inputArg.toList ++ (state.remainingCommands match { case exec :: Nil if exec.commandLine == "shell" => Nil diff --git a/main/src/main/scala/sbt/coursierint/CoursierArtifactsTasks.scala b/main/src/main/scala/sbt/coursierint/CoursierArtifactsTasks.scala index 721665e31..84f6776fb 100644 --- a/main/src/main/scala/sbt/coursierint/CoursierArtifactsTasks.scala +++ b/main/src/main/scala/sbt/coursierint/CoursierArtifactsTasks.scala @@ -17,6 +17,7 @@ import lmcoursier.definitions.{ } import sbt.librarymanagement._ import sbt.Keys._ +import sbt.SlashSyntax0._ object CoursierArtifactsTasks { def coursierPublicationsTask( @@ -48,18 +49,12 @@ object CoursierArtifactsTasks { for ((config, targetConfig) <- configsMap) yield { val publish = getOpt( - publishArtifact - .in(projectRef) - .in(packageBin) - .in(config) + projectRef / config / packageBin / publishArtifact ).getOrElse(false) if (publish) getOpt( - artifact - .in(projectRef) - .in(packageBin) - .in(config) + projectRef / config / packageBin / artifact ).map(targetConfig -> _) else None @@ -69,18 +64,12 @@ object CoursierArtifactsTasks { for ((config, targetConfig) <- configsMap) yield { val publish = getOpt( - publishArtifact - .in(projectRef) - .in(packageSrc) - .in(config) + projectRef / config / packageSrc / publishArtifact ).getOrElse(false) if (publish) getOpt( - artifact - .in(projectRef) - .in(packageSrc) - .in(config) + projectRef / config / packageSrc / artifact ).map(sourcesConfigOpt.getOrElse(targetConfig) -> _) else None @@ -91,18 +80,12 @@ object CoursierArtifactsTasks { val publish = getOpt( - publishArtifact - .in(projectRef) - .in(packageDoc) - .in(config) + projectRef / config / packageDoc / publishArtifact ).getOrElse(false) if (publish) getOpt( - artifact - .in(projectRef) - .in(packageDoc) - .in(config) + projectRef / config / packageDoc / artifact ).map(docsConfigOpt.getOrElse(targetConfig) -> _) else None @@ -134,8 +117,7 @@ object CoursierArtifactsTasks { // No obvious way of getting the corresponding publishArtifact value for the ones // only here, it seems. val extraSbtArtifacts = getOpt( - sbt.Keys.artifacts - .in(projectRef) + projectRef / sbt.Keys.artifacts ).getOrElse(Nil) .filterNot(stdArtifactsSet) diff --git a/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala b/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala index c22249c6b..8bbdb8969 100644 --- a/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala +++ b/main/src/main/scala/sbt/coursierint/CoursierRepositoriesTasks.scala @@ -11,6 +11,7 @@ package coursierint import sbt.librarymanagement._ import sbt.Keys._ import sbt.ScopeFilter.Make._ +import sbt.SlashSyntax0._ object CoursierRepositoriesTasks { private object CResolvers { @@ -108,7 +109,7 @@ object CoursierRepositoriesTasks { .bootRepositories(appConfiguration.value) .toSeq .flatten ++ // required because of the hack above it seems - externalResolvers.in(updateSbtClassifiers).value + (updateSbtClassifiers / externalResolvers).value val pluginIvySnapshotsFound = resolvers.exists { case repo: URLRepository => diff --git a/main/src/main/scala/sbt/coursierint/LMCoursier.scala b/main/src/main/scala/sbt/coursierint/LMCoursier.scala index 7bd0b6302..7ea805ce4 100644 --- a/main/src/main/scala/sbt/coursierint/LMCoursier.scala +++ b/main/src/main/scala/sbt/coursierint/LMCoursier.scala @@ -315,8 +315,8 @@ object LMCoursier { } } import scala.collection.JavaConverters._ - (Keys.credentials in ThisBuild).value foreach registerCredentials - (Keys.credentials in LocalRootProject).value foreach registerCredentials + (ThisBuild / Keys.credentials).value foreach registerCredentials + (LocalRootProject / Keys.credentials).value foreach registerCredentials Keys.credentials.value foreach registerCredentials credentialRegistry.values.asScala.toVector } diff --git a/main/src/main/scala/sbt/internal/Aggregation.scala b/main/src/main/scala/sbt/internal/Aggregation.scala index 62b6fa7d9..b17413652 100644 --- a/main/src/main/scala/sbt/internal/Aggregation.scala +++ b/main/src/main/scala/sbt/internal/Aggregation.scala @@ -12,11 +12,13 @@ import java.text.DateFormat import sbt.Def.ScopedKey import sbt.Keys.{ showSuccess, showTiming, timingFormat } +import sbt.SlashSyntax0._ import sbt.internal.util.complete.Parser import sbt.internal.util.complete.Parser.{ failure, seq, success } import sbt.internal.util._ import sbt.std.Transform.DummyTaskMap import sbt.util.{ Logger, Show } +import scala.annotation.nowarn sealed trait Aggregation object Aggregation { @@ -127,7 +129,8 @@ object Aggregation { ): Unit = { import extracted._ def get(key: SettingKey[Boolean]): Boolean = - key in currentRef get structure.data getOrElse true + (currentRef / key).get(structure.data) getOrElse true + if (get(showSuccess)) { if (get(showTiming)) { val msg = timingString(start, stop, structure.data, currentRef) @@ -143,7 +146,7 @@ object Aggregation { data: Settings[Scope], currentRef: ProjectRef, ): String = { - val format = timingFormat in currentRef get data getOrElse defaultFormat + val format = (currentRef / timingFormat).get(data) getOrElse defaultFormat timing(format, startTime, endTime) } @@ -287,6 +290,7 @@ object Aggregation { ScopedKey(resolved, key.key) } + @nowarn def aggregationEnabled(key: ScopedKey[_], data: Settings[Scope]): Boolean = Keys.aggregate in Scope.fillTaskAxis(key.scope, key.key) get data getOrElse true private[sbt] val suppressShow = diff --git a/main/src/main/scala/sbt/internal/BuildStructure.scala b/main/src/main/scala/sbt/internal/BuildStructure.scala index 3cf76319a..4c10fba22 100644 --- a/main/src/main/scala/sbt/internal/BuildStructure.scala +++ b/main/src/main/scala/sbt/internal/BuildStructure.scala @@ -20,6 +20,7 @@ import sbt.io.syntax._ import sbt.internal.util.{ AttributeEntry, AttributeKey, AttributeMap, Attributed, Settings } import sbt.internal.util.Attributed.data import sbt.util.Logger +import scala.annotation.nowarn final class BuildStructure( val units: Map[URI, LoadedBuildUnit], @@ -396,6 +397,8 @@ object BuildStreams { def refTarget(ref: ResolvedReference, fallbackBase: File, data: Settings[Scope]): File = refTarget(GlobalScope.copy(project = Select(ref)), fallbackBase, data) + + @nowarn def refTarget(scope: Scope, fallbackBase: File, data: Settings[Scope]): File = (Keys.target in scope get data getOrElse outputDirectory(fallbackBase)) / StreamsDirectory } diff --git a/main/src/main/scala/sbt/internal/ClassLoaders.scala b/main/src/main/scala/sbt/internal/ClassLoaders.scala index 5590abc12..1c5df8aa0 100644 --- a/main/src/main/scala/sbt/internal/ClassLoaders.scala +++ b/main/src/main/scala/sbt/internal/ClassLoaders.scala @@ -14,6 +14,7 @@ import java.nio.file.Path import sbt.ClassLoaderLayeringStrategy._ import sbt.Keys._ +import sbt.SlashSyntax0._ import sbt.internal.classpath.ClassLoaderCache import sbt.internal.inc.ScalaInstance import sbt.internal.inc.classpath.ClasspathUtil @@ -36,7 +37,7 @@ private[sbt] object ClassLoaders { private[sbt] def testTask: Def.Initialize[Task[ClassLoader]] = Def.task { val si = scalaInstance.value val cp = fullClasspath.value.map(_.data) - val dependencyStamps = modifiedTimes((outputFileStamps in dependencyClasspathFiles).value).toMap + val dependencyStamps = modifiedTimes((dependencyClasspathFiles / outputFileStamps).value).toMap def getLm(f: File): Long = dependencyStamps.getOrElse(f, IO.getModifiedTimeOrZero(f)) val rawCP = cp.map(f => f -> getLm(f)) val fullCP = @@ -75,13 +76,13 @@ private[sbt] object ClassLoaders { if (options.nonEmpty) { val mask = ScopeMask(project = false) val showJavaOptions = Scope.displayMasked( - (javaOptions in resolvedScope).scopedKey.scope, - (javaOptions in resolvedScope).key.label, + (resolvedScope / javaOptions).scopedKey.scope, + (resolvedScope / javaOptions).key.label, mask ) val showFork = Scope.displayMasked( - (fork in resolvedScope).scopedKey.scope, - (fork in resolvedScope).key.label, + (resolvedScope / fork).scopedKey.scope, + (resolvedScope / fork).key.label, mask ) s.log.warn(s"$showJavaOptions will be ignored, $showFork is set to false") diff --git a/main/src/main/scala/sbt/internal/ClasspathImpl.scala b/main/src/main/scala/sbt/internal/ClasspathImpl.scala index 30cf1da0e..43f35dbd8 100644 --- a/main/src/main/scala/sbt/internal/ClasspathImpl.scala +++ b/main/src/main/scala/sbt/internal/ClasspathImpl.scala @@ -52,7 +52,7 @@ private[sbt] object ClasspathImpl { def trackedExportedProducts(track: TrackLevel): Initialize[Task[Classpath]] = Def.task { val _ = (packageBin / dynamicDependency).value - val art = (artifact in packageBin).value + val art = (packageBin / artifact).value val module = projectID.value val config = configuration.value for { (f, analysis) <- trackedExportedProductsImplTask(track).value } yield APIMappings @@ -65,7 +65,7 @@ private[sbt] object ClasspathImpl { def trackedExportedJarProducts(track: TrackLevel): Initialize[Task[Classpath]] = Def.task { val _ = (packageBin / dynamicDependency).value - val art = (artifact in packageBin).value + val art = (packageBin / artifact).value val module = projectID.value val config = configuration.value for { (f, analysis) <- trackedJarProductsImplTask(track).value } yield APIMappings @@ -114,7 +114,7 @@ private[sbt] object ClasspathImpl { track: TrackLevel ): Initialize[Task[Seq[(File, CompileAnalysis)]]] = Def.taskDyn { - val jar = (artifactPath in packageBin).value + val jar = (packageBin / artifactPath).value TrackLevel.intersection(track, exportToInternal.value) match { case TrackLevel.TrackAlways => Def.task { diff --git a/main/src/main/scala/sbt/internal/Clean.scala b/main/src/main/scala/sbt/internal/Clean.scala index 0f314fd60..0d980c50e 100644 --- a/main/src/main/scala/sbt/internal/Clean.scala +++ b/main/src/main/scala/sbt/internal/Clean.scala @@ -14,12 +14,14 @@ import java.nio.file.{ DirectoryNotEmptyException, Files, Path } import sbt.Def._ import sbt.Keys._ import sbt.Project.richInitializeTask +import sbt.SlashSyntax0._ import sbt.io.syntax._ import sbt.nio.Keys._ import sbt.nio.file._ import sbt.nio.file.syntax._ import sbt.util.Level import sjsonnew.JsonFormat +import scala.annotation.nowarn private[sbt] object Clean { @@ -51,16 +53,16 @@ private[sbt] object Clean { } private[this] def cleanFilter(scope: Scope): Def.Initialize[Task[Path => Boolean]] = Def.task { - val excludes = (cleanKeepFiles in scope).value.map { + val excludes = (scope / cleanKeepFiles).value.map { // This mimics the legacy behavior of cleanFilesTask case f if f.isDirectory => Glob(f, AnyPath) case f => f.toGlob - } ++ (cleanKeepGlobs in scope).value + } ++ (scope / cleanKeepGlobs).value p: Path => excludes.exists(_.matches(p)) } private[this] def cleanDelete(scope: Scope): Def.Initialize[Task[Path => Unit]] = Def.task { // Don't use a regular logger because the logger actually writes to the target directory. - val debug = (logLevel in scope).?.value.orElse(state.value.get(logLevel.key)) match { + val debug = (scope / logLevel).?.value.orElse(state.value.get(logLevel.key)) match { case Some(Level.Debug) => (string: String) => println(s"[debug] $string") case _ => @@ -83,15 +85,15 @@ private[sbt] object Clean { Def.taskDyn { val state = Keys.state.value val extracted = Project.extract(state) - val view = (fileTreeView in scope).value + val view = (scope / fileTreeView).value val manager = streamsManager.value Def.task { val excludeFilter = cleanFilter(scope).value val delete = cleanDelete(scope).value - val targetDir = (target in scope).?.value.map(_.toPath) + val targetDir = (scope / target).?.value.map(_.toPath) targetDir.filter(_ => full).foreach(deleteContents(_, excludeFilter, view, delete)) - (cleanFiles in scope).?.value.getOrElse(Nil).foreach { f => + (scope / cleanFiles).?.value.getOrElse(Nil).foreach { f => deleteContents(f.toPath, excludeFilter, view, delete) } @@ -105,7 +107,7 @@ private[sbt] object Clean { } val streamsGlobs = (streamsKey.toSeq ++ stampsKey).map(k => manager(k).cacheDirectory.toGlob / **) - ((fileOutputs in scope).value.filter(g => targetDir.fold(true)(g.base.startsWith)) ++ streamsGlobs) + ((scope / fileOutputs).value.filter(g => targetDir.fold(true)(g.base.startsWith)) ++ streamsGlobs) .foreach { g => val filter: Path => Boolean = { path => !g.matches(path) || excludeFilter(path) @@ -127,18 +129,20 @@ private[sbt] object Clean { private[this] implicit class ToSeqPathOps[T](val t: T) extends AnyVal { def toSeqPath(implicit toSeqPath: ToSeqPath[T]): Seq[Path] = toSeqPath(t) } + + @nowarn private[sbt] def cleanFileOutputTask[T: JsonFormat: ToSeqPath]( taskKey: TaskKey[T] ): Def.Initialize[Task[Unit]] = Def.taskDyn { val scope = taskKey.scope in taskKey.key Def.task { - val targetDir = (target in scope).value.toPath + val targetDir = (scope / target).value.toPath val filter = cleanFilter(scope).value // We do not want to inadvertently delete files that are not in the target directory. val excludeFilter: Path => Boolean = path => !path.startsWith(targetDir) || filter(path) val delete = cleanDelete(scope).value - val st = streams.in(scope).value + val st = (scope / streams).value taskKey.previous.foreach(_.toSeqPath.foreach(p => if (!excludeFilter(p)) delete(p))) delete(st.cacheDirectory.toPath / Previous.DependencyDirectory) } diff --git a/main/src/main/scala/sbt/internal/ConsoleProject.scala b/main/src/main/scala/sbt/internal/ConsoleProject.scala index f62f0d5a6..b2776b754 100644 --- a/main/src/main/scala/sbt/internal/ConsoleProject.scala +++ b/main/src/main/scala/sbt/internal/ConsoleProject.scala @@ -8,6 +8,7 @@ package sbt package internal +import sbt.SlashSyntax0._ import sbt.internal.classpath.AlternativeZincUtil import sbt.internal.inc.{ ScalaInstance, ZincLmUtil } import sbt.internal.util.Terminal @@ -25,7 +26,7 @@ object ConsoleProject { val (state1, dependencyResolution) = extracted.runTask(Keys.dependencyResolution, state) val (_, scalaCompilerBridgeBinaryJar) = - extracted.runTask(Keys.scalaCompilerBridgeBinaryJar.in(Keys.consoleProject), state1) + extracted.runTask(Keys.consoleProject / Keys.scalaCompilerBridgeBinaryJar, state1) val scalaInstance = { val scalaProvider = state.configuration.provider.scalaProvider ScalaInstance(scalaProvider.version, scalaProvider) @@ -50,8 +51,7 @@ object ConsoleProject { componentProvider = app.provider.components, secondaryCacheDir = Option(zincDir), dependencyResolution = dependencyResolution, - compilerBridgeSource = - extracted.get(Keys.scalaCompilerBridgeSource.in(Keys.consoleProject)), + compilerBridgeSource = extracted.get(Keys.consoleProject / Keys.scalaCompilerBridgeSource), scalaJarsTarget = zincDir, classLoaderCache = state1.get(BasicKeys.classLoaderCache), log = log diff --git a/main/src/main/scala/sbt/internal/Continuous.scala b/main/src/main/scala/sbt/internal/Continuous.scala index 92801f32b..c206cb71e 100644 --- a/main/src/main/scala/sbt/internal/Continuous.scala +++ b/main/src/main/scala/sbt/internal/Continuous.scala @@ -22,6 +22,7 @@ import java.util.concurrent.atomic.{ AtomicBoolean, AtomicInteger } import sbt.BasicCommandStrings._ import sbt.Def._ import sbt.Keys._ +import sbt.SlashSyntax0._ import sbt.internal.Continuous.{ ContinuousState, FileStampRepository } import sbt.internal.LabeledFunctions._ import sbt.internal.io.WatchState @@ -379,18 +380,18 @@ private[sbt] object Continuous extends DeprecatedContinuous { (settings.inputOptionsMessage, parser, alt) case _ => val options = - extracted.getOpt(watchInputOptions in ThisBuild).getOrElse(Watch.defaultInputOptions) + extracted.getOpt((ThisBuild / watchInputOptions)).getOrElse(Watch.defaultInputOptions) val message = extracted - .getOpt(watchInputOptionsMessage in ThisBuild) + .getOpt((ThisBuild / watchInputOptionsMessage)) .getOrElse(Watch.defaultInputOptionsMessage(options)) val parser = extracted - .getOpt(watchInputParser in ThisBuild) + .getOpt((ThisBuild / watchInputParser)) .getOrElse(Watch.defaultInputParser(options)) val alt = extracted - .getOpt(watchInputStream in ThisBuild) + .getOpt((ThisBuild / watchInputStream)) .map { _ => - (watchInputStream in ThisBuild) -> extracted - .getOpt(watchInputHandler in ThisBuild) + (ThisBuild / watchInputStream) -> extracted + .getOpt((ThisBuild / watchInputHandler)) .getOrElse(defaultInputHandler(parser)) } (message, parser, alt) @@ -425,7 +426,7 @@ private[sbt] object Continuous extends DeprecatedContinuous { // Print the default watch message if there are multiple tasks if (configs.size > 1) { val onStartWatch = - extracted.getOpt(watchStartMessage in project).getOrElse(Watch.defaultStartWatch) + extracted.getOpt((project / watchStartMessage)).getOrElse(Watch.defaultStartWatch) onStartWatch(count, project, commands).foreach(logger.info(_)) } res @@ -442,7 +443,7 @@ private[sbt] object Continuous extends DeprecatedContinuous { )(implicit extracted: Extracted): (Int => Option[(Watch.Event, Watch.Action)], () => Unit) = { val trackMetaBuild = configs.forall(_.watchSettings.trackMetaBuild) val buildGlobs = - if (trackMetaBuild) extracted.getOpt(fileInputs in checkBuildSources).getOrElse(Nil) + if (trackMetaBuild) extracted.getOpt((checkBuildSources / fileInputs)).getOrElse(Nil) else Nil val retentionPeriod = configs.map(_.watchSettings.antiEntropyRetentionPeriod).max @@ -1041,9 +1042,9 @@ private[sbt] object Continuous extends DeprecatedContinuous { lazy val taskScope = Project.fillTaskAxis(scopedKey).scope scopedKey.scope match { case scope if scope.task.toOption.isDefined => - extracted.getOpt(settingKey in scope) orElse extracted.getOpt(settingKey in taskScope) + extracted.getOpt((scope / settingKey)) orElse extracted.getOpt((taskScope / settingKey)) case scope => - extracted.getOpt(settingKey in taskScope) orElse extracted.getOpt(settingKey in scope) + extracted.getOpt((taskScope / settingKey)) orElse extracted.getOpt((scope / settingKey)) } } @@ -1063,12 +1064,12 @@ private[sbt] object Continuous extends DeprecatedContinuous { lazy val taskScope = Project.fillTaskAxis(scopedKey).scope scopedKey.scope match { case scope if scope.task.toOption.isDefined => - if (extracted.getOpt(taskKey in scope).isDefined) Some(taskKey in scope) - else if (extracted.getOpt(taskKey in taskScope).isDefined) Some(taskKey in taskScope) + if (extracted.getOpt((scope / taskKey)).isDefined) Some((scope / taskKey)) + else if (extracted.getOpt((taskScope / taskKey)).isDefined) Some((taskScope / taskKey)) else None case scope => - if (extracted.getOpt(taskKey in taskScope).isDefined) Some(taskKey in taskScope) - else if (extracted.getOpt(taskKey in scope).isDefined) Some(taskKey in scope) + if (extracted.getOpt((taskScope / taskKey)).isDefined) Some((taskScope / taskKey)) + else if (extracted.getOpt((scope / taskKey)).isDefined) Some((scope / taskKey)) else None } } diff --git a/main/src/main/scala/sbt/internal/CrossJava.scala b/main/src/main/scala/sbt/internal/CrossJava.scala index 4a5801198..4764fc829 100644 --- a/main/src/main/scala/sbt/internal/CrossJava.scala +++ b/main/src/main/scala/sbt/internal/CrossJava.scala @@ -16,6 +16,7 @@ import sbt.io.Path import sbt.io.syntax._ import sbt.Cross._ import sbt.Def.{ ScopedKey, Setting } +import sbt.SlashSyntax0._ import sbt.internal.util.complete.DefaultParsers._ import sbt.internal.util.AttributeKey import sbt.internal.util.complete.{ DefaultParsers, Parser } @@ -169,7 +170,7 @@ private[sbt] object CrossJava { proj: ResolvedReference ): Map[String, File] = { import extracted._ - (Keys.fullJavaHomes in proj get structure.data).get + ((proj / Keys.fullJavaHomes) get structure.data).get } private def getJavaHomesTyped( @@ -185,14 +186,14 @@ private[sbt] object CrossJava { ): Seq[String] = { import extracted._ import Keys._ - (crossJavaVersions in proj get structure.data).getOrElse(Nil) + ((proj / crossJavaVersions) get structure.data).getOrElse(Nil) } private def getCrossJavaHomes(extracted: Extracted, proj: ResolvedReference): Seq[File] = { import extracted._ import Keys._ - val fjh = (fullJavaHomes in proj get structure.data).get - (crossJavaVersions in proj get structure.data) map { jvs => + val fjh = ((proj / fullJavaHomes) get structure.data).get + ((proj / crossJavaVersions) get structure.data) map { jvs => jvs map { jv => lookupJavaHome(jv, fjh) } @@ -235,7 +236,7 @@ private[sbt] object CrossJava { } val scope = Scope(Select(proj), Zero, Zero, Zero) Seq( - javaHome in scope := Some(home) + (scope / javaHome) := Some(home) ) } diff --git a/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala b/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala index fa16e888d..b9effa8a9 100644 --- a/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala +++ b/main/src/main/scala/sbt/internal/DefaultBackgroundJobService.scala @@ -17,6 +17,7 @@ import java.util.concurrent.atomic.{ AtomicLong, AtomicReference } import sbt.Def.{ Classpath, ScopedKey, Setting } import sbt.Scope.GlobalScope +import sbt.SlashSyntax0._ import sbt.internal.inc.classpath.ClasspathFilter import sbt.internal.util.{ Attributed, ManagedLogger } import sbt.io.syntax._ @@ -514,9 +515,9 @@ private[sbt] object DefaultBackgroundJobService { backgroundJobServices.clear() } private[sbt] lazy val backgroundJobServiceSetting: Setting[_] = - (Keys.bgJobService in GlobalScope) := { - val path = (sbt.Keys.bgJobServiceDirectory in GlobalScope).value - val useLog4J = (Keys.useLog4J in GlobalScope).value + (GlobalScope / Keys.bgJobService) := { + val path = (GlobalScope / sbt.Keys.bgJobServiceDirectory).value + val useLog4J = (GlobalScope / Keys.useLog4J).value val newService = new DefaultBackgroundJobService(path, useLog4J) backgroundJobServices.putIfAbsent(path, newService) match { case null => newService @@ -526,7 +527,7 @@ private[sbt] object DefaultBackgroundJobService { } } private[sbt] lazy val backgroundJobServiceSettings: Seq[Def.Setting[_]] = Def.settings( - Keys.bgJobServiceDirectory in GlobalScope := { + (GlobalScope / Keys.bgJobServiceDirectory) := { sbt.Keys.appConfiguration.value.baseDirectory / "target" / "bg-jobs" }, backgroundJobServiceSetting diff --git a/main/src/main/scala/sbt/internal/EvaluateConfigurations.scala b/main/src/main/scala/sbt/internal/EvaluateConfigurations.scala index 049092600..9986629e5 100644 --- a/main/src/main/scala/sbt/internal/EvaluateConfigurations.scala +++ b/main/src/main/scala/sbt/internal/EvaluateConfigurations.scala @@ -22,6 +22,7 @@ import compiler.{ Eval, EvalImports } import sbt.internal.util.complete.DefaultParsers.validID import Def.{ ScopedKey, Setting } import Scope.GlobalScope +import sbt.SlashSyntax0._ import sbt.internal.parser.SbtParser import sbt.io.IO @@ -389,7 +390,7 @@ object Index { case _ => () } ) - val onComplete = Keys.onComplete in GlobalScope get ss getOrElse (() => ()) + val onComplete = (GlobalScope / Keys.onComplete) get ss getOrElse (() => ()) new Triggers[Task](runBefore, triggeredBy, map => { onComplete(); map }) } diff --git a/main/src/main/scala/sbt/internal/GlobalPlugin.scala b/main/src/main/scala/sbt/internal/GlobalPlugin.scala index 5f25200bb..285f15910 100644 --- a/main/src/main/scala/sbt/internal/GlobalPlugin.scala +++ b/main/src/main/scala/sbt/internal/GlobalPlugin.scala @@ -20,9 +20,11 @@ import sbt.internal.util.Attributed import Def.{ ScopedKey, Setting } import Keys._ import Configurations.{ Compile, Runtime } +import sbt.SlashSyntax0._ import java.io.File import org.apache.ivy.core.module.{ descriptor, id } import descriptor.ModuleDescriptor, id.ModuleRevisionId +import scala.annotation.nowarn object GlobalPlugin { // constructs a sequence of settings that may be appended to a project's settings to @@ -45,7 +47,7 @@ object GlobalPlugin { config: Configuration, cp: Seq[Attributed[File]] ): Setting[_] = - internalDependencyClasspath in config ~= { prev => + (config / internalDependencyClasspath) ~= { prev => (prev ++ cp).distinct } @@ -66,13 +68,15 @@ object GlobalPlugin { Project.runUnloadHooks(newS) // discard state GlobalPlugin(data, structure, inject(data), base) } + + @nowarn def extract(state: State, structure: BuildStructure): (State, GlobalPluginData) = { import structure.{ data, root, rootProject } val p: Scope = Scope.GlobalScope in ProjectRef(root, rootProject(root)) val taskInit = Def.task { - val intcp = (internalDependencyClasspath in Runtime).value - val prods = (exportedProducts in Runtime).value + val intcp = (Runtime / internalDependencyClasspath).value + val prods = (Runtime / exportedProducts).value val depMap = projectDescriptors.value + ivyModule.value.dependencyMapping(state.log) // If we reference it directly (if it's an executionRoot) then it forces an update, which is not what we want. val updateReport = Def.taskDyn { Def.task { update.value } }.value @@ -82,7 +86,7 @@ object GlobalPlugin { projectDependencies.value, depMap, resolvers.value.toVector, - (fullClasspath in Runtime).value, + (Runtime / fullClasspath).value, (prods ++ intcp).distinct )(updateReport) } @@ -105,6 +109,8 @@ object GlobalPlugin { (newS, processResult2(result)) } } + + @nowarn val globalPluginSettings = Project.inScope(Scope.GlobalScope in LocalRootProject)( Seq( organization := SbtArtifacts.Organization, diff --git a/main/src/main/scala/sbt/internal/IvyConsole.scala b/main/src/main/scala/sbt/internal/IvyConsole.scala index 3e8dc164b..ec61b1dda 100644 --- a/main/src/main/scala/sbt/internal/IvyConsole.scala +++ b/main/src/main/scala/sbt/internal/IvyConsole.scala @@ -25,6 +25,7 @@ import Configurations.Compile import Def.Setting import Keys._ import Scope.Global +import sbt.SlashSyntax0._ import sbt.io.IO @@ -46,9 +47,9 @@ object IvyConsole { val depSettings: Seq[Setting[_]] = Seq( libraryDependencies ++= managed.reverse, resolvers ++= repos.reverse.toVector, - unmanagedJars in Compile ++= Attributed blankSeq unmanaged.reverse, - logLevel in Global := Level.Warn, - showSuccess in Global := false + Compile / unmanagedJars ++= Attributed blankSeq unmanaged.reverse, + Global / logLevel := Level.Warn, + Global / showSuccess := false ) val append = Load.transformSettings( Load.projectScope(currentRef), diff --git a/main/src/main/scala/sbt/internal/LibraryManagement.scala b/main/src/main/scala/sbt/internal/LibraryManagement.scala index 9f6b22ac7..e6aafbbba 100644 --- a/main/src/main/scala/sbt/internal/LibraryManagement.scala +++ b/main/src/main/scala/sbt/internal/LibraryManagement.scala @@ -11,6 +11,7 @@ package internal import java.io.File import java.util.concurrent.Callable +import sbt.SlashSyntax0._ import sbt.internal.librarymanagement._ import sbt.librarymanagement._ import sbt.librarymanagement.syntax._ @@ -265,7 +266,7 @@ private[sbt] object LibraryManagement { val updateConf = { import UpdateLogging.{ Full, DownloadOnly, Default } val conf = updateConfiguration.value - val maybeUpdateLevel = (logLevel in update).?.value + val maybeUpdateLevel = (update / logLevel).?.value val conf1 = maybeUpdateLevel.orElse(state0.get(logLevel.key)) match { case Some(Level.Debug) if conf.logging == Default => conf.withLogging(logging = Full) case Some(_) if conf.logging == Default => conf.withLogging(logging = DownloadOnly) @@ -283,10 +284,10 @@ private[sbt] object LibraryManagement { Reference.display(thisProjectRef.value), updateConf, identity, - skip = (skip in update).value, + skip = (update / skip).value, force = shouldForce, depsUpdated = transitiveUpdate.value.exists(!_.stats.cached), - uwConfig = (unresolvedWarningConfiguration in update).value, + uwConfig = (update / unresolvedWarningConfiguration).value, evictionLevel = Level.Debug, versionSchemeOverrides = Nil, assumedEvictionErrorLevel = Level.Debug, @@ -310,7 +311,7 @@ private[sbt] object LibraryManagement { val app = appConfiguration.value val srcTypes = sourceArtifactTypes.value val docTypes = docArtifactTypes.value - val uwConfig = (unresolvedWarningConfiguration in update).value + val uwConfig = (update / unresolvedWarningConfiguration).value val out = is.withIvy(s.log)(_.getSettings.getDefaultIvyUserDir) withExcludes(out, mod.classifiers, lock(app)) { excludes => lm.updateClassifiers( diff --git a/main/src/main/scala/sbt/internal/LintUnused.scala b/main/src/main/scala/sbt/internal/LintUnused.scala index d29993b18..af7645504 100644 --- a/main/src/main/scala/sbt/internal/LintUnused.scala +++ b/main/src/main/scala/sbt/internal/LintUnused.scala @@ -13,6 +13,7 @@ import Def.{ Setting, ScopedKey } import sbt.internal.util.{ FilePosition, NoPosition, SourcePosition } import java.io.File import Scope.Global +import sbt.SlashSyntax0._ import sbt.Def._ object LintUnused { @@ -63,8 +64,8 @@ object LintUnused { val _ = Def.spaceDelimited().parsed // not used yet val state = Keys.state.value val log = streams.value.log - val includeKeys = (lintIncludeFilter in Global).value - val excludeKeys = (lintExcludeFilter in Global).value + val includeKeys = (Global / lintIncludeFilter).value + val excludeKeys = (Global / lintExcludeFilter).value val result = lintUnused(state, includeKeys, excludeKeys) if (result.isEmpty) log.success("ok") else lintResultLines(result) foreach { log.warn(_) } @@ -74,9 +75,9 @@ object LintUnused { def lintUnusedFunc(s: State): State = { val log = s.log val extracted = Project.extract(s) - val includeKeys = extracted.get(lintIncludeFilter in Global) - val excludeKeys = extracted.get(lintExcludeFilter in Global) - if (extracted.get(lintUnusedKeysOnLoad in Global)) { + val includeKeys = extracted.get((Global / lintIncludeFilter)) + val excludeKeys = extracted.get((Global / lintExcludeFilter)) + if (extracted.get((Global / lintUnusedKeysOnLoad))) { val result = lintUnused(s, includeKeys, excludeKeys) lintResultLines(result) foreach { log.warn(_) } } diff --git a/main/src/main/scala/sbt/internal/Load.scala b/main/src/main/scala/sbt/internal/Load.scala index 7713fa145..7b9d83c72 100755 --- a/main/src/main/scala/sbt/internal/Load.scala +++ b/main/src/main/scala/sbt/internal/Load.scala @@ -16,6 +16,7 @@ import sbt.Def.{ ScopeLocal, ScopedKey, Setting, isDummy } import sbt.Keys._ import sbt.Project.inScope import sbt.Scope.GlobalScope +import sbt.SlashSyntax0._ import sbt.compiler.Eval import sbt.internal.BuildStreams._ import sbt.internal.inc.classpath.ClasspathUtil @@ -30,7 +31,7 @@ import sbt.nio.Settings import sbt.util.{ Logger, Show } import xsbti.compile.{ ClasspathOptionsUtil, Compilers } -import scala.annotation.tailrec +import scala.annotation.{ nowarn, tailrec } import scala.collection.mutable import scala.tools.nsc.reporters.ConsoleReporter @@ -128,7 +129,7 @@ private[sbt] object Load { } def injectGlobal(state: State): Seq[Setting[_]] = - (appConfiguration in GlobalScope :== state.configuration) +: + ((GlobalScope / appConfiguration) :== state.configuration) +: LogManager.settingsLogger(state) +: EvaluateTask.injectSettings @@ -375,7 +376,7 @@ private[sbt] object Load { rootProject: URI => String, injectSettings: InjectSettings ): Seq[Setting[_]] = { - ((loadedBuild in GlobalScope :== loaded) +: + (((GlobalScope / loadedBuild) :== loaded) +: transformProjectOnly(loaded.root, rootProject, injectSettings.global)) ++ inScope(GlobalScope)(loaded.autos.globalSettings) ++ loaded.units.toSeq.flatMap { @@ -386,7 +387,7 @@ private[sbt] object Load { val ref = ProjectRef(uri, id) val defineConfig: Seq[Setting[_]] = for (c <- project.configurations) - yield ((configuration in (ref, ConfigKey(c.name))) :== c) + yield ((ref / ConfigKey(c.name) / configuration) :== c) val builtin: Seq[Setting[_]] = (thisProject :== project) +: (thisProjectRef :== ref) +: defineConfig val settings = builtin ++ project.settings ++ injectSettings.project @@ -1154,14 +1155,15 @@ private[sbt] object Load { } /** These are the settings defined when loading a project "meta" build. */ + @nowarn val autoPluginSettings: Seq[Setting[_]] = inScope(GlobalScope in LocalRootProject)( Seq( sbtPlugin :== true, isMetaBuild :== true, pluginData := { - val prod = (exportedProducts in Configurations.Runtime).value - val cp = (fullClasspath in Configurations.Runtime).value - val opts = (scalacOptions in Configurations.Compile).value + val prod = (Configurations.Runtime / exportedProducts).value + val cp = (Configurations.Runtime / fullClasspath).value + val opts = (Configurations.Compile / scalacOptions).value PluginData( removeEntries(cp, prod), prod, diff --git a/main/src/main/scala/sbt/internal/LogManager.scala b/main/src/main/scala/sbt/internal/LogManager.scala index b643b277e..e28fd91ee 100644 --- a/main/src/main/scala/sbt/internal/LogManager.scala +++ b/main/src/main/scala/sbt/internal/LogManager.scala @@ -12,11 +12,13 @@ import java.io.PrintWriter import sbt.Def.ScopedKey import sbt.Keys._ -import sbt.Scope.GlobalScope +import sbt.Scope.Global +import sbt.SlashSyntax0._ import sbt.internal.util.MainAppender._ import sbt.internal.util.{ Terminal => ITerminal, _ } import sbt.util.{ Level, LogExchange, Logger, LoggerContext } import org.apache.logging.log4j.core.{ Appender => XAppender } +import scala.annotation.nowarn sealed abstract class LogManager { def apply( @@ -59,6 +61,7 @@ object LogManager { // This is called by mkStreams // + @nowarn def construct( data: Settings[Scope], state: State @@ -70,6 +73,7 @@ object LogManager { manager(data, state, task, to, context) } + @nowarn def constructBackgroundLog( data: Settings[Scope], state: State @@ -309,7 +313,7 @@ object LogManager { private[sbt] def settingsLogger(state: State): Def.Setting[_] = // strict to avoid retaining a reference to `state` - sLog in GlobalScope :== globalWrapper(state) + Global / sLog :== globalWrapper(state) // construct a Logger that delegates to the global logger, but only holds a weak reference // this is an approximation to the ideal that would invalidate the delegate after loading completes diff --git a/main/src/main/scala/sbt/internal/PluginsDebug.scala b/main/src/main/scala/sbt/internal/PluginsDebug.scala index a7ed6ec84..d73cfcdc7 100644 --- a/main/src/main/scala/sbt/internal/PluginsDebug.scala +++ b/main/src/main/scala/sbt/internal/PluginsDebug.scala @@ -12,6 +12,7 @@ import sbt.internal.util.{ AttributeKey, Dag, Relation, Util } import sbt.util.Logger import Def.Setting +import sbt.SlashSyntax0._ import Plugins._ import PluginsDebug._ import java.net.URI @@ -169,7 +170,7 @@ private[sbt] object PluginsDebug { val extracted = Project.extract(s) import extracted._ def definesPlugin(p: ResolvedProject): Boolean = p.autoPlugins.contains(plugin) - def projectForRef(ref: ProjectRef): ResolvedProject = get(Keys.thisProject in ref) + def projectForRef(ref: ProjectRef): ResolvedProject = get(ref / Keys.thisProject) val perBuild: Map[URI, Set[AutoPlugin]] = structure.units.mapValues(unit => availableAutoPlugins(unit).toSet).toMap val pluginsThisBuild = perBuild.getOrElse(currentRef.build, Set.empty).toList diff --git a/main/src/main/scala/sbt/internal/RemoteCache.scala b/main/src/main/scala/sbt/internal/RemoteCache.scala index 9ecd54c6b..6e46f607f 100644 --- a/main/src/main/scala/sbt/internal/RemoteCache.scala +++ b/main/src/main/scala/sbt/internal/RemoteCache.scala @@ -33,6 +33,7 @@ import sbt.internal.remotecache._ import sbt.internal.inc.{ HashUtil, JarUtils } import sbt.util.InterfaceUtil.toOption import sbt.util.Logger +import scala.annotation.nowarn object RemoteCache { final val cachedCompileClassifier = "cached-compile" @@ -151,6 +152,7 @@ object RemoteCache { ) ++ inConfig(Compile)(configCacheSettings(compileArtifact(Compile, cachedCompileClassifier))) ++ inConfig(Test)(configCacheSettings(testArtifact(Test, cachedTestClassifier)))) + @nowarn def configCacheSettings[A <: RemoteCacheArtifact]( cacheArtifactTask: Def.Initialize[Task[A]] ): Seq[Def.Setting[_]] = diff --git a/main/src/main/scala/sbt/internal/Script.scala b/main/src/main/scala/sbt/internal/Script.scala index 5615dcd5e..203ee2000 100644 --- a/main/src/main/scala/sbt/internal/Script.scala +++ b/main/src/main/scala/sbt/internal/Script.scala @@ -17,6 +17,7 @@ import Keys._ import EvaluateConfigurations.{ evaluateConfiguration => evaluate } import Configurations.Compile import Scope.Global +import sbt.SlashSyntax0._ import sbt.io.{ Hash, IO } @@ -50,13 +51,13 @@ object Script { val embeddedSettings = blocks(script).flatMap { block => evaluate(eval(), script, block.lines, currentUnit.imports, block.offset + 1)(currentLoader) } - val scriptAsSource = sources in Compile := script :: Nil + val scriptAsSource = (Compile / sources) := script :: Nil val asScript = scalacOptions ++= Seq("-Xscript", script.getName.stripSuffix(".scala")) val scriptSettings = Seq( asScript, scriptAsSource, - logLevel in Global := Level.Warn, - showSuccess in Global := false + (Global / logLevel) := Level.Warn, + (Global / showSuccess) := false ) val append = Load.transformSettings( Load.projectScope(currentRef), diff --git a/main/src/main/scala/sbt/internal/SettingCompletions.scala b/main/src/main/scala/sbt/internal/SettingCompletions.scala index 40ec4cb1c..e3ff3cce4 100644 --- a/main/src/main/scala/sbt/internal/SettingCompletions.scala +++ b/main/src/main/scala/sbt/internal/SettingCompletions.scala @@ -18,6 +18,7 @@ import Scope.Global import Types.idFun import complete._ import DefaultParsers._ +import scala.annotation.nowarn /** * The resulting `session` and verbose and quiet summaries of the result of a set operation. @@ -53,6 +54,8 @@ private[sbt] object SettingCompletions { val projectScope = Load.projectScope(currentRef) def resolve(s: Setting[_]): Seq[Setting[_]] = Load.transformSettings(projectScope, currentRef.build, rootProject, s :: Nil) + + @nowarn def rescope[T](setting: Setting[T]): Seq[Setting[_]] = { val akey = setting.key.key val global = ScopedKey(Global, akey) diff --git a/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala b/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala index 44fb45f3a..5215f4ea8 100644 --- a/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala +++ b/main/src/main/scala/sbt/internal/WatchTransitiveDependencies.scala @@ -19,7 +19,7 @@ import sbt.nio.FileStamper import sbt.nio.Keys._ import sbt.nio.file.Glob -import scala.annotation.tailrec +import scala.annotation.{ nowarn, tailrec } private[sbt] object WatchTransitiveDependencies { private implicit class SourceOps(val source: Source) { @@ -53,6 +53,8 @@ private[sbt] object WatchTransitiveDependencies { def structure: BuildStructure = extracted.structure def data: Map[Scope, AttributeMap] = extracted.structure.data.data } + + @nowarn private def argumentsImpl( scopedKey: ScopedKey[_], extracted: Extracted, @@ -127,6 +129,7 @@ private[sbt] object WatchTransitiveDependencies { (inputGlobs ++ triggerGlobs ++ legacy(keys :+ scopedKey, args)).distinct.sorted } + @nowarn private def legacy(keys: Seq[ScopedKey[_]], args: Arguments): Seq[DynamicInput] = { import args._ val projectScopes = @@ -160,6 +163,8 @@ private[sbt] object WatchTransitiveDependencies { case Right(globs) => globs.map(toDynamicInput) } } + + @nowarn @tailrec private def collectKeys( arguments: Arguments, diff --git a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala index d28e28674..7de551a56 100644 --- a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala +++ b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala @@ -30,8 +30,10 @@ import sbt.util.Logger import sjsonnew.shaded.scalajson.ast.unsafe.{ JNull, JValue } import sjsonnew.support.scalajson.unsafe.{ CompactPrinter, Converter, Parser => JsonParser } +// import scala.annotation.nowarn import scala.util.control.NonFatal import scala.util.{ Failure, Success, Try } +import scala.annotation.nowarn object BuildServerProtocol { import sbt.internal.bsp.codec.JsonProtocol._ @@ -369,6 +371,7 @@ object BuildServerProtocol { ) ) + @nowarn private def bspWorkspaceSetting: Def.Initialize[Map[BuildTargetIdentifier, Scope]] = Def.settingDyn { val loadedBuild = Keys.loadedBuild.value @@ -417,7 +420,7 @@ object BuildServerProtocol { (dep, configs) <- Keys.bspInternalDependencyConfigurations.value config <- configs if dep != thisProjectRef || config.name != thisConfig.name - } yield Keys.bspTargetIdentifier.in(dep, config) + } yield (dep / config / Keys.bspTargetIdentifier) val capabilities = BuildTargetCapabilities(canCompile = true, canTest = true, canRun = true) val tags = BuildTargetTag.fromConfig(configuration.name) Def.task { @@ -444,7 +447,7 @@ object BuildServerProtocol { val internalDependencyClasspath = for { (ref, configs) <- bspInternalDependencyConfigurations.value config <- configs - } yield Keys.classDirectory.in(ref, config) + } yield ref / config / Keys.classDirectory Def.task { val classpath = internalDependencyClasspath.join.value.distinct ++ @@ -596,6 +599,7 @@ object BuildServerProtocol { state.respondEvent(RunResult(originId, statusCode)) } + @nowarn private def internalDependencyConfigurationsSetting = Def.settingDyn { val allScopes = bspWorkspace.value.map { case (_, scope) => scope }.toSet val directDependencies = Keys.internalDependencyConfigurations.value @@ -618,7 +622,7 @@ object BuildServerProtocol { val transitiveDependencies = for { (dep, configs) <- directDependencies config <- configs if dep != ref || config.name != thisConfig.name - } yield Keys.bspInternalDependencyConfigurations.in(dep, config) + } yield dep / config / Keys.bspInternalDependencyConfigurations Def.setting { val allDependencies = directDependencies ++ transitiveDependencies.join.value.flatten diff --git a/main/src/main/scala/sbt/internal/server/NetworkChannel.scala b/main/src/main/scala/sbt/internal/server/NetworkChannel.scala index 87b8db41d..4221f9db7 100644 --- a/main/src/main/scala/sbt/internal/server/NetworkChannel.scala +++ b/main/src/main/scala/sbt/internal/server/NetworkChannel.scala @@ -36,7 +36,7 @@ import sbt.internal.util.complete.{ Parser, Parsers } import sbt.protocol._ import sbt.util.Logger -import scala.annotation.tailrec +import scala.annotation.{ nowarn, tailrec } import scala.collection.mutable import scala.concurrent.duration._ import scala.util.Try @@ -418,6 +418,7 @@ final class NetworkChannel( } } + @nowarn protected def onCompletionRequest(execId: Option[String], cp: CompletionParams) = { if (initialized) { try { diff --git a/main/src/main/scala/sbt/nio/Settings.scala b/main/src/main/scala/sbt/nio/Settings.scala index 0351015b6..3f78649af 100644 --- a/main/src/main/scala/sbt/nio/Settings.scala +++ b/main/src/main/scala/sbt/nio/Settings.scala @@ -63,6 +63,7 @@ private[sbt] object Settings { * @param fileOutputScopes the set of scopes for which the fileOutputs setting is defined * @return the injected settings */ + @nowarn private[this] def maybeAddOutputsAndFileStamps( setting: Def.Setting[_], fileOutputScopes: Set[Scope] @@ -104,6 +105,8 @@ private[sbt] object Settings { case _ => Nil } } + + @nowarn private[sbt] val inject: Def.ScopedKey[_] => Seq[Def.Setting[_]] = scopedKey => scopedKey.key match { case transitiveDynamicInputs.key => @@ -138,6 +141,7 @@ private[sbt] object Settings { * @return a task definition that retrieves the file input files and their attributes scoped * to a particular task. */ + @nowarn private[sbt] def inputPathSettings(setting: Def.Setting[_]): Seq[Def.Setting[_]] = { val scopedKey = setting.key val scope = scopedKey.scope @@ -168,6 +172,7 @@ private[sbt] object Settings { * @param scope the key whose file inputs we are seeking * @return a task definition that retrieves all of the input paths scoped to the input key. */ + @nowarn private[this] def allFilesImpl(scope: Scope): Def.Setting[_] = { addTaskDefinition(Keys.allInputFiles in scope := { val filter = @@ -187,6 +192,7 @@ private[sbt] object Settings { * @param scope the scope corresponding to the task whose fileInputs we are seeking * @return a task definition that retrieves the changed input files scoped to the key. */ + @nowarn private[this] def changedInputFilesImpl(scope: Scope): List[Def.Setting[_]] = changedFilesImpl(scope, changedInputFiles, inputFileStamps) :: (watchForceTriggerOnAnyChange in scope := { @@ -195,6 +201,8 @@ private[sbt] object Settings { case None => false } }) :: Nil + + @nowarn private[this] def changedFilesImpl( scope: Scope, changeKey: TaskKey[Seq[(Path, FileStamp)] => FileChanges], @@ -242,6 +250,7 @@ private[sbt] object Settings { * @param scope the scope to add the custom clean * @return a task specific clean implementation */ + @nowarn private[sbt] def cleanImpl(scope: Scope): Def.Setting[_] = addTaskDefinition { sbt.Keys.clean in scope := Clean.task(scope, full = false).value } @@ -252,6 +261,7 @@ private[sbt] object Settings { * @param taskKey the task for which we add a custom clean implementation * @return a task specificic clean implementation */ + @nowarn private[sbt] def cleanImpl[T: JsonFormat: ToSeqPath](taskKey: TaskKey[T]): Def.Setting[_] = { val taskScope = taskKey.scope in taskKey.key addTaskDefinition(sbt.Keys.clean in taskScope := Def.taskDyn { @@ -299,6 +309,7 @@ private[sbt] object Settings { }) } + @nowarn private[this] def outputsAndStamps[T: JsonFormat: ToSeqPath]( taskKey: TaskKey[T] ): List[Def.Setting[_]] = { @@ -306,6 +317,8 @@ private[sbt] object Settings { val changes = changedFilesImpl(scope, changedOutputFiles, outputFileStamps) :: Nil allOutputPathsImpl(scope) :: outputFileStampsImpl(scope) :: cleanImpl(taskKey) :: changes } + + @nowarn private[this] def allOutputPathsImpl(scope: Scope): Def.Setting[_] = addTaskDefinition(allOutputFiles in scope := { val filter = @@ -331,6 +344,8 @@ private[sbt] object Settings { fileOutputGlobs.exists(_.matches(p)) || !attributeFilter(p) } }) + + @nowarn private[this] def outputFileStampsImpl(scope: Scope): Def.Setting[_] = addTaskDefinition(outputFileStamps in scope := { val stamper: Path => Option[FileStamp] = (outputFileStamper in scope).value match { diff --git a/main/src/main/scala/sbt/nio/Watch.scala b/main/src/main/scala/sbt/nio/Watch.scala index ace5d26e3..0e235ed13 100644 --- a/main/src/main/scala/sbt/nio/Watch.scala +++ b/main/src/main/scala/sbt/nio/Watch.scala @@ -14,6 +14,7 @@ import java.util.Locale import java.util.concurrent.TimeUnit import sbt.BasicCommandStrings.{ ContinuousExecutePrefix, TerminateAction } +import sbt.SlashSyntax0._ import sbt._ import sbt.internal.LabeledFunctions._ import sbt.internal.nio.FileEvent @@ -620,7 +621,7 @@ object Watch { watchStartMessage :== Watch.defaultStartWatch, watchTriggeredMessage :== Watch.defaultOnTriggerMessage, watchForceTriggerOnAnyChange :== false, - watchPersistFileStamps := (sbt.Keys.turbo in ThisBuild).value, + watchPersistFileStamps := (ThisBuild / sbt.Keys.turbo).value, watchTriggers :== Nil, watchAntiEntropyPollPeriod := Watch.defaultAntiEntropyPollPeriod, ) diff --git a/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala b/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala index 902d54277..2c20525e9 100644 --- a/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala +++ b/main/src/main/scala/sbt/plugins/DependencyTreeSettings.scala @@ -46,7 +46,7 @@ object DependencyTreeSettings { // concatenating & inlining ivySbt & ivyModule default task implementations, as `SbtAccess.inTask` does // NOT correctly force the scope when applied to `TaskKey.toTask` instances (as opposed to raw // implementations like `Classpaths.mkIvyConfiguration` or `Classpaths.updateTask`) - val is = new IvySbt((ivyConfiguration in dependencyTreeIgnoreMissingUpdate).value) + val is = new IvySbt((dependencyTreeIgnoreMissingUpdate / ivyConfiguration).value) new is.Module(moduleSettings.value) }, // don't fail on missing dependencies @@ -161,7 +161,7 @@ object DependencyTreeSettings { key / asString := renderer(dependencyTreeModuleGraph0.value), key / toFile := { val (targetFile, force) = targetFileAndForceParser.parsed - writeToFile(key.key.label, (asString in key).value, targetFile, force, streams.value) + writeToFile(key.key.label, (key / asString).value, targetFile, force, streams.value) }, )