diff --git a/main-actions/src/main/scala/sbt/TestResultLogger.scala b/main-actions/src/main/scala/sbt/TestResultLogger.scala index 1415f3818..687dd3a52 100644 --- a/main-actions/src/main/scala/sbt/TestResultLogger.scala +++ b/main-actions/src/main/scala/sbt/TestResultLogger.scala @@ -27,7 +27,7 @@ trait TestResultLogger { * * @param log The target logger to write output to. * @param results The test results about which to log. - * @param taskName The task about which we are logging. Eg. "my-module-b/test:test" + * @param taskName The task about which we are logging. Eg. "my-module-b/Test/test" */ def run(log: Logger, results: Output, taskName: String): Unit diff --git a/main-settings/src/main/scala/sbt/Def.scala b/main-settings/src/main/scala/sbt/Def.scala index 57d5ca174..30206a8d4 100644 --- a/main-settings/src/main/scala/sbt/Def.scala +++ b/main-settings/src/main/scala/sbt/Def.scala @@ -29,8 +29,32 @@ import xsbti.{ HashedVirtualFileRef, VirtualFile, VirtualFileRef } import sjsonnew.JsonFormat import scala.reflect.ClassTag +trait BuildSyntax: + inline def settingKey[A1](inline description: String): SettingKey[A1] = + ${ std.KeyMacro.settingKeyImpl[A1]('description) } + + inline def taskKey[A1](inline description: String): TaskKey[A1] = + ${ std.KeyMacro.taskKeyImpl[A1]('description) } + + inline def inputKey[A1](inline description: String): InputKey[A1] = + ${ std.KeyMacro.inputKeyImpl[A1]('description) } + + import sbt.std.ParserInput + extension [A1](inline in: Task[A1]) + inline def value: A1 = std.InputWrapper.`wrapTask_\u2603\u2603`[A1](in) + + // implicit def macroValueIn[T](@deprecated("unused", "") in: InputTask[T]): std.InputEvaluated[T] = + // ??? + + extension [A1](inline in: Parser[A1]) + inline def parsed: A1 = ParserInput.`parser_\u2603\u2603`[A1](Def.toSParser(in)) + + extension [A1](inline in: State => Parser[A1]) + inline def parsed: A1 = ParserInput.`parser_\u2603\u2603`[A1](in) +end BuildSyntax + /** A concrete settings system that uses `sbt.Scope` for the scope type. */ -object Def extends Init[Scope] with TaskMacroExtra with InitializeImplicits: +object Def extends BuildSyntax with Init[Scope] with InitializeImplicits: type Classpath = Seq[Attributed[HashedVirtualFileRef]] def settings(ss: SettingsDefinition*): Seq[Setting[_]] = ss.flatMap(_.settings) @@ -404,15 +428,6 @@ object Def extends Init[Scope] with TaskMacroExtra with InitializeImplicits: ) ) - inline def settingKey[A1](inline description: String): SettingKey[A1] = - ${ std.KeyMacro.settingKeyImpl[A1]('description) } - - inline def taskKey[A1](inline description: String): TaskKey[A1] = - ${ std.KeyMacro.taskKeyImpl[A1]('description) } - - inline def inputKey[A1](inline description: String): InputKey[A1] = - ${ std.KeyMacro.inputKeyImpl[A1]('description) } - class InitOps[T](private val x: Initialize[T]) extends AnyVal { def toTaskable: Taskable[T] = x } @@ -449,28 +464,9 @@ object Def extends Init[Scope] with TaskMacroExtra with InitializeImplicits: t.info.attributes.get(isDummyTask) getOrElse false end Def -// these need to be mixed into the sbt package object -// because the target doesn't involve Initialize or anything in Def -trait TaskMacroExtra: - import sbt.std.ParserInput - extension [A1](inline in: Task[A1]) - inline def value: A1 = std.InputWrapper.`wrapTask_\u2603\u2603`[A1](in) - - // implicit def macroValueIn[T](@deprecated("unused", "") in: InputTask[T]): std.InputEvaluated[T] = - // ??? - - extension [A1](inline in: Parser[A1]) - inline def parsed: A1 = ParserInput.`parser_\u2603\u2603`[A1](Def.toSParser(in)) - - extension [A1](inline in: State => Parser[A1]) - inline def parsed: A1 = ParserInput.`parser_\u2603\u2603`[A1](in) -end TaskMacroExtra - -sealed trait InitializeImplicits0 { self: Def.type => +sealed trait InitializeImplicits { self: Def.type => implicit def initOps[T](x: Def.Initialize[T]): Def.InitOps[T] = new Def.InitOps(x) -} -sealed trait InitializeImplicits extends InitializeImplicits0 { self: Def.type => implicit def initTaskOps[T](x: Def.Initialize[Task[T]]): Def.InitTaskOps[T] = new Def.InitTaskOps(x) } diff --git a/main-settings/src/main/scala/sbt/Structure.scala b/main-settings/src/main/scala/sbt/Structure.scala index f03f127b3..bce97a035 100644 --- a/main-settings/src/main/scala/sbt/Structure.scala +++ b/main-settings/src/main/scala/sbt/Structure.scala @@ -382,6 +382,8 @@ object Scoped: protected def onTask[A2](f: Task[A1] => Task[A2]): Initialize[Task[A2]] = init.apply(f) + def dependsOn(tasks: Initialize[? <: Task[?]]*): Initialize[Task[A1]] = + init.zipWith(tasks.asInstanceOf[Seq[Initialize[Task[?]]]].join)(_.dependsOn(_*)) def flatMapTaskValue[T](f: A1 => Task[T]): Initialize[Task[T]] = onTask(_.result flatMap (f compose successM)) def map[A2](f: A1 => A2): Initialize[Task[A2]] = diff --git a/main/src/main/scala/sbt/BareBuildSyntax.scala b/main/src/main/scala/sbt/BareBuildSyntax.scala new file mode 100644 index 000000000..4396e8234 --- /dev/null +++ b/main/src/main/scala/sbt/BareBuildSyntax.scala @@ -0,0 +1,23 @@ +/* + * sbt + * Copyright 2023, Scala center + * Copyright 2011 - 2022, Lightbend, Inc. + * Copyright 2008 - 2010, Mark Harrah + * Licensed under Apache License 2.0 (see LICENSE) + */ + +package sbt + +import sbt.internal.DslEntry +import sbt.librarymanagement.Configuration + +trait BareBuildSyntax: + def enablePlugins(ps: AutoPlugin*): DslEntry = DslEntry.DslEnablePlugins(ps) + def disablePlugins(ps: AutoPlugin*): DslEntry = DslEntry.DslDisablePlugins(ps) + def configs(cs: Configuration*): DslEntry = DslEntry.DslConfigs(cs) + def dependsOn(deps: ClasspathDep[ProjectReference]*): DslEntry = DslEntry.DslDependsOn(deps) + // avoid conflict with `sbt.Keys.aggregate` + def aggregateProjects(refs: ProjectReference*): DslEntry = DslEntry.DslAggregate(refs) +end BareBuildSyntax + +object BareBuildSyntax extends BareBuildSyntax diff --git a/main/src/main/scala/sbt/BuildSyntax.scala b/main/src/main/scala/sbt/BuildSyntax.scala deleted file mode 100644 index ad0825502..000000000 --- a/main/src/main/scala/sbt/BuildSyntax.scala +++ /dev/null @@ -1,41 +0,0 @@ -/* - * sbt - * Copyright 2023, Scala center - * Copyright 2011 - 2022, Lightbend, Inc. - * Copyright 2008 - 2010, Mark Harrah - * Licensed under Apache License 2.0 (see LICENSE) - */ - -package sbt - -import sbt.internal.DslEntry -import sbt.librarymanagement.Configuration - -private[sbt] trait BuildSyntax: - import scala.language.experimental.macros - - /** - * Creates a new Project. This is a macro that expects to be assigned directly to a val. - * The name of the val is used as the project ID and the name of the base directory of the project. - */ - inline def project: Project = ${ std.KeyMacro.projectImpl } - inline def projectMatrix: ProjectMatrix = ${ ProjectMatrix.projectMatrixImpl } - inline def settingKey[A1](inline description: String): SettingKey[A1] = - ${ std.KeyMacro.settingKeyImpl[A1]('description) } - inline def taskKey[A1](inline description: String): TaskKey[A1] = - ${ std.KeyMacro.taskKeyImpl[A1]('description) } - inline def inputKey[A1](inline description: String): InputKey[A1] = - ${ std.KeyMacro.inputKeyImpl[A1]('description) } - - def enablePlugins(ps: AutoPlugin*): DslEntry = DslEntry.DslEnablePlugins(ps) - def disablePlugins(ps: AutoPlugin*): DslEntry = DslEntry.DslDisablePlugins(ps) - def configs(cs: Configuration*): DslEntry = DslEntry.DslConfigs(cs) - def dependsOn(deps: ClasspathDep[ProjectReference]*): DslEntry = DslEntry.DslDependsOn(deps) - // avoid conflict with `sbt.Keys.aggregate` - def aggregateProjects(refs: ProjectReference*): DslEntry = DslEntry.DslAggregate(refs) - - implicit def sbtStateToUpperStateOps(s: State): UpperStateOps = - new UpperStateOps.UpperStateOpsImpl(s) -end BuildSyntax - -private[sbt] object BuildSyntax extends BuildSyntax diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 3782bd24b..27b6da56b 100644 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -332,9 +332,6 @@ object Defaults extends BuildCommon { envVars :== Map.empty, sbtVersion := appConfiguration.value.provider.id.version, sbtBinaryVersion := binarySbtVersion(sbtVersion.value), - // `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. pluginCrossBuild / sbtVersion := sbtVersion.value, onLoad := idFun[State], onUnload := idFun[State], @@ -2902,6 +2899,9 @@ object Classpaths { import Defaults._ import Keys._ + def analyzed[A](data: A, analysisFile: VirtualFile): Attributed[A] = + Attributed.blank(data).put(Keys.analysis, analysisFile.id) + def concatDistinct[A]( a: Taskable[Seq[A]], b: Taskable[Seq[A]] @@ -3102,7 +3102,7 @@ object Classpaths { Defaults.globalDefaults( Seq( publishMavenStyle :== true, - sbtPluginPublishLegacyMavenStyle :== true, + sbtPluginPublishLegacyMavenStyle :== false, publishArtifact :== true, (Test / publishArtifact) :== false ) @@ -4776,11 +4776,18 @@ object Classpaths { } } -private[sbt] object Build0 extends BuildExtra +private[sbt] object BuildExtra extends BuildExtra trait BuildExtra extends BuildCommon with DefExtra { import Defaults._ + /** + * Creates a new Project. This is a macro that expects to be assigned directly to a val. + * The name of the val is used as the project ID and the name of the base directory of the project. + */ + inline def project: Project = ${ std.KeyMacro.projectImpl } + inline def projectMatrix: ProjectMatrix = ${ ProjectMatrix.projectMatrixImpl } + /** * Defines an alias given by `name` that expands to `value`. * This alias is defined globally after projects are loaded. @@ -5042,7 +5049,7 @@ trait BuildExtra extends BuildCommon with DefExtra { /** * Disables post-compilation hook for determining tests for tab-completion (such as for 'test-only'). - * This is useful for reducing test:compile time when not running test. + * This is useful for reducing Test/compile time when not running test. */ def noTestCompletion(config: Configuration = Test): Setting[_] = inConfig(config)(Seq(definedTests := detectTests.value)).head @@ -5051,6 +5058,9 @@ trait BuildExtra extends BuildCommon with DefExtra { f: ScopedKey[_] => Boolean ): Seq[Setting[_]] = ss filter (s => f(s.key) && (!transitive || s.dependencies.forall(f))) + + implicit def sbtStateToUpperStateOps(s: State): UpperStateOps = + new UpperStateOps.UpperStateOpsImpl(s) } trait DefExtra { diff --git a/main/src/main/scala/sbt/EvaluateTask.scala b/main/src/main/scala/sbt/EvaluateTask.scala index 3e1dabea6..3eb37c2b7 100644 --- a/main/src/main/scala/sbt/EvaluateTask.scala +++ b/main/src/main/scala/sbt/EvaluateTask.scala @@ -13,6 +13,7 @@ import java.util.concurrent.atomic.AtomicReference import sbt.Def.{ ScopedKey, Setting, dummyState } import sbt.Keys.{ TaskProgress => _, name => _, _ } +import sbt.BuildExtra.* import sbt.ProjectExtra.* import sbt.Scope.Global import sbt.SlashSyntax0._ @@ -24,7 +25,6 @@ import sbt.internal.util.{ Terminal => ITerminal, _ } import sbt.librarymanagement.{ Resolver, UpdateReport } import sbt.std.Transform.DummyTaskMap import sbt.util.{ Logger, Show } -import sbt.BuildSyntax._ import sbt.internal.bsp.BuildTargetIdentifier import scala.annotation.nowarn diff --git a/main/src/main/scala/sbt/Keys.scala b/main/src/main/scala/sbt/Keys.scala index e602d450e..610faebb1 100644 --- a/main/src/main/scala/sbt/Keys.scala +++ b/main/src/main/scala/sbt/Keys.scala @@ -16,8 +16,7 @@ import lmcoursier.{ CoursierConfiguration, FallbackDependency } import org.apache.ivy.core.module.descriptor.ModuleDescriptor import org.apache.ivy.core.module.id.ModuleRevisionId import org.apache.logging.log4j.core.{ Appender => XAppender } -import sbt.BuildSyntax._ -import sbt.Def.ScopedKey +import sbt.Def.* import sbt.KeyRanks._ import sbt.internal.InMemoryCacheStore.CacheStoreFactoryFactory import sbt.internal._ diff --git a/main/src/main/scala/sbt/internal/Act.scala b/main/src/main/scala/sbt/internal/Act.scala index 2522e7ff9..91ad20c4a 100644 --- a/main/src/main/scala/sbt/internal/Act.scala +++ b/main/src/main/scala/sbt/internal/Act.scala @@ -44,7 +44,6 @@ final class ParsedKey(val key: ScopedKey[_], val mask: ScopeMask, val separaters end ParsedKey object Act { - val ZeroString = "*" private[sbt] val GlobalIdent = "Global" private[sbt] val ZeroIdent = "Zero" private[sbt] val ThisBuildIdent = "ThisBuild" @@ -54,8 +53,6 @@ object Act { token(OptSpace ~> '/' <~ OptSpace).examples("/").map(_ => ()) private[sbt] val slashSeq: Seq[String] = Seq("/") - private[sbt] val colonSeq: Seq[String] = Seq(":") - private[sbt] val colonColonSeq: Seq[String] = Seq("::") type KeysParser = Parser[Seq[ScopedKey[Any]]] type KeysParserSep = Parser[Seq[(ScopedKey[Any], Seq[String])]] @@ -283,26 +280,15 @@ object Act { def toAxis[T](opt: Option[T], ifNone: ScopeAxis[T]): ScopeAxis[T] = opt match { case Some(t) => Select(t); case None => ifNone } - def config(confs: Set[String]): Parser[ParsedAxis[String]] = { - val sep = ':' !!! "Expected ':' (if selecting a configuration)" - token( - (ZeroString ^^^ ParsedZero | value(examples(ID, confs, "configuration"))) <~ sep - ) ?? Omitted - } - // New configuration parser that's able to parse configuration ident trailed by slash. private[sbt] def configIdent( confs: Set[String], idents: Set[String], fromIdent: String => String ): Parser[(ParsedAxis[String], Seq[String])] = { - val oldSep: Parser[Char] = ':' val sep: Parser[Unit] = spacedSlash !!! "Expected '/'" token( - ((ZeroString ^^^ (ParsedZero -> colonSeq)) <~ oldSep) - | ((ZeroString ^^^ (ParsedZero -> slashSeq)) <~ sep) - | ((ZeroIdent ^^^ (ParsedZero -> slashSeq)) <~ sep) - | (value(examples(ID, confs, "configuration")).map(_ -> colonSeq) <~ oldSep) + ((ZeroIdent ^^^ (ParsedZero -> slashSeq)) <~ sep) | (value(examples(CapitalizedID, idents, "configuration ident").map(fromIdent)) .map(_ -> slashSeq) <~ sep) ) ?? (Omitted -> Nil) @@ -399,16 +385,10 @@ object Act { val suggested = normKeys.map(_._1).toSet val keyP = filterStrings(examples(ID, suggested, "key"), valid.keySet, "key").map(valid) - ((token( + (token( value(keyP).map(_ -> slashSeq) - | ZeroString ^^^ (ParsedZero -> slashSeq) | ZeroIdent ^^^ (ParsedZero -> slashSeq) - ) <~ spacedSlash) | - (token( - value(keyP).map(_ -> colonColonSeq) - | ZeroString ^^^ (ParsedZero -> colonColonSeq) - | ZeroIdent ^^^ (ParsedZero -> colonColonSeq) - ) <~ token("::".id))) ?? (Omitted -> Nil) + ) <~ spacedSlash) ?? (Omitted -> Nil) } def resolveTask(task: ParsedAxis[AttributeKey[_]]): Option[AttributeKey[_]] = @@ -452,11 +432,10 @@ object Act { } def projectRef(index: KeyIndex, currentBuild: URI): Parser[ParsedAxis[ResolvedReference]] = { - val global = token(ZeroString ~ spacedSlash) ^^^ ParsedZero val zeroIdent = token(ZeroIdent ~ spacedSlash) ^^^ ParsedZero val thisBuildIdent = value(token(ThisBuildIdent ~ spacedSlash) ^^^ BuildRef(currentBuild)) val trailing = spacedSlash !!! "Expected '/' (if selecting a project)" - global | zeroIdent | thisBuildIdent | + zeroIdent | thisBuildIdent | value(resolvedReferenceIdent(index, currentBuild, trailing)) | value(resolvedReference(index, currentBuild, trailing)) } diff --git a/main/src/main/scala/sbt/internal/BuildUtil.scala b/main/src/main/scala/sbt/internal/BuildUtil.scala index 30344b0a1..1cbab6e24 100644 --- a/main/src/main/scala/sbt/internal/BuildUtil.scala +++ b/main/src/main/scala/sbt/internal/BuildUtil.scala @@ -94,6 +94,7 @@ object BuildUtil { ("import _root_.scala.xml.{TopScope=>$scope}" :: "import _root_.sbt.*" :: "import _root_.sbt.given" + :: "import _root_.sbt.BareBuildSyntax.*" :: "import _root_.sbt.Keys.*" :: "import _root_.sbt.nio.Keys.*" :: Nil) diff --git a/main/src/main/scala/sbt/internal/ClasspathImpl.scala b/main/src/main/scala/sbt/internal/ClasspathImpl.scala index 5fbd145e9..74b5f066d 100644 --- a/main/src/main/scala/sbt/internal/ClasspathImpl.scala +++ b/main/src/main/scala/sbt/internal/ClasspathImpl.scala @@ -43,7 +43,7 @@ private[sbt] object ClasspathImpl { val xs = products.map(_ -> analysis) for (f, analysis) <- xs yield APIMappings - .store(analyzed(f, analysisFile), apiURL.value) + .store(Classpaths.analyzed(f, analysisFile), apiURL.value) .put(Keys.moduleIDStr, Classpaths.moduleIdJsonKeyFormat.write(module)) .put(Keys.configurationStr, config.name) else exportedProducts.value @@ -57,7 +57,7 @@ private[sbt] object ClasspathImpl { val config = configuration.value for (f, analysis) <- trackedExportedProductsImplTask(track).value yield APIMappings - .store(analyzed(f, analysis), apiURL.value) + .store(Classpaths.analyzed(f, analysis), apiURL.value) .put(Keys.artifactStr, RemoteCache.artifactToStr(art)) .put(Keys.moduleIDStr, Classpaths.moduleIdJsonKeyFormat.write(module)) .put(Keys.configurationStr, config.name) @@ -71,7 +71,7 @@ private[sbt] object ClasspathImpl { val config = configuration.value for (f, analysis) <- trackedJarProductsImplTask(track).value yield APIMappings - .store(analyzed(f, analysis), apiURL.value) + .store(Classpaths.analyzed(f, analysis), apiURL.value) .put(Keys.artifactStr, RemoteCache.artifactToStr(art)) .put(Keys.moduleIDStr, Classpaths.moduleIdJsonKeyFormat.write(module)) .put(Keys.configurationStr, config.name) @@ -344,9 +344,6 @@ private[sbt] object ClasspathImpl { (tasks.toSeq.join).map(_.flatten.distinct) } - def analyzed[A](data: A, analysisFile: VirtualFile): Attributed[A] = - Attributed.blank(data).put(Keys.analysis, analysisFile.id) - def interSort( projectRef: ProjectRef, conf: Configuration, diff --git a/main/src/main/scala/sbt/internal/CommandStrings.scala b/main/src/main/scala/sbt/internal/CommandStrings.scala index e4996e6ec..3b72c3257 100644 --- a/main/src/main/scala/sbt/internal/CommandStrings.scala +++ b/main/src/main/scala/sbt/internal/CommandStrings.scala @@ -82,7 +82,7 @@ $PrintCommand Displays lines from the logging of previous commands that match `pattern`. $LastGrepCommand [key] - Displays lines from logging associated with `key` that match `pattern`. The key typically refers to a task (for example, test:compile). The logging that is displayed is restricted to the logging for that particular task. + Displays lines from logging associated with `key` that match `pattern`. The key typically refers to a task (for example, Test/compile). The logging that is displayed is restricted to the logging for that particular task. is a regular expression interpreted by java.util.Pattern. Matching text is highlighted (when highlighting is supported and enabled). See also '$LastCommand'.""" @@ -94,7 +94,7 @@ $LastGrepCommand [key] Prints the logging for the previous command, typically at a more verbose level. $LastCommand - Prints the logging associated with the provided key. The key typically refers to a task (for example, test:compile). The logging that is displayed is restricted to the logging for that particular task. + Prints the logging associated with the provided key. The key typically refers to a task (for example, Test/compile). The logging that is displayed is restricted to the logging for that particular task. See also '$LastGrepCommand'.""" diff --git a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala index fffa06be9..df65d95a2 100644 --- a/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala +++ b/main/src/main/scala/sbt/internal/server/BuildServerProtocol.scala @@ -11,8 +11,8 @@ package internal package server import java.net.URI +import sbt.BuildExtra.* import sbt.BuildPaths.{ configurationSources, projectStandard } -import sbt.BuildSyntax._ import sbt.Def._ import sbt.Keys._ import sbt.Project._ diff --git a/main/src/main/scala/sbt/internal/server/SettingQuery.scala b/main/src/main/scala/sbt/internal/server/SettingQuery.scala index b768eddd3..d52bb2df4 100644 --- a/main/src/main/scala/sbt/internal/server/SettingQuery.scala +++ b/main/src/main/scala/sbt/internal/server/SettingQuery.scala @@ -36,7 +36,7 @@ object SettingQuery { index: KeyIndex, currentBuild: URI ): Parser[ParsedExplicitAxis[ResolvedReference]] = { - val global = token(Act.ZeroString ~ '/') ^^^ ParsedExplicitGlobal + val global = token(Act.GlobalIdent ~ '/') ^^^ ParsedExplicitGlobal val trailing = '/' !!! "Expected '/' (if selecting a project)" global | explicitValue(Act.resolvedReference(index, currentBuild, trailing)) } @@ -56,7 +56,12 @@ object SettingQuery { for { rawProject <- projectRef(index, currentBuild) proj = resolveProject(rawProject) - confAmb <- Act.config(index configs proj) + confPair <- Act.configIdent( + index.configs(proj), + index.configIdents(proj), + index.fromConfigIdent(proj) + ) + (confAmb, seps) = confPair partialMask = ScopeMask(true, confAmb.isExplicit, false, false) } yield Act.taskKeyExtra(index, defaultConfigs, keyMap, proj, confAmb, partialMask, Nil) } diff --git a/main/src/main/scala/sbt/nio/Keys.scala b/main/src/main/scala/sbt/nio/Keys.scala index a851448ca..168996fa9 100644 --- a/main/src/main/scala/sbt/nio/Keys.scala +++ b/main/src/main/scala/sbt/nio/Keys.scala @@ -12,7 +12,7 @@ import java.io.InputStream import java.nio.file.Path import java.util.concurrent.atomic.AtomicBoolean -import sbt.BuildSyntax.{ settingKey, taskKey } +import sbt.Def.{ settingKey, taskKey } import sbt.KeyRanks.{ BMinusSetting, DSetting, Invisible } import sbt.internal.DynamicInput import sbt.internal.nio.FileTreeRepository diff --git a/main/src/main/scala/sbt/plugins/DependencyTreeKeys.scala b/main/src/main/scala/sbt/plugins/DependencyTreeKeys.scala index 71ea74c5c..c010c85df 100644 --- a/main/src/main/scala/sbt/plugins/DependencyTreeKeys.scala +++ b/main/src/main/scala/sbt/plugins/DependencyTreeKeys.scala @@ -12,7 +12,7 @@ package plugins import java.io.File import java.net.URI import sbt.internal.graph._ -import sbt.BuildSyntax._ +import sbt.Def._ import sbt.librarymanagement.{ ModuleID, UpdateReport } trait MiniDependencyTreeKeys { diff --git a/main/src/main/scala/sbt/plugins/SbtPlugin.scala b/main/src/main/scala/sbt/plugins/SbtPlugin.scala index c38d34b76..a37cd8b6f 100644 --- a/main/src/main/scala/sbt/plugins/SbtPlugin.scala +++ b/main/src/main/scala/sbt/plugins/SbtPlugin.scala @@ -10,12 +10,19 @@ package sbt package plugins import sbt.Def.Setting -import sbt.Keys._ +import sbt.Keys.* +import sbt.SlashSyntax0.* -object SbtPlugin extends AutoPlugin { +object SbtPlugin extends AutoPlugin: override def requires = ScriptedPlugin override lazy val projectSettings: Seq[Setting[_]] = Seq( - sbtPlugin := true + sbtPlugin := true, + pluginCrossBuild / sbtVersion := { + scalaBinaryVersion.value match + case "3" => sbtVersion.value + case "2.12" => "1.5.8" + case "2.10" => "0.13.18" + }, ) -} +end SbtPlugin diff --git a/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala b/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala index 453754a0a..f9d8548cb 100644 --- a/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala +++ b/main/src/main/scala/sbt/plugins/SemanticdbPlugin.scala @@ -39,7 +39,7 @@ object SemanticdbPlugin extends AutoPlugin { val sdb = semanticdbEnabled.value val m = semanticdbCompilerPlugin.value val sv = scalaVersion.value - if (sdb && !ScalaInstance.isDotty(sv)) List(Build0.compilerPlugin(m)) + if (sdb && !ScalaInstance.isDotty(sv)) List(BuildExtra.compilerPlugin(m)) else Nil }, semanticdbOptions += { diff --git a/main/src/test/scala/ProjectMacro.scala b/main/src/test/scala/ProjectMacro.scala index 0c35b7e35..3f47153c0 100644 --- a/main/src/test/scala/ProjectMacro.scala +++ b/main/src/test/scala/ProjectMacro.scala @@ -11,7 +11,7 @@ package sbt import scala.util.control.NonFatal import org.scalacheck._ import Prop._ -import sbt.BuildSyntax.project +import sbt.BuildExtra.project import java.io.File class ProjectDefs { diff --git a/sbt-app/src/main/scala/package.scala b/sbt-app/src/main/scala/package.scala index c7c25051a..2408e465b 100644 --- a/sbt-app/src/main/scala/package.scala +++ b/sbt-app/src/main/scala/package.scala @@ -23,9 +23,8 @@ package object sbt with sbt.librarymanagement.DependencyFilterExtra with sbt.librarymanagement.LibraryManagementSyntax with sbt.BuildExtra - with sbt.TaskMacroExtra - with sbt.ScopeFilter.Make with sbt.BuildSyntax + with sbt.ScopeFilter.Make with sbt.OptionSyntax with sbt.SlashSyntax with sbt.Import: diff --git a/sbt-app/src/main/scala/sbt/Import.scala b/sbt-app/src/main/scala/sbt/Import.scala index bd0d4d0f4..669732047 100644 --- a/sbt-app/src/main/scala/sbt/Import.scala +++ b/sbt-app/src/main/scala/sbt/Import.scala @@ -29,7 +29,10 @@ trait Import { val CustomOutput = sbt.OutputStrategy.CustomOutput val AllRequirements = sbt.PluginTrigger.AllRequirements val NoTrigger = sbt.PluginTrigger.NoTrigger - + val ClasspathDependency = ClasspathDep.ClasspathDependency + type ClasspathDependency = ClasspathDep.ClasspathDependency + val ResolvedClasspathDependency = ClasspathDep.ResolvedClasspathDependency + type ResolvedClasspathDependency = ClasspathDep.ResolvedClasspathDependency // sbt.testing type TestResult = sbt.protocol.testing.TestResult val TestResult = sbt.protocol.testing.TestResult @@ -197,6 +200,8 @@ trait Import { type SimpleReader = sbt.internal.util.SimpleReader type SourcePosition = sbt.internal.util.SourcePosition val StackTrace = sbt.internal.util.StackTrace + val StringAttributeKey = sbt.internal.util.StringAttributeKey + type StringAttributeKey = sbt.internal.util.StringAttributeKey type SuppressedTraceContext = sbt.internal.util.SuppressedTraceContext type TranslatedException = sbt.internal.util.TranslatedException type TranslatedIOException = sbt.internal.util.TranslatedIOException diff --git a/sbt-app/src/sbt-test/actions/previous/test b/sbt-app/src/sbt-test/actions/previous/test index ebee855a7..4593dbd51 100644 --- a/sbt-app/src/sbt-test/actions/previous/test +++ b/sbt-app/src/sbt-test/actions/previous/test @@ -6,5 +6,5 @@ > checkNext 1 2 > checkScopes 0 0 -> all x compile:y::x runtime:y::x y +> all x Compile/y/x Runtime/y/x y > checkScopes 21 91 \ No newline at end of file diff --git a/sbt-app/src/sbt-test/compiler-project/run-test/build.sbt b/sbt-app/src/sbt-test/compiler-project/run-test/build.sbt index 910d61c97..6f986f803 100644 --- a/sbt-app/src/sbt-test/compiler-project/run-test/build.sbt +++ b/sbt-app/src/sbt-test/compiler-project/run-test/build.sbt @@ -1,9 +1,7 @@ -ThisBuild / scalaVersion := "2.12.19" - +scalaVersion := "2.12.19" libraryDependencies ++= Seq( "com.novocode" % "junit-interface" % "0.5" % Test, "junit" % "junit" % "4.13.1" % Test, "commons-io" % "commons-io" % "2.5" % Runtime, ) - libraryDependencies += scalaVersion("org.scala-lang" % "scala-compiler" % _ ).value diff --git a/sbt-app/src/sbt-test/compiler-project/run-test/src/test/scala/Basic.scala b/sbt-app/src/sbt-test/compiler-project/run-test/src/test/scala/Basic.scala index 8f26f73a4..cecbc9e2d 100644 --- a/sbt-app/src/sbt-test/compiler-project/run-test/src/test/scala/Basic.scala +++ b/sbt-app/src/sbt-test/compiler-project/run-test/src/test/scala/Basic.scala @@ -3,13 +3,11 @@ package foo.bar import org.junit._ import org.junit.Assert._ -class Basic -{ - val foo = new Foo - @Test - def checkBind(): Unit = - { - try { assertTrue( foo.eval("3") == 3) } - catch { case e => e.printStackTrace; throw e} - } +class Basic { + val foo = new Foo + @Test + def checkBind(): Unit = { + try { assertTrue( foo.eval("3") == 3) } + catch { case e => e.printStackTrace; throw e} + } } diff --git a/sbt-app/src/sbt-test/compiler-project/run-test/test b/sbt-app/src/sbt-test/compiler-project/run-test/test index 9988b8016..d8f76a3d6 100644 --- a/sbt-app/src/sbt-test/compiler-project/run-test/test +++ b/sbt-app/src/sbt-test/compiler-project/run-test/test @@ -1,10 +1,10 @@ > run 1 -> test:test +> test > clean > run 2 -> test:test +> test > clean > run -1 -> test:test \ No newline at end of file +> test \ No newline at end of file diff --git a/sbt-app/src/sbt-test/dependency-management/cache-classifiers/test b/sbt-app/src/sbt-test/dependency-management/cache-classifiers/test index 6c538db38..cc06d54c4 100644 --- a/sbt-app/src/sbt-test/dependency-management/cache-classifiers/test +++ b/sbt-app/src/sbt-test/dependency-management/cache-classifiers/test @@ -1,7 +1,7 @@ > a/publish $ copy-file changes/B.scala b/B.scala --> b/test:compile +-> b/Test/compile # Need to sleep 3s because the check depends on last modified time and typical resolution is 1s. $ sleep 3000 @@ -9,4 +9,4 @@ $ sleep 3000 $ copy-file changes/A.scala a/src/test/scala/A.scala > a/publish -> b/test:compile +> b/Test/compile diff --git a/sbt-app/src/sbt-test/dependency-management/ext-pom-classifier/test b/sbt-app/src/sbt-test/dependency-management/ext-pom-classifier/test index 49047044e..df98bfb9b 100644 --- a/sbt-app/src/sbt-test/dependency-management/ext-pom-classifier/test +++ b/sbt-app/src/sbt-test/dependency-management/ext-pom-classifier/test @@ -1,3 +1,3 @@ -> export compile:dependencyClasspath -> export test:dependencyClasspath -> test:compile +> export Compile/dependencyClasspath +> export Test/dependencyClasspath +> Test/compile diff --git a/sbt-app/src/sbt-test/dependency-management/ivy-settings-a/disabled b/sbt-app/src/sbt-test/dependency-management/ivy-settings-a/disabled index d7b5b2289..99669ebe0 100644 --- a/sbt-app/src/sbt-test/dependency-management/ivy-settings-a/disabled +++ b/sbt-app/src/sbt-test/dependency-management/ivy-settings-a/disabled @@ -8,4 +8,4 @@ $ copy-file changes/scalacheck-ivy.xml ivy.xml $ copy-file changes/scala-tools-ivysettings.xml ivysettings.xml > check -> test:compile +> Test/compile diff --git a/sbt-app/src/sbt-test/project-matrix/plugin/build.sbt b/sbt-app/src/sbt-test/project-matrix/plugin/build.sbt new file mode 100644 index 000000000..ad99d07fd --- /dev/null +++ b/sbt-app/src/sbt-test/project-matrix/plugin/build.sbt @@ -0,0 +1,28 @@ +val scala3 = "3.3.3" +val scala212 = "2.12.19" + +organization := "com.example" +version := "0.1.0-SNAPSHOT" + +lazy val checkSbt2Plugin = taskKey[Unit]("") + +lazy val plugin = (projectMatrix in file("plugin")) + .enablePlugins(SbtPlugin) + .settings( + organization := "com.example", + name := "sbt-example", + // TODO: Once 2.0 is released we can move this check to the `test` file + checkSbt2Plugin := { + val repo = (ThisBuild / baseDirectory).value / "repo" + val sbtV = sbtBinaryVersion.value + val expected = (repo / "com" / "example" / + s"sbt-example_sbt${sbtV}_3" / + "0.1.0-SNAPSHOT" / + s"sbt-example_sbt${sbtV}_3-0.1.0-SNAPSHOT.pom") + assert(expected.exists, s"$expected did not exist") + }, + ) + .jvmPlatform(scalaVersions = Seq(scala3, scala212)) + +publishMavenStyle := true +publishTo := Some(Resolver.file("test-publish", (ThisBuild / baseDirectory).value / "repo/")) diff --git a/sbt-app/src/sbt-test/project-matrix/plugin/test b/sbt-app/src/sbt-test/project-matrix/plugin/test new file mode 100644 index 000000000..c478cd9e0 --- /dev/null +++ b/sbt-app/src/sbt-test/project-matrix/plugin/test @@ -0,0 +1,8 @@ +> compile + +> publish + +$ exists repo/com/example/sbt-example_2.12_1.0/0.1.0-SNAPSHOT/sbt-example_2.12_1.0-0.1.0-SNAPSHOT.pom +$ absent repo/com/example/sbt-example_2.12_1.0/0.1.0-SNAPSHOT/sbt-example-0.1.0-SNAPSHOT.pom + +> checkSbt2Plugin diff --git a/sbt-app/src/sbt-test/project1/cross-plugins-source/test b/sbt-app/src/sbt-test/project1/cross-plugins-source/test index f3f14e7b2..6b1226d2c 100644 --- a/sbt-app/src/sbt-test/project1/cross-plugins-source/test +++ b/sbt-app/src/sbt-test/project1/cross-plugins-source/test @@ -1,3 +1,3 @@ > show pluginCrossBuild::sbtDependency > compile --> test:compile +-> Test/compile diff --git a/sbt-app/src/sbt-test/project1/flatten/test b/sbt-app/src/sbt-test/project1/flatten/test index 842d12a01..6ab62ce67 100644 --- a/sbt-app/src/sbt-test/project1/flatten/test +++ b/sbt-app/src/sbt-test/project1/flatten/test @@ -3,20 +3,20 @@ > compile > test -> test:run +> Test/run # This part verifies that the package-src action works properly under a flattened/merged source hierarchy > packageSrc -> test:packageSrc +> Test/packageSrc $ delete src $ delete test-src --> test:run +-> Test/run > unpackage -> test:unpackage +> Test/unpackage -> test:test -> test:run +> Test/test +> Test/run diff --git a/sbt-app/src/sbt-test/project1/semanticdb/test b/sbt-app/src/sbt-test/project1/semanticdb/test index 4d242e8e1..754edf028 100644 --- a/sbt-app/src/sbt-test/project1/semanticdb/test +++ b/sbt-app/src/sbt-test/project1/semanticdb/test @@ -1,16 +1,16 @@ > compile $ exists target/scala-2.12/classes/META-INF/semanticdb/src/main/scala/foo/Compile.scala.semanticdb -> test:compile +> Test/compile $ exists target/scala-2.12/test-classes/META-INF/semanticdb/src/test/scala/foo/Test.scala.semanticdb -> it:compile +> IntegrationTest/compile $ exists target/scala-2.12/it-classes/META-INF/semanticdb/src/it/scala/foo/IntegrationTest.scala.semanticdb -> custom:compile +> Custom/compile $ exists target/scala-2.12/custom-classes/META-INF/semanticdb/src/custom/scala/foo/Custom.scala.semanticdb -> st:compile +> SystemTest/compile $ exists target/scala-2.12/st-classes/META-INF/semanticdb/src/st/scala/foo/SystemTest.scala.semanticdb > check diff --git a/sbt-app/src/sbt-test/tests/arguments/test b/sbt-app/src/sbt-test/tests/arguments/test index 1058dceb3..67f2423c0 100644 --- a/sbt-app/src/sbt-test/tests/arguments/test +++ b/sbt-app/src/sbt-test/tests/arguments/test @@ -1,4 +1,4 @@ -# should fail because it should run all test:tests, some of which are expected to fail (1 and 4) +# should fail because it should run all tests, some of which are expected to fail (1 and 4) -> testQuick $ touch success1 diff --git a/sbt-app/src/sbt-test/tests/it/test b/sbt-app/src/sbt-test/tests/it/test index c313c9831..75ee6ffe5 100644 --- a/sbt-app/src/sbt-test/tests/it/test +++ b/sbt-app/src/sbt-test/tests/it/test @@ -1,28 +1,27 @@ > clean $ delete src/ $ copy-file changes/ClassFailModuleSuccess.scala src/it/scala/Test.scala --> it:test +-> IntegrationTest/test > clean $ delete src/ $ copy-file changes/ClassFailModuleFail.scala src/it/scala/Test.scala --> it:test +-> IntegrationTest/test > clean $ delete src/ $ copy-file changes/ClassSuccessModuleFail.scala src/it/scala/Test.scala --> it:test +-> IntegrationTest/test > clean $ delete src/ $ copy-file changes/ClassSuccessModuleSuccess.scala src/it/scala/Test.scala -> it:test +> IntegrationTest/test # verify that a failing normal test fails when run directly $ copy-file changes/AlwaysFail.scala src/test/scala/AlwaysFail.scala --> test:test - -# but that it does not affect the result of it:test (#539) -> it:test +-> Test/test +# but that it does not affect the result of IntegrationTest/test (#539) +> IntegrationTest/test diff --git a/sbt-app/src/sbt-test/tests/resources/build.sbt b/sbt-app/src/sbt-test/tests/resources/build.sbt index e6997605a..9f528a540 100644 --- a/sbt-app/src/sbt-test/tests/resources/build.sbt +++ b/sbt-app/src/sbt-test/tests/resources/build.sbt @@ -1,3 +1,3 @@ +scalaVersion := "2.12.19" val specs = "org.specs2" %% "specs2-core" % "4.3.4" -ThisBuild / scalaVersion := "2.12.19" libraryDependencies += specs % Test diff --git a/sbt-app/src/sbt-test/tests/resources/test b/sbt-app/src/sbt-test/tests/resources/test index 7c6f9c539..a270b7b48 100644 --- a/sbt-app/src/sbt-test/tests/resources/test +++ b/sbt-app/src/sbt-test/tests/resources/test @@ -1 +1 @@ -> test:test \ No newline at end of file +> test \ No newline at end of file diff --git a/sbt-app/src/sbt-test/tests/test-quick/build.sbt b/sbt-app/src/sbt-test/tests/test-quick/build.sbt index c30aa0fc2..60d36d64b 100644 --- a/sbt-app/src/sbt-test/tests/test-quick/build.sbt +++ b/sbt-app/src/sbt-test/tests/test-quick/build.sbt @@ -1,7 +1,7 @@ Global / cacheStores := Seq.empty val scalatest = "org.scalatest" %% "scalatest" % "3.0.5" -ThisBuild / scalaVersion := "2.12.19" +scalaVersion := "2.12.19" lazy val root = (project in file(".")) .settings( diff --git a/sbt-app/src/sbt-test/tests/test-quick/test b/sbt-app/src/sbt-test/tests/test-quick/test index c86f0276f..4db0b2828 100644 --- a/sbt-app/src/sbt-test/tests/test-quick/test +++ b/sbt-app/src/sbt-test/tests/test-quick/test @@ -27,7 +27,7 @@ $ sleep 2000 # src/test compilation group change. $ copy-file changed/Base.scala src/test/scala/Base.scala -> test:compile +> Test/compile $ sleep 2000 -> testQuick Create > testQuick Delete diff --git a/server-test/src/test/scala/testpkg/ClientTest.scala b/server-test/src/test/scala/testpkg/ClientTest.scala index dcda788a7..e5a4a3c7d 100644 --- a/server-test/src/test/scala/testpkg/ClientTest.scala +++ b/server-test/src/test/scala/testpkg/ClientTest.scala @@ -112,7 +112,6 @@ class ClientTest extends AbstractServerTest { test("compi completions") { val expected = Vector( "compile", - "compile:", "compileAnalysisFile", "compileAnalysisFilename", "compileAnalysisTargetRoot", @@ -135,7 +134,6 @@ class ClientTest extends AbstractServerTest { val testOnlyExpected = Vector( "testOnly", "testOnly/", - "testOnly::", "testOnly;", ) assert(complete("testOnly") == testOnlyExpected) diff --git a/tasks-standard/src/main/scala/sbt/std/Streams.scala b/tasks-standard/src/main/scala/sbt/std/Streams.scala index 25fd67de5..84f0a1ea2 100644 --- a/tasks-standard/src/main/scala/sbt/std/Streams.scala +++ b/tasks-standard/src/main/scala/sbt/std/Streams.scala @@ -22,8 +22,8 @@ import sbt.util._ // no longer specific to Tasks, so 'TaskStreams' should be renamed /** * Represents a set of streams associated with a context. In sbt, this is a named set of streams for - * a particular scoped key. For example, logging for test:compile is by default sent to the "out" - * stream in the test:compile context. + * a particular scoped key. For example, logging for Test/compile is by default sent to the "out" + * stream in the Test/compile context. */ sealed trait TaskStreams[Key] {