Skip to content

Commit

Permalink
runMigrations: make migration flags nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
sergej-koscejev committed Apr 25, 2023
1 parent 9984588 commit 17eae3e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Extracted Git-based versioning into a separate subproject, `git-based-versioning`.
- `runMigrations`: `force` and `haltOnPrecheckFailure` are now nullable and null by default.

## 1.15

Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ val versionMinor = 16
group = "de.itemis.mps"

var currentBranch:String? = ""
currentBranch = de.itemis.mps.gradle.GitBasedVersioning.getGitBranch()
currentBranch = GitBasedVersioning.getGitBranch()

version = if (!project.hasProperty("useSnapshot") &&
(project.hasProperty("forceCI") || project.hasProperty("teamcity"))
) {
de.itemis.mps.gradle.GitBasedVersioning.getVersion(
GitBasedVersioning.getVersion(
// Publish releases from v1.x branch without v1.x prefix
if (currentBranch == "v1.x") "HEAD" else currentBranch,
versionMajor.toString(), versionMinor.toString())
Expand Down
12 changes: 6 additions & 6 deletions src/main/kotlin/de/itemis/mps/gradle/runmigrations/Plugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ open class MigrationExecutorPluginExtensions @Inject constructor(of: ObjectFacto
* (Since MPS 2021.1) Whether to halt if a pre-check has failed. Note that the check for migrated dependencies
* cannot be skipped.
*/
var haltOnPrecheckFailure = true
var haltOnPrecheckFailure: Boolean? = null

/**
* (Since MPS 2021.3) Whether to force a migration even if the project directory contains `.allow-pending-migrations` file.
*/

var force = false
var force: Boolean? = null
}

@Suppress("unused")
Expand All @@ -49,11 +49,11 @@ open class RunMigrationsMpsProjectPlugin : Plugin<Project> {
val mpsVersion = extension.getMPSVersion()
val parsedMPSVersion = SemVer.parse(mpsVersion)

if (extension.force && parsedMPSVersion < MIN_VERSION_FOR_FORCE) {
if (extension.force != null && parsedMPSVersion < MIN_VERSION_FOR_FORCE) {
throw GradleException("The force migration flag is only supported for MPS version $MIN_VERSION_FOR_FORCE and higher.")
}

if (!extension.haltOnPrecheckFailure && parsedMPSVersion < MIN_VERSION_FOR_HALT_ON_PRECHECK_FAILURE) {
if (extension.haltOnPrecheckFailure != null && parsedMPSVersion < MIN_VERSION_FOR_HALT_ON_PRECHECK_FAILURE) {
throw GradleException("The 'do not halt on pre-check failure' option is only supported for MPS version $MIN_VERSION_FOR_HALT_ON_PRECHECK_FAILURE and higher.")
}

Expand Down Expand Up @@ -84,8 +84,8 @@ open class RunMigrationsMpsProjectPlugin : Plugin<Project> {
add("project" to projectLocation)
add("mpsHome" to mpsLocation)

if (parsedMPSVersion >= MIN_VERSION_FOR_FORCE) add("force" to extension.force)
if (parsedMPSVersion >= MIN_VERSION_FOR_HALT_ON_PRECHECK_FAILURE) add("haltOnPrecheckFailure" to extension.haltOnPrecheckFailure)
if (extension.force != null) add("force" to extension.force!!)
if (extension.haltOnPrecheckFailure != null) add("haltOnPrecheckFailure" to extension.haltOnPrecheckFailure!!)

toTypedArray()
}
Expand Down

0 comments on commit 17eae3e

Please sign in to comment.