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

Fix fallback commands #433

Merged
merged 2 commits into from
Sep 8, 2023
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 build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ lazy val V = new {
val scala213BinaryVersion = "2.13"
val scala212 = "2.12.15"
val scalatest = "3.2.13"
val scala3 = "3.3.0"
val scala3 = "3.3.1"
val scalafix = "0.11.0"
val organizeImports = "0.4.3"
val catsCore = "2.7.0"
Expand Down
2 changes: 0 additions & 2 deletions plugin/src/main/scala/migrate/CommandStrings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,4 @@ object CommandStrings {
|- Incompatible: it is incompatible with Scala 3 because it is a macro library or a compiler plugin
|- Unclassified: sbt-scala3-migrate does not know how to migrate this dependency
|""".stripMargin

val migrateFallback = "internalMigrateFallback"
}
28 changes: 14 additions & 14 deletions plugin/src/main/scala/migrate/ScalaMigratePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ object ScalaMigratePlugin extends AutoPlugin {
migrateScalacOptions,
migrateLibDependencies,
migrateTypes,
fallback,
fallbackAndFail,
migrateFail
internalMigrateFallback,
internalMigrateFallbackAndFail,
internalMigrateFail
)
)

Expand Down Expand Up @@ -134,9 +134,9 @@ object ScalaMigratePlugin extends AutoPlugin {
migrateScalacOptions,
migrateLibDependencies,
migrateTypes,
fallback,
fallbackAndFail,
migrateFail),
internalMigrateFallback,
internalMigrateFallbackAndFail,
internalMigrateFail),
inConfig(Compile)(configSettings),
inConfig(Test)(configSettings)
)
Expand Down Expand Up @@ -249,30 +249,30 @@ object ScalaMigratePlugin extends AutoPlugin {
val preparedState = state.copy(attributes = state.attributes.remove(Keys.scala2Version))
val commands = List(
StashOnFailure, // stash shell from onFailure
s"$OnFailure migrateFallbackAndFail $projectId",
s"$OnFailure internalMigrateFallbackAndFail $projectId",
s"$projectId / storeScala2Inputs",
setScalaVersion(projectId, BuildInfo.scala3Version), // set Scala 3
s"$projectId / internalMigrateTypes",
PopOnFailure, // pop shell to onFailure in case the fallback fails
s"$migrateFallback $projectId" // set Scala 2.13
PopOnFailure, // pop shell to onFailure in case the fallback fails
s"internalMigrateFallback $projectId" // set Scala 2.13
)
commands ::: preparedState
}

lazy val fallback: Command =
Command(migrateFallback)(idParser) { (state, projectId) =>
lazy val internalMigrateFallback: Command =
Command("internalMigrateFallback")(idParser) { (state, projectId) =>
state.attributes.get(Keys.scala2Version) match {
case Some(scala2Version) => setScalaVersion(projectId, scala2Version) :: state
case None => state
}
}

lazy val fallbackAndFail: Command =
lazy val internalMigrateFallbackAndFail: Command =
Command("internalMigrateFallbackAndFail")(idParser) { (state, projectId) =>
PopOnFailure :: s"migrateFallback $projectId" :: s"migrateFail $projectId" :: Nil ::: state
PopOnFailure :: s"internalMigrateFallback $projectId" :: s"internalMigrateFail $projectId" :: Nil ::: state
}

lazy val migrateFail: Command =
lazy val internalMigrateFail: Command =
Command("internalMigrateFail")(idParser) { (state, projectId) =>
state.log.error(s"Migration of $projectId failed.")
state.fail
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
> migrateTypes aggregate-project

# check aggregate-project is migrated
> ++3.3.0!
> ++3.3.1!
> aggregate-project / compile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
> migrateSyntax integration-test
> migrateTypes integration-test

> ++3.3.0!
> ++3.3.1!
> integration-test / IntegrationTest / compile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
> migrateSyntax library-dependencies
> migrateTypes library-dependencies

> ++3.3.0!
> ++3.3.1!
> library-dependencies / compile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
> migrateSyntax managed-sources
> migrateTypes managed-sources

> ++3.3.0!
> ++3.3.1!
> managed-sources / compile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
> migrateSyntax syntax-migration

> ++3.3.0!
> ++3.3.1!
> syntax-migration / Test / compile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
> migrateTypes type-inference-migration

> ++3.3.0!
> ++3.3.1!
> type-inference-migration / Test / compile