Skip to content

Commit

Permalink
1.23.1: Clean temporary directory before migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
sergej-koscejev committed Mar 20, 2024
1 parent f28e9fc commit a54f29f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
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.23.1

### Fixed

- `MpsMigrate` and `runMigrations` tasks will clean their temporary directory (where MPS caches and the generated Ant
script are located) before each run. This helps avoid complaints by MPS that files have been modified externally.

## 1.23.0

### Added
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.23.0"
val baseVersion = "1.23.1"

group = "de.itemis.mps"

Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/de/itemis/mps/gradle/runmigrations/Plugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ open class RunMigrationsMpsProjectPlugin : Plugin<Project> {
throw GradleException("Specified MPS location does not exist or is not a directory: $mpsLocation")
}

// Clean temporary dir to help avoid strange errors
temporaryDir.listFiles()?.forEach { it.deleteRecursively() }

val buildFile = temporaryDir.resolve("build.xml")
buildFile.printWriter().use {
MarkupBuilder(it).withGroovyBuilder {
Expand Down
8 changes: 8 additions & 0 deletions src/main/kotlin/de/itemis/mps/gradle/tasks/MpsMigrate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ abstract class MpsMigrate @Inject constructor(

@TaskAction
fun execute() {
// When MPS detects that files have changed externally then instead of updating the VFS cache it complains.
// Cleaning temporary directory helps avoid this.
cleanTemporaryDir()

val buildFile = temporaryDir.resolve("build.xml")
writeBuildFile(buildFile)

Expand All @@ -105,6 +109,10 @@ abstract class MpsMigrate @Inject constructor(
}
}

private fun cleanTemporaryDir() {
temporaryDir.listFiles()?.forEach { it.deleteRecursively() }
}

private fun writeBuildFile(buildFile: File) {
buildFile.printWriter().use { writer ->
MarkupBuilder(writer).withGroovyBuilder {
Expand Down

0 comments on commit a54f29f

Please sign in to comment.