mirror of https://github.com/sbt/sbt.git
Merge pull request #7486 from eed3si9n/wip/postfix
[2.x] Migrate postfix ops
This commit is contained in:
commit
652f7dc575
|
|
@ -393,8 +393,7 @@ object Index {
|
|||
case (k, xs) if xs.size > 1 => (k, xs)
|
||||
}
|
||||
.toVector
|
||||
if (duplicates.isEmpty)
|
||||
multiMap.collect { case (k, v) if validID(k) => (k, v.head) } toMap
|
||||
if duplicates.isEmpty then multiMap.collect { case (k, v) if validID(k) => (k, v.head) }.toMap
|
||||
else
|
||||
sys.error(
|
||||
duplicates map { case (k, tps) =>
|
||||
|
|
|
|||
|
|
@ -408,9 +408,11 @@ object Scope {
|
|||
projectInherit: ProjectRef => Seq[ProjectRef],
|
||||
configInherit: (ResolvedReference, ConfigKey) => Seq[ConfigKey]
|
||||
): DelegateIndex = {
|
||||
val pDelegates = refs map { case (ref, project) =>
|
||||
(ref, delegateIndex(ref, configurations(project))(projectInherit, configInherit))
|
||||
} toMap;
|
||||
val pDelegates = refs
|
||||
.map:
|
||||
case (ref, project) =>
|
||||
(ref, delegateIndex(ref, configurations(project))(projectInherit, configInherit))
|
||||
.toMap
|
||||
new DelegateIndex0(pDelegates)
|
||||
}
|
||||
private[this] def delegateIndex(ref: ProjectRef, confs: Seq[ConfigKey])(
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ object Cross {
|
|||
private def crossRestoreSessionParser: Parser[String] = token(CrossRestoreSessionCommand)
|
||||
|
||||
private[sbt] def requireSession[T](p: State => Parser[T]): State => Parser[T] =
|
||||
s => if (s get sessionSettings isEmpty) failure("No project loaded") else p(s)
|
||||
s => if s.get(sessionSettings).isEmpty then failure("No project loaded") else p(s)
|
||||
|
||||
private def resolveAggregates(extracted: Extracted): Seq[ProjectRef] = {
|
||||
|
||||
|
|
|
|||
|
|
@ -2944,8 +2944,8 @@ object Classpaths {
|
|||
unmanagedJars := findUnmanagedJars(
|
||||
configuration.value,
|
||||
unmanagedBase.value,
|
||||
(unmanagedJars / includeFilter) value,
|
||||
(unmanagedJars / excludeFilter) value,
|
||||
(unmanagedJars / includeFilter).value,
|
||||
(unmanagedJars / excludeFilter).value,
|
||||
fileConverter.value,
|
||||
)
|
||||
).map(exportVirtualClasspath) ++ Seq(
|
||||
|
|
@ -3606,7 +3606,7 @@ object Classpaths {
|
|||
|
||||
private[sbt] def defaultProjectID: Initialize[ModuleID] = Def.setting {
|
||||
val p0 = ModuleID(organization.value, moduleName.value, version.value)
|
||||
.cross((projectID / crossVersion) value)
|
||||
.cross((projectID / crossVersion).value)
|
||||
.artifacts(artifacts.value: _*)
|
||||
val p1 = apiURL.value match {
|
||||
case Some(u) => p0.extra(SbtPomExtraProperties.POM_API_KEY -> u.toExternalForm)
|
||||
|
|
@ -4227,7 +4227,7 @@ object Classpaths {
|
|||
(proj / ivyModule).get(data)
|
||||
}.join
|
||||
ivyModules.mapN { mod =>
|
||||
mod map { _.dependencyMapping(log) } toMap;
|
||||
mod.map { _.dependencyMapping(log) }.toMap
|
||||
}
|
||||
|
||||
def projectResolverTask: Initialize[Task[Resolver]] =
|
||||
|
|
|
|||
|
|
@ -304,11 +304,11 @@ trait ProjectExtra extends Scoped.Syntax:
|
|||
val msg = (ref / Keys.onLoadMessage) get structure.data getOrElse ""
|
||||
if (!msg.isEmpty) s.log.info(msg)
|
||||
def get[T](k: SettingKey[T]): Option[T] = (ref / k) get structure.data
|
||||
def commandsIn(axis: ResolvedReference) = (axis / commands) get structure.data toList
|
||||
def commandsIn(axis: ResolvedReference) = (axis / commands).get(structure.data).toList
|
||||
|
||||
val allCommands = commandsIn(ref) ++ commandsIn(
|
||||
BuildRef(ref.build)
|
||||
) ++ ((Global / commands) get structure.data toList)
|
||||
) ++ (Global / commands).get(structure.data).toList
|
||||
val history = get(historyPath).flatMap(identity)
|
||||
val prompt = get(shellPrompt)
|
||||
val newPrompt = get(colorShellPrompt)
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ object Resolvers {
|
|||
if (Util.isNonCygwinWindows) "cmd" +: "/c" +: command
|
||||
else command,
|
||||
cwd
|
||||
) !;
|
||||
).!
|
||||
if (result != 0)
|
||||
sys.error("Nonzero exit code (" + result + "): " + command.mkString(" "))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ object ScriptedPlugin extends AutoPlugin {
|
|||
sys.props(org.apache.logging.log4j.util.LoaderUtil.IGNORE_TCCL_PROPERTY) = "true"
|
||||
|
||||
object autoImport {
|
||||
val ScriptedConf = Configurations.config("scripted-sbt") hide
|
||||
val ScriptedLaunchConf = Configurations.config("scripted-sbt-launch") hide
|
||||
val ScriptedConf = Configurations.config("scripted-sbt").hide
|
||||
val ScriptedLaunchConf = Configurations.config("scripted-sbt-launch").hide
|
||||
|
||||
val scriptedSbt = settingKey[String]("")
|
||||
val sbtLauncher = taskKey[File]("")
|
||||
|
|
|
|||
|
|
@ -596,7 +596,7 @@ object Act {
|
|||
else data.get(scope, key)
|
||||
|
||||
def requireSession[T](s: State, p: => Parser[T]): Parser[T] =
|
||||
if (s get sessionSettings isEmpty) failure("No project loaded") else p
|
||||
if s.get(sessionSettings).isEmpty then failure("No project loaded") else p
|
||||
|
||||
sealed trait ParsedAxis[+T] {
|
||||
final def isExplicit = this != Omitted
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ object Aggregation {
|
|||
|
||||
val extracted = Project extract s
|
||||
import extracted.structure
|
||||
val toRun = ts map { case KeyValue(k, t) => t.map(v => KeyValue(k, v)) } join;
|
||||
val roots = ts map { case KeyValue(k, _) => k }
|
||||
val toRun = ts.map { case KeyValue(k, t) => t.map(v => KeyValue(k, v)) }.join
|
||||
val roots = ts.map { case KeyValue(k, _) => k }
|
||||
val config = extractedTaskConfig(extracted, structure, s)
|
||||
|
||||
val start = System.currentTimeMillis
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ private[sbt] object ClasspathImpl {
|
|||
}
|
||||
|
||||
def union[A, B](maps: Seq[A => Seq[B]]): A => Seq[B] =
|
||||
a => maps.foldLeft(Seq[B]()) { _ ++ _(a) } distinct;
|
||||
a => maps.foldLeft(Seq[B]()) { _ ++ _(a) }.distinct
|
||||
|
||||
def parseList(s: String, allConfs: Seq[String]): Seq[String] =
|
||||
(trim(s split ",") flatMap replaceWildcard(allConfs)).distinct
|
||||
|
|
|
|||
|
|
@ -1466,9 +1466,10 @@ private[sbt] object Load {
|
|||
def initialSession(structure: BuildStructure, rootEval: () => Eval, s: State): SessionSettings = {
|
||||
val session = s get Keys.sessionSettings
|
||||
val currentProject = session map (_.currentProject) getOrElse Map.empty
|
||||
val currentBuild = session map (_.currentBuild) filter (uri =>
|
||||
structure.units.keys exists (uri ==)
|
||||
) getOrElse structure.root
|
||||
val currentBuild = session
|
||||
.map(_.currentBuild)
|
||||
.filter(uri => structure.units.keys.exists(uri == _))
|
||||
.getOrElse(structure.root)
|
||||
new SessionSettings(
|
||||
currentBuild,
|
||||
projectMap(structure, currentProject),
|
||||
|
|
|
|||
|
|
@ -183,9 +183,9 @@ object PluginDiscovery:
|
|||
|
||||
private[this] def incompatiblePlugins(data: PluginData, t: LinkageError): Nothing = {
|
||||
val evicted = data.report.toList.flatMap(_.configurations.flatMap(_.evicted))
|
||||
val evictedModules = evicted map { id =>
|
||||
val evictedModules = evicted.map { id =>
|
||||
(id.organization, id.name)
|
||||
} distinct;
|
||||
}.distinct
|
||||
val evictedStrings = evictedModules map { case (o, n) => o + ":" + n }
|
||||
val msgBase = "Binary incompatibility in plugins detected."
|
||||
val msgExtra =
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ private[sbt] object PluginsDebug {
|
|||
|
||||
private[this] def includeAll[T <: Basic](basic: Set[T]): Plugins = And(basic.toList)
|
||||
private[this] def excludeAll(plugins: Set[AutoPlugin]): Plugins =
|
||||
And(plugins map (p => Exclude(p)) toList)
|
||||
And(plugins.map(p => Exclude(p)).toList)
|
||||
|
||||
private[this] def excludes(bs: Seq[Basic]): Set[AutoPlugin] =
|
||||
bs.collect { case Exclude(b) => b }.toSet
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import sbt.ProjectExtra.{ extract, updateCurrent }
|
|||
|
||||
object ProjectNavigation {
|
||||
def command(s: State): Parser[() => State] =
|
||||
if (s get sessionSettings isEmpty) failure("No project loaded")
|
||||
if s.get(sessionSettings).isEmpty then failure("No project loaded")
|
||||
else (new ProjectNavigation(s)).command
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -866,8 +866,8 @@ object BuildServerProtocol {
|
|||
}
|
||||
}
|
||||
|
||||
private val jsonParser: Parser[JValue] = (Parsers.any *).map(_.mkString)
|
||||
.map(JsonParser.parseUnsafe)
|
||||
private val jsonParser: Parser[JValue] = (Parsers.any.*).map(_.mkString)
|
||||
.map(JsonParser.parseUnsafe)
|
||||
|
||||
private def bspRunTask: Def.Initialize[InputTask[Unit]] =
|
||||
Def.input((s: State) => jsonParser).flatMapTask { json =>
|
||||
|
|
|
|||
|
|
@ -189,9 +189,7 @@ abstract class TestBuild {
|
|||
}
|
||||
|
||||
def mapBy[K, T](s: Seq[T])(f: T => K): Map[K, T] =
|
||||
s map { t =>
|
||||
(f(t), t)
|
||||
} toMap;
|
||||
s.map(t => (f(t), t)).toMap
|
||||
|
||||
lazy val keysGen: Gen[TestKeys] =
|
||||
for {
|
||||
|
|
|
|||
|
|
@ -9,28 +9,28 @@ object HouseRulesPlugin extends AutoPlugin {
|
|||
|
||||
lazy val baseSettings: Seq[Def.Setting[_]] = Seq(
|
||||
scalacOptions ++= Seq("-encoding", "utf8"),
|
||||
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked", "-Xlint"),
|
||||
scalacOptions ++= Seq("-deprecation", "-feature", "-unchecked"),
|
||||
scalacOptions += "-language:higherKinds",
|
||||
scalacOptions += "-language:implicitConversions",
|
||||
scalacOptions ++= "-Xfuture".ifScala213OrMinus.value.toList,
|
||||
scalacOptions += "-Xlint",
|
||||
scalacOptions ++= "-Xlint".ifScala2.value.toList,
|
||||
// TODO: uncomment once we can build without warnings on Scala 3
|
||||
// scalacOptions ++= "-Xfatal-warnings"
|
||||
// .ifScala(v => {
|
||||
// .ifScala3x(_ => {
|
||||
// sys.props.get("sbt.build.fatal") match {
|
||||
// case Some(_) => java.lang.Boolean.getBoolean("sbt.build.fatal")
|
||||
// case _ => v == 12
|
||||
// case _ => true
|
||||
// }
|
||||
// })
|
||||
// .value
|
||||
// .toList,
|
||||
scalacOptions ++= "-Ykind-projector".ifScala3.value.toList,
|
||||
scalacOptions ++= "-Ysemanticdb".ifScala3.value.toList,
|
||||
scalacOptions ++= "-Yinline-warnings".ifScala211OrMinus.value.toList,
|
||||
scalacOptions ++= "-Yno-adapted-args".ifScala212OrMinus.value.toList,
|
||||
scalacOptions += "-Ywarn-dead-code",
|
||||
scalacOptions += "-Ywarn-numeric-widen",
|
||||
scalacOptions += "-Ywarn-value-discard",
|
||||
scalacOptions ++= "-Ywarn-unused-import".ifScala(v => 11 <= v && v <= 12).value.toList
|
||||
scalacOptions ++= "-Ywarn-dead-code".ifScala2.value.toList,
|
||||
scalacOptions ++= "-Ywarn-numeric-widen".ifScala2.value.toList,
|
||||
scalacOptions ++= "-Ywarn-value-discard".ifScala2.value.toList,
|
||||
scalacOptions ++= "-Ywarn-unused-import".ifScala2x(v => 11 <= v && v <= 12).value.toList
|
||||
) ++ Seq(Compile, Test).flatMap(c =>
|
||||
(c / console / scalacOptions) --= Seq("-Ywarn-unused-import", "-Xlint")
|
||||
)
|
||||
|
|
@ -38,14 +38,17 @@ object HouseRulesPlugin extends AutoPlugin {
|
|||
private def scalaPartV = Def setting (CrossVersion partialVersion scalaVersion.value)
|
||||
|
||||
private implicit final class AnyWithIfScala[A](val __x: A) {
|
||||
def ifScala(p: Long => Boolean) =
|
||||
Def setting (scalaPartV.value collect { case (2, y) if p(y) => __x })
|
||||
def ifScalaLte(v: Long) = ifScala(_ <= v)
|
||||
def ifScalaGte(v: Long) = ifScala(_ >= v)
|
||||
def ifScala2x(p: Long => Boolean) =
|
||||
Def.setting(scalaPartV.value collect { case (2, y) if p(y) => __x })
|
||||
def ifScala3x(p: Long => Boolean) =
|
||||
Def.setting(scalaPartV.value collect { case (3, y) if p(y) => __x })
|
||||
def ifScalaLte(v: Long) = ifScala2x(_ <= v)
|
||||
def ifScalaGte(v: Long) = ifScala2x(_ >= v)
|
||||
def ifScala211OrMinus = ifScalaLte(11)
|
||||
def ifScala211OrPlus = ifScalaGte(11)
|
||||
def ifScala212OrMinus = ifScalaLte(12)
|
||||
def ifScala213OrMinus = ifScalaLte(13)
|
||||
def ifScala2 = ifScala2x(_ => true)
|
||||
def ifScala3 = Def.setting(
|
||||
if (scalaBinaryVersion.value == "3") Seq(__x)
|
||||
else Nil
|
||||
|
|
|
|||
|
|
@ -26,14 +26,6 @@ object Util {
|
|||
)
|
||||
|
||||
lazy val baseScalacOptions = Seq(
|
||||
scalacOptions ++= Seq(
|
||||
"-Xelide-below",
|
||||
"0",
|
||||
"-language:existentials",
|
||||
"-language:postfixOps",
|
||||
"-Yrangepos",
|
||||
"-Wconf:cat=unused-nowarn:s",
|
||||
),
|
||||
Compile / doc / scalacOptions -= "-Xlint",
|
||||
Compile / doc / scalacOptions -= "-Xfatal-warnings",
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue