From 896925d6d2c55d66031c32a1fb833b9703fca5c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergej=20Ko=C5=A1=C4=8Dejev?= Date: Tue, 9 Jul 2024 19:07:42 +0200 Subject: [PATCH] 1.28.0: Remigrate can now exclude module migrations --- CHANGELOG.md | 6 ++++++ api/mps-gradle-plugin.api | 15 +++++++++++++++ build.gradle.kts | 2 +- .../mps/gradle/tasks/ExcludedModuleMigration.kt | 6 ++++++ .../de/itemis/mps/gradle/tasks/Remigrate.kt | 13 ++++++++++++- src/test/kotlin/test/migration/RemigrateTest.kt | 4 ++++ 6 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/main/kotlin/de/itemis/mps/gradle/tasks/ExcludedModuleMigration.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index a6ec8cb..14bbaee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 1.28.0 + +### Added + +- `Remigrate` now supports excluding module migrations. + ## 1.27.0 ### Added diff --git a/api/mps-gradle-plugin.api b/api/mps-gradle-plugin.api index a434e06..f5f9d1b 100644 --- a/api/mps-gradle-plugin.api +++ b/api/mps-gradle-plugin.api @@ -304,6 +304,19 @@ public final class de/itemis/mps/gradle/runmigrations/RunMigrationsMpsProjectPlu public final fun getMIN_VERSION_FOR_HALT_ON_PRECHECK_FAILURE ()Lnet/swiftzer/semver/SemVer; } +public final class de/itemis/mps/gradle/tasks/ExcludedModuleMigration { + public fun (Ljava/lang/String;I)V + public final fun component1 ()Ljava/lang/String; + public final fun component2 ()I + public final fun copy (Ljava/lang/String;I)Lde/itemis/mps/gradle/tasks/ExcludedModuleMigration; + public static synthetic fun copy$default (Lde/itemis/mps/gradle/tasks/ExcludedModuleMigration;Ljava/lang/String;IILjava/lang/Object;)Lde/itemis/mps/gradle/tasks/ExcludedModuleMigration; + public fun equals (Ljava/lang/Object;)Z + public final fun getLanguage ()Ljava/lang/String; + public final fun getVersion ()I + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + public abstract class de/itemis/mps/gradle/tasks/MpsCheck : org/gradle/api/tasks/JavaExec, org/gradle/api/tasks/VerificationTask { public fun ()V public fun exec ()V @@ -382,9 +395,11 @@ public abstract class de/itemis/mps/gradle/tasks/MpsMigrate : org/gradle/api/Def public class de/itemis/mps/gradle/tasks/Remigrate : org/gradle/api/tasks/JavaExec { public fun (Lorg/gradle/api/model/ObjectFactory;Lorg/gradle/api/provider/ProviderFactory;)V + public final fun excludeModuleMigration (Ljava/lang/String;I)V public fun exec ()V public final fun getAdditionalClasspath ()Lorg/gradle/api/file/ConfigurableFileCollection; protected final fun getAllProjectFiles ()Lorg/gradle/api/provider/Provider; + public final fun getExcludedModuleMigrations ()Lorg/gradle/api/provider/SetProperty; public final fun getFolderMacros ()Lorg/gradle/api/provider/MapProperty; public final fun getMpsHome ()Lorg/gradle/api/file/DirectoryProperty; public final fun getMpsVersion ()Lorg/gradle/api/provider/Property; diff --git a/build.gradle.kts b/build.gradle.kts index 36c5745..b3944f6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,7 +24,7 @@ plugins { id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2" } -val baseVersion = "1.27.0" +val baseVersion = "1.28.0" group = "de.itemis.mps" diff --git a/src/main/kotlin/de/itemis/mps/gradle/tasks/ExcludedModuleMigration.kt b/src/main/kotlin/de/itemis/mps/gradle/tasks/ExcludedModuleMigration.kt new file mode 100644 index 0000000..83503b3 --- /dev/null +++ b/src/main/kotlin/de/itemis/mps/gradle/tasks/ExcludedModuleMigration.kt @@ -0,0 +1,6 @@ +package de.itemis.mps.gradle.tasks + +import org.gradle.api.Incubating + +@Incubating +data class ExcludedModuleMigration(val language: String, val version: Int) diff --git a/src/main/kotlin/de/itemis/mps/gradle/tasks/Remigrate.kt b/src/main/kotlin/de/itemis/mps/gradle/tasks/Remigrate.kt index bc4fc80..6c08d24 100644 --- a/src/main/kotlin/de/itemis/mps/gradle/tasks/Remigrate.kt +++ b/src/main/kotlin/de/itemis/mps/gradle/tasks/Remigrate.kt @@ -12,10 +12,12 @@ import org.gradle.api.model.ObjectFactory import org.gradle.api.provider.MapProperty import org.gradle.api.provider.Property import org.gradle.api.provider.ProviderFactory +import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.* import org.gradle.kotlin.dsl.mapProperty import org.gradle.kotlin.dsl.newInstance import org.gradle.kotlin.dsl.property +import org.gradle.kotlin.dsl.setProperty import org.gradle.process.CommandLineArgumentProvider import javax.inject.Inject @@ -52,6 +54,12 @@ open class Remigrate @Inject constructor( val additionalClasspath: ConfigurableFileCollection = objectFactory.fileCollection().from(initialBackendClasspath()) + @get:Input + val excludedModuleMigrations: SetProperty = objectFactory.setProperty() + + fun excludeModuleMigration(language: String, version: Int) { + excludedModuleMigrations.add(ExcludedModuleMigration(language, version)) + } init { val backendBuilder: MpsBackendBuilder = project.objects.newInstance(MpsBackendBuilder::class) @@ -75,7 +83,10 @@ open class Remigrate @Inject constructor( .flatMap { it.moduleArtifacts.map { it.file } } .single() - result.add("--plugin=de.itemis.mps.buildbackends.remigrate::" + pluginFile) + result.add("--plugin=de.itemis.mps.buildbackends.remigrate::$pluginFile") + + result.addAll( + excludedModuleMigrations.get().map { "--exclude-module-migration=${it.language}:${it.version}" }) result }) diff --git a/src/test/kotlin/test/migration/RemigrateTest.kt b/src/test/kotlin/test/migration/RemigrateTest.kt index 51168a0..2aea8a6 100644 --- a/src/test/kotlin/test/migration/RemigrateTest.kt +++ b/src/test/kotlin/test/migration/RemigrateTest.kt @@ -38,6 +38,7 @@ class RemigrateTest { buildFile.writeText( """ import de.itemis.mps.gradle.tasks.Remigrate + import de.itemis.mps.gradle.tasks.ExcludedModuleMigration plugins { id("de.itemis.mps.gradle.common") @@ -61,6 +62,9 @@ class RemigrateTest { val remigrate by tasks.registering(Remigrate::class) { projectDirectories.from("$mpsTestPrjLocation") mpsHome.set(layout.dir(resolveMps.map { it.destinationDir })) + + excludedModuleMigrations.add(ExcludedModuleMigration("foo", 0)) + excludeModuleMigration("bar", 1) } """.trimIndent() )