Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare Scala 3 #429

Merged
merged 1 commit into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/scala/Compat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions src/main/scala/ReleaseExtra.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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.")
}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions src/main/scala/ReleasePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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")
Expand All @@ -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")
Expand All @@ -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 = {
Expand Down Expand Up @@ -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)
}

Expand Down