diff --git a/README.md b/README.md index 4ce6482..4292005 100644 --- a/README.md +++ b/README.md @@ -492,7 +492,9 @@ Parameters: * `mpsLocation` - location where to place the MPS files. * `mpsVersion` - if you use a [custom distribution](#custom-mps-distribution) of MPS. * `projectLocation` - location of the project that should be migrated. -* `force` - ignores the marker files for projects which allow pending migrations, migrate them anyway (supported in 2021.3.0 and higher) +* `force` - ignores the marker files for projects which allow pending migrations, migrate them anyway. Supported in 2021.3.0 and higher. +* `haltOnPrecheckFailure` - controls whether migration is aborted if pre-checks fail (except the check for migrated dependecies) Default: `true`. Supported in 2021.1 and higher. +* `haltOnDependencyError` - controls whether migration is aborted when non-migrated dependencies are discovered. Default: `true`. Supported in 2021.3.4 and 2023.2 and higher. * `maxHeap` (since 1.15) - maximum heap size setting for the JVM that executes the migrations. The value is a string understood by the JVM command line argument `-Xmx` e.g. `3G` or `512M`. diff --git a/src/main/kotlin/de/itemis/mps/gradle/runmigrations/Plugin.kt b/src/main/kotlin/de/itemis/mps/gradle/runmigrations/Plugin.kt index 4067498..1cf36d4 100644 --- a/src/main/kotlin/de/itemis/mps/gradle/runmigrations/Plugin.kt +++ b/src/main/kotlin/de/itemis/mps/gradle/runmigrations/Plugin.kt @@ -15,15 +15,19 @@ import javax.inject.Inject open class MigrationExecutorPluginExtensions @Inject constructor(of: ObjectFactory) : BasePluginExtensions(of) { /** - * (Since MPS 2021.1) Whether to halt if a pre-check has failed. Note that the check for migrated dependencies - * cannot be skipped. + * (Since MPS 2021.1) Whether to halt if a pre-check has failed. Note that to ignore the check for migrated + * dependencies the [haltOnDependencyError] option must be set to `false` as well. */ var haltOnPrecheckFailure: Boolean? = null /** - * (Since MPS 2021.3) Whether to force a migration even if the project directory contains `.allow-pending-migrations` file. + * (Since MPS 2021.3.4) Whether to halt when a non-migrated dependency is discovered. */ + var haltOnDependencyError: Boolean? = null + /** + * (Since MPS 2021.3) Whether to force a migration even if the project directory contains `.allow-pending-migrations` file. + */ var force: Boolean? = null } @@ -31,6 +35,7 @@ open class MigrationExecutorPluginExtensions @Inject constructor(of: ObjectFacto open class RunMigrationsMpsProjectPlugin : Plugin { companion object { val MIN_VERSION_FOR_HALT_ON_PRECHECK_FAILURE = SemVer(2021, 1) + val MIN_VERSION_FOR_HALT_ON_DEPENDENCY_ERROR = SemVer(2021, 3, 4) val MIN_VERSION_FOR_FORCE = SemVer(2021, 3) } @@ -57,6 +62,10 @@ open class RunMigrationsMpsProjectPlugin : Plugin { 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.") } + if (extension.haltOnDependencyError != null && parsedMPSVersion < MIN_VERSION_FOR_HALT_ON_DEPENDENCY_ERROR) { + throw GradleException("The 'do not halt on dependency error' option is only supported for MPS version $MIN_VERSION_FOR_HALT_ON_DEPENDENCY_ERROR and higher.") + } + val resolveMps: Task = if (extension.mpsConfig != null) { tasks.create("resolveMpsForMigrations", Copy::class.java) { from({ extension.mpsConfig!!.resolve().map(::zipTree) }) @@ -84,8 +93,9 @@ open class RunMigrationsMpsProjectPlugin : Plugin { add("project" to projectLocation) add("mpsHome" to mpsLocation) - if (extension.force != null) add("force" to extension.force!!) - if (extension.haltOnPrecheckFailure != null) add("haltOnPrecheckFailure" to extension.haltOnPrecheckFailure!!) + extension.force?.let { add("force" to it) } + extension.haltOnPrecheckFailure?.let { add("haltOnPrecheckFailure" to it) } + extension.haltOnDependencyError?.let { add("haltOnDependencyError" to it) } toTypedArray() }