From 56d2a0549be066de1f9dfce638716caf753c965a Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Sat, 5 Oct 2024 17:34:14 +0900 Subject: [PATCH] prepare Scala 3 --- src/main/scala/Compat.scala | 2 +- src/main/scala/ReleaseExtra.scala | 24 ++++++++++++------------ src/main/scala/ReleasePlugin.scala | 18 +++++++++--------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/main/scala/Compat.scala b/src/main/scala/Compat.scala index 670b310..aa998fe 100644 --- a/src/main/scala/Compat.scala +++ b/src/main/scala/Compat.scala @@ -72,7 +72,7 @@ object Compat { } type Command = sbt.Exec - implicit def command2String(command: Command) = command.commandLine + implicit def command2String(command: Command): String = command.commandLine implicit def string2Exex(s: String): Command = sbt.Exec(s, None, None) // type aliases diff --git a/src/main/scala/ReleaseExtra.scala b/src/main/scala/ReleaseExtra.scala index 61dff38..d0739f4 100644 --- a/src/main/scala/ReleaseExtra.scala +++ b/src/main/scala/ReleaseExtra.scala @@ -12,7 +12,7 @@ import sys.process.ProcessLogger object ReleaseStateTransformations { import Utilities._ - lazy val checkSnapshotDependencies: ReleaseStep = ReleaseStep({ st: State => + lazy val checkSnapshotDependencies: ReleaseStep = ReleaseStep({ (st: State) => val thisRef = st.extract.get(thisProjectRef) val (newSt, result) = Compat.runTaskAggregated(thisRef / releaseSnapshotDependencies, st) val snapshotDeps = result match { @@ -31,7 +31,7 @@ object ReleaseStateTransformations { }, enableCrossBuild = true) - lazy val inquireVersions: ReleaseStep = { st: State => + lazy val inquireVersions: ReleaseStep = { (st: State) => val extracted = Project.extract(st) @@ -56,7 +56,7 @@ object ReleaseStateTransformations { lazy val runClean : ReleaseStep = ReleaseStep( - action = { st: State => + action = { (st: State) => val extracted = Project.extract(st) val ref = extracted.get(thisProjectRef) extracted.runAggregated(ref / (Global / clean), st) @@ -65,7 +65,7 @@ object ReleaseStateTransformations { lazy val runTest: ReleaseStep = ReleaseStep( - action = { st: State => + action = { (st: State) => if (!st.get(skipTests).getOrElse(false)) { val extracted = Project.extract(st) val ref = extracted.get(thisProjectRef) @@ -80,7 +80,7 @@ object ReleaseStateTransformations { val globalVersionString = "ThisBuild / version := \"%s\"" private[this] val globalVersionStringOldSyntax = "version in ThisBuild := \"%s\"" val versionString = "version := \"%s\"" - private[sbtrelease] def setVersion(selectVersion: Versions => String): ReleaseStep = { st: State => + private[sbtrelease] def setVersion(selectVersion: Versions => String): ReleaseStep = { (st: State) => val vs = st.get(versions).getOrElse(sys.error("No versions are set! Was this release part executed before inquireVersions?")) val selected = selectVersion(vs) @@ -117,7 +117,7 @@ object ReleaseStateTransformations { IO.writeLines(file, Seq(versionString)) } - private[sbtrelease] lazy val initialVcsChecks = { st: State => + private[sbtrelease] lazy val initialVcsChecks = { (st: State) => val extracted = Project.extract( st ) val hasUntrackedFiles = vcs(st).hasUntrackedFiles @@ -147,7 +147,7 @@ object ReleaseStateTransformations { } lazy val commitReleaseVersion = ReleaseStep(commitReleaseVersionAction, initialVcsChecks) - private[sbtrelease] lazy val commitReleaseVersionAction = { st: State => + private[sbtrelease] lazy val commitReleaseVersionAction = { (st: State) => val newState = commitVersion(st, releaseCommitMessage) reapply(Seq[Setting[_]]( packageOptions += ManifestAttributes( @@ -156,7 +156,7 @@ object ReleaseStateTransformations { ), newState) } - lazy val commitNextVersion = {st: State => commitVersion(st, releaseNextCommitMessage)} + lazy val commitNextVersion = { (st: State) => commitVersion(st, releaseNextCommitMessage)} private[sbtrelease] def commitVersion = { (st: State, commitMessage: TaskKey[String]) => val log = toProcessLogger(st) @@ -180,7 +180,7 @@ object ReleaseStateTransformations { newState } - lazy val tagRelease: ReleaseStep = { st: State => + lazy val tagRelease: ReleaseStep = { (st: State) => val defaultChoice = st.get(tagDefault) match { case Some(Some(td)) => Some(td) @@ -229,7 +229,7 @@ object ReleaseStateTransformations { } lazy val pushChanges: ReleaseStep = ReleaseStep(pushChangesAction, checkUpstream) - private[sbtrelease] lazy val checkUpstream = { st: State => + private[sbtrelease] lazy val checkUpstream = { (st: State) => if (!vcs(st).hasUpstream) { sys.error("No tracking branch is set up. Either configure a remote tracking branch, or remove the pushChanges release part.") } @@ -260,7 +260,7 @@ object ReleaseStateTransformations { override def buffer[T](f: => T): T = st.log.buffer(f) } - private[sbtrelease] lazy val pushChangesAction = { st: State => + private[sbtrelease] lazy val pushChangesAction = { (st: State) => val defaultChoice = extractDefault(st, "y") val log = toProcessLogger(st) @@ -287,7 +287,7 @@ object ReleaseStateTransformations { check = Compat.checkPublishTo, enableCrossBuild = true ) - private[sbtrelease] lazy val runPublishArtifactsAction = { st: State => + private[sbtrelease] lazy val runPublishArtifactsAction = { (st: State) => val extracted = st.extract val ref = extracted.get(thisProjectRef) extracted.runAggregated(ref / (Global / releasePublishArtifactsAction), st) diff --git a/src/main/scala/ReleasePlugin.scala b/src/main/scala/ReleasePlugin.scala index c077d9d..b5b72d1 100644 --- a/src/main/scala/ReleasePlugin.scala +++ b/src/main/scala/ReleasePlugin.scala @@ -40,28 +40,28 @@ object ReleasePlugin extends AutoPlugin { } @deprecated("Use releaseStepTaskAggregated", "1.0.0") - def releaseTask[T](key: TaskKey[T]) = { st: State => + def releaseTask[T](key: TaskKey[T]) = { (st: State) => Project.extract(st).runAggregated(key, st) } /** * Convert the given task key to a release step action. */ - def releaseStepTask[T](key: TaskKey[T]) = { st: State => + def releaseStepTask[T](key: TaskKey[T]) = { (st: State) => Project.extract(st).runTask(key, st)._1 } /** * Convert the given task key to a release step action that gets run aggregated. */ - def releaseStepTaskAggregated[T](key: TaskKey[T]): State => State = { st: State => + def releaseStepTaskAggregated[T](key: TaskKey[T]): State => State = { (st: State) => Project.extract(st).runAggregated(key, st) } /** * Convert the given input task key and input to a release step action. */ - def releaseStepInputTask[T](key: InputKey[T], input: String = ""): State => State = { st: State => + def releaseStepInputTask[T](key: InputKey[T], input: String = ""): State => State = { (st: State) => import EvaluateTask._ val extracted = Project.extract(st) val inputTask = extracted.get(Scoped.scopedSetting(key.scope, key.key)) @@ -80,7 +80,7 @@ object ReleasePlugin extends AutoPlugin { /** * Convert the given command and input to a release step action */ - def releaseStepCommand(command: Command, input: String = ""): State => State = { st: State => + def releaseStepCommand(command: Command, input: String = ""): State => State = { (st: State) => Parser.parse(input, command.parser(st)) match { case Right(cmd) => cmd() case Left(msg) => sys.error(s"Invalid programmatic input:\n$msg") @@ -90,7 +90,7 @@ object ReleasePlugin extends AutoPlugin { /** * Convert the given command string to a release step action */ - def releaseStepCommand(command: String): State => State = { st: State => + def releaseStepCommand(command: String): State => State = { (st: State) => Parser.parse(command, st.combinedParser) match { case Right(cmd) => cmd() case Left(msg) => sys.error(s"Invalid programmatic input:\n$msg") @@ -100,7 +100,7 @@ object ReleasePlugin extends AutoPlugin { /** * Convert the given command string to a release step action, preserving and invoking remaining commands */ - def releaseStepCommandAndRemaining(command: String): State => State = { initState: State => + def releaseStepCommandAndRemaining(command: String): State => State = { (initState: State) => import Compat._ @annotation.tailrec def runCommand(command: Compat.Command, state: State): State = { @@ -179,14 +179,14 @@ object ReleasePlugin extends AutoPlugin { } } - val removeFailureCommand = { s: State => + val removeFailureCommand = { (s: State) => s.remainingCommands match { case FailureCommand :: tail => s.copy(remainingCommands = tail) case _ => s } } - val failureCheck = { s: State => + val failureCheck = { (s: State) => filterFailure(_.copy(onFailure = Some(FailureCommand)))(s) }