Skip to content

Commit

Permalink
1.28.0: Remigrate can now exclude module migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
sergej-koscejev committed Jul 9, 2024
1 parent 389ea32 commit 896925d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions api/mps-gradle-plugin.api
Original file line number Diff line number Diff line change
Expand Up @@ -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 <init> (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 <init> ()V
public fun exec ()V
Expand Down Expand Up @@ -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 <init> (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;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 12 additions & 1 deletion src/main/kotlin/de/itemis/mps/gradle/tasks/Remigrate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -52,6 +54,12 @@ open class Remigrate @Inject constructor(
val additionalClasspath: ConfigurableFileCollection =
objectFactory.fileCollection().from(initialBackendClasspath())

@get:Input
val excludedModuleMigrations: SetProperty<ExcludedModuleMigration> = objectFactory.setProperty()

fun excludeModuleMigration(language: String, version: Int) {
excludedModuleMigrations.add(ExcludedModuleMigration(language, version))
}

init {
val backendBuilder: MpsBackendBuilder = project.objects.newInstance(MpsBackendBuilder::class)
Expand All @@ -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
})
Expand Down
4 changes: 4 additions & 0 deletions src/test/kotlin/test/migration/RemigrateTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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()
)
Expand Down

0 comments on commit 896925d

Please sign in to comment.