Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
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.24.3

- Upgrade to project-loader 4.0.0
- Backends are now only tested against 2023.2 and above (up from 2022.2) due to a bug in MPS
(https://youtrack.jetbrains.com/issue/MPS-39248/Cant-find-property-constraints-errors-for-base-language)
which makes newer MPS versions break when opening projects from old MPS versions.

## 1.24.2

- `execute` now applies the indexing workaround like `modelcheck` and `generate`.
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
org.gradle.parallel=true

version.backend=1.24.2
version.project-loader=4.0.0
version.backend=1.24.3
version.project-loader=5.0.0

# A comma-separated list of MPS releases or prereleases to test against.
# Also used in the GitHub workflow to test each version in parallel
supportedMpsVersions=2022.3.3,2023.2.2,2024.1.2,2024.3.1,251.23774.10091
supportedMpsVersions=2023.2.2,2024.1.2,2025.1.1,253.28294.219
6 changes: 6 additions & 0 deletions launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
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).

## 2.8.0

### Added

- `--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED` is now passed to the JVM to support MPS 2025.3 prerelease.

## 2.7.0

### Changed
Expand Down
2 changes: 1 addition & 1 deletion launcher/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version.launcher=2.7.0
version.launcher=2.8.0
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;

public class MpsBackendBuilder {
Expand Down Expand Up @@ -193,6 +192,7 @@ private static void configureOpens(JavaForkOptions options) {
"java.base/java.util",
"java.base/java.util.concurrent",
"java.base/java.util.concurrent.atomic",
"java.base/jdk.internal.ref",
"java.base/jdk.internal.vm",
"java.base/sun.nio.ch",
"java.base/sun.nio.fs",
Expand Down
11 changes: 11 additions & 0 deletions project-loader/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Changes in versions before 2.0.0 are documented in the [root changelog](../CHANGELOG.md).

## 5.0.0

### Added

- `ProjectLoader#executeWithProjects` to execute an action for multiple projects, applying the indexing workaround
to each, according to arguments.

### Changed

- `Args#forceIndexing` moved up to `EnvironmentArgs`.

## 4.0.0

### Added
Expand Down
3 changes: 2 additions & 1 deletion project-loader/api/project-loader.api
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public final class de/itemis/mps/gradle/logging/LoggingFactoryKt {
public class de/itemis/mps/gradle/project/loader/Args : de/itemis/mps/gradle/project/loader/EnvironmentArgs {
public fun <init> (Lcom/xenomachina/argparser/ArgParser;)V
public fun configureProjectLoader (Lde/itemis/mps/gradle/project/loader/ProjectLoader$Builder;)V
public final fun getForceIndexing ()Ljava/lang/Boolean;
public final fun getProject ()Ljava/io/File;
}

Expand All @@ -34,6 +33,7 @@ public class de/itemis/mps/gradle/project/loader/EnvironmentArgs {
public fun configureProjectLoader (Lde/itemis/mps/gradle/project/loader/ProjectLoader$Builder;)V
public final fun getBuildNumber ()Ljava/lang/String;
public final fun getEnvironmentKind ()Lde/itemis/mps/gradle/project/loader/EnvironmentKind;
public final fun getForceIndexing ()Ljava/lang/Boolean;
public final fun getLogLevel ()Lde/itemis/mps/gradle/logging/LogLevel;
public final fun getMacros ()Ljava/util/List;
public final fun getPluginLocation ()Ljava/io/File;
Expand Down Expand Up @@ -120,6 +120,7 @@ public final class de/itemis/mps/gradle/project/loader/ProjectLoader {
public static final field Companion Lde/itemis/mps/gradle/project/loader/ProjectLoader$Companion;
public synthetic fun <init> (Ljetbrains/mps/tool/environment/EnvironmentConfig;Lde/itemis/mps/gradle/project/loader/EnvironmentKind;Ljava/io/File;Ljava/lang/String;Lde/itemis/mps/gradle/logging/LogLevel;Ljava/lang/Boolean;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun execute (Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public final fun executeForEachProject (Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/util/List;
public final fun executeWithProject (Ljava/io/File;Lkotlin/jvm/functions/Function2;)Ljava/lang/Object;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ public open class EnvironmentArgs(parser: ArgParser) {
public val skipLibraries: Boolean by parser.flagging("--no-libraries",
help = "do not load project libraries under MPS environment")

public val forceIndexing: Boolean? by parser.storing(
"--force-indexing", help = "whether to force full indexing at startup to work around MPS-37926." +
" Supported values: always, never, auto. Default: auto.") {
when (this) {
"always" -> true
"never" -> false
"auto" -> null
else -> throw InvalidArgumentException("Unsupported value '$this'. Supported values are always, never, auto")
}
}.default(null)

public open fun configureProjectLoader(builder: ProjectLoader.Builder) {
builder.environmentConfig {
plugins.addAll(this@EnvironmentArgs.plugins)
Expand All @@ -69,6 +80,8 @@ public open class EnvironmentArgs(parser: ArgParser) {
builder.environmentKind = environmentKind
builder.buildNumber = buildNumber
builder.logLevel = de.itemis.mps.gradle.logging.LogLevel.valueOf(logLevel.toString())

builder.forceIndexing = forceIndexing
}

public fun buildLoader(): ProjectLoader = ProjectLoader.build(this::configureProjectLoader)
Expand All @@ -84,22 +97,9 @@ public open class Args(parser: ArgParser) : EnvironmentArgs(parser) {
public val project: File by parser.storing("--project",
help = "project to generate from") { File(this) }

public val forceIndexing: Boolean? by parser.storing(
"--force-indexing", help = "whether to force full indexing at startup to work around MPS-37926." +
" Supported values: always, never, auto. Default: auto.") {
when (this) {
"always" -> true
"never" -> false
"auto" -> null
else -> throw InvalidArgumentException("Unsupported value '$this'. Supported values are always, never, auto")
}
}.default(null)

override fun configureProjectLoader(builder: ProjectLoader.Builder) {
super.configureProjectLoader(builder)

builder.forceIndexing = forceIndexing

if (!skipLibraries && environmentKind == EnvironmentKind.MPS) {
builder.environmentConfig {
findProjectLibraries(project, macros, libraries::addAll)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,32 @@ public class ProjectLoader private constructor(

/**
* Execute [action] in the context of an initialized MPS/IDEA environment and project located in [projectDir].
* Closes the project and shuts down the environment after the action finishes, even if it throws an exception.
* Closes the project after the action even if it throws an exception. Shuts down the environment after actions
* finish, even if it throws an exception.
*
* If an action for a project throws an exception, actions for further projects in the list are not performed.
*
* @param projectDir the directory to open as a MPS project
* @param action action to execute.
*/
public fun <T> executeWithProject(projectDir: File, action: (Environment, Project) -> T): T =
execute { env -> withOpenProject(env, projectDir, action) }

/**
* Execute [action] in the manner of [executeWithProject] for each project in [projectDirs]. The environment is
* opened once, projects are opened sequentially, each project being closed before opening the next one.
*
* If [action] throws an exception for one of the projects, further projects in the list will not be processed.
* Closes the project and shuts down the environment after the action finishes, even if it throws an exception.
*
* @param projectDirs the directories to open as MPS projects
* @param action action to execute.
*/
public fun <T> executeForEachProject(projectDirs: List<File>, action: (Environment, Project) -> T): List<T> =
execute { env ->
projectDirs.map { withOpenProject(env, it, action) }
}

/**
* Opens the project in [projectDir], executes [action] and disposes of the project regardless of whether [action]
* succeeds or throws an exception.
Expand Down
6 changes: 6 additions & 0 deletions remigrate/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) after reaching version 1.0.0. Until then any version may
contain breaking changes.

# 1.0.0

## Added

- The backend will now wait until project indices are built for each project before running migrations.

# 0.3.0

## Added
Expand Down
2 changes: 1 addition & 1 deletion remigrate/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version.backend=0.3.0
version.backend=1.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private fun runProjectMigrations(project: Project, migrationsToExclude: Set<Stri
}

// A helper function to avoid deprecation warnings everywhere we need the project name
@Suppress("DEPRECATION", "removal")
@Suppress("DEPRECATION")
private fun getName(project: Project) = project.name

private fun resolve(languageRegistry: LanguageRegistry, reference: MigrationScriptReference): MigrationScript? =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,21 @@ val logger = logging.getLogger("de.itemis.mps.gradle.migrate")

fun remigrate(args: RemigrateArgs) {
val loader = args.buildLoader()
val projectDirs = args.projects.map(::File)
val moduleMigrationsToExclude = args.excludeModuleMigrations.toSet()
val projectMigrationsToExclude = args.excludeProjectMigrations.toSet()

loader.execute { environment ->
loader.executeForEachProject(projectDirs) { environment, project ->
val pluginId = PluginId.getId(PLUGIN_ID)
val pluginDescriptor = PluginManager.getInstance()
.findEnabledPlugin(pluginId)

if (pluginDescriptor == null) {
throw Exception("Plugin $pluginId not loaded or not enabled, cannot proceed")
}

for (projectDir in args.projects) {
val project = environment.openProject(File(projectDir))
try {
val helperClass =
pluginDescriptor.pluginClassLoader!!.loadClass(WorkFromIdeaPlugin.javaClass.name)

val method = helperClass.getMethod("work",
Project::class.java,
Set::class.java,
Set::class.java)

method.invoke(null, project, projectMigrationsToExclude, moduleMigrationsToExclude)
} finally {
environment.closeProject(project)
}
environment.flushAllEvents()
}
val pluginDescriptor = PluginManager.getInstance().findEnabledPlugin(pluginId)
?: throw Exception("Plugin $pluginId not loaded or not enabled, cannot proceed")

val helperClass = pluginDescriptor.pluginClassLoader!!.loadClass(WorkFromIdeaPlugin.javaClass.name)
val method = helperClass.getMethod("work", Project::class.java, Set::class.java, Set::class.java)

method.invoke(null, project, projectMigrationsToExclude, moduleMigrationsToExclude)

environment.flushAllEvents()
}
}

Expand Down
15 changes: 15 additions & 0 deletions test-projects/execute-method/.mps/migration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MigrationProperties">
<entry key="jetbrains.mps.ide.mpsmigration.v191.SaveAllJavaStubMethodRefsToShortForeignFormat" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v191.UpdateJavaStubMethodRefs" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2019_3.DefaultFacetExplicitPersistence" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2021_2.SplitMPSCoreStub" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2021_3.ExtractMPSBootStubs" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2022_3.ExplicitJavaFacetSettings" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2022_3.SplitMPSCoreStub2" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2023_1.DataFlowStubsToRegularNodes" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2023_1.JavaModuleSettingsToFacet" value="executed" />
<entry key="project.migrated.version" value="232" />
</component>
</project>
2 changes: 1 addition & 1 deletion test-projects/execute-method/.mps/vcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<child id="1068581517665" name="statement" index="3cqZAp" />
</concept>
<concept id="1068581517677" name="jetbrains.mps.baseLanguage.structure.VoidType" flags="in" index="3cqZAl" />
<concept id="1204053956946" name="jetbrains.mps.baseLanguage.structure.IMethodCall" flags="ng" index="1ndlxa">
<concept id="1204053956946" name="jetbrains.mps.baseLanguage.structure.IMethodCall" flags="ngI" index="1ndlxa">
<reference id="1068499141037" name="baseMethodDeclaration" index="37wK5l" />
<child id="1068499141038" name="actualArgument" index="37wK5m" />
</concept>
Expand All @@ -61,13 +61,13 @@
<concept id="1107535904670" name="jetbrains.mps.baseLanguage.structure.ClassifierType" flags="in" index="3uibUv">
<reference id="1107535924139" name="classifier" index="3uigEE" />
</concept>
<concept id="1178549954367" name="jetbrains.mps.baseLanguage.structure.IVisible" flags="ng" index="1B3ioH">
<concept id="1178549954367" name="jetbrains.mps.baseLanguage.structure.IVisible" flags="ngI" index="1B3ioH">
<child id="1178549979242" name="visibility" index="1B3o_S" />
</concept>
<concept id="1146644602865" name="jetbrains.mps.baseLanguage.structure.PublicVisibility" flags="nn" index="3Tm1VV" />
</language>
<language id="ceab5195-25ea-4f22-9b92-103b95ca8c0c" name="jetbrains.mps.lang.core">
<concept id="1169194658468" name="jetbrains.mps.lang.core.structure.INamedConcept" flags="ng" index="TrEIO">
<concept id="1169194658468" name="jetbrains.mps.lang.core.structure.INamedConcept" flags="ngI" index="TrEIO">
<property id="1169194664001" name="name" index="TrG5h" />
</concept>
</language>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<solution name="my.solution" uuid="468a495b-8ea4-49d8-b365-3c92887c30e0" moduleVersion="0" compileInMPS="true">
<solution name="my.solution" uuid="468a495b-8ea4-49d8-b365-3c92887c30e0" moduleVersion="0">
<models>
<modelRoot contentPath="${module}" type="default">
<sourceRoot location="models" />
</modelRoot>
</models>
<facets>
<facet type="java">
<facet type="java" compile="mps" classes="mps" ext="no">
<classes generated="true" path="${module}/classes_gen" />
</facet>
</facets>
<sourcePath />
<dependencies>
<dependency reexport="false">6354ebe7-c22a-4a0f-ac54-50b52ab9b065(JDK)</dependency>
<dependency reexport="false">6ed54515-acc8-4d1e-a16c-9fd6cfe951ea(MPS.Core)</dependency>
</dependencies>
<languageVersions>
<language slang="l:f3061a53-9226-4cc5-a443-f952ceaf5816:jetbrains.mps.baseLanguage" version="12" />
<language slang="l:fd392034-7849-419d-9071-12563d152375:jetbrains.mps.baseLanguage.closures" version="0" />
<language slang="l:83888646-71ce-4f1c-9c53-c54016f6ad4f:jetbrains.mps.baseLanguage.collections" version="1" />
<language slang="l:83888646-71ce-4f1c-9c53-c54016f6ad4f:jetbrains.mps.baseLanguage.collections" version="2" />
<language slang="l:f2801650-65d5-424e-bb1b-463a8781b786:jetbrains.mps.baseLanguage.javadoc" version="2" />
<language slang="l:760a0a8c-eabb-4521-8bfd-65db761a9ba3:jetbrains.mps.baseLanguage.logging" version="0" />
<language slang="l:a247e09e-2435-45ba-b8d2-07e93feba96a:jetbrains.mps.baseLanguage.tuples" version="0" />
Expand Down
7 changes: 7 additions & 0 deletions test-projects/generate-build-solution/.mps/migration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,12 @@
<entry key="jetbrains.mps.ide.mpsmigration.v191.SaveAllJavaStubMethodRefsToShortForeignFormat" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v191.UpdateJavaStubMethodRefs" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2019_3.DefaultFacetExplicitPersistence" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2021_2.SplitMPSCoreStub" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2021_3.ExtractMPSBootStubs" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2022_3.ExplicitJavaFacetSettings" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2022_3.SplitMPSCoreStub2" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2023_1.DataFlowStubsToRegularNodes" value="executed" />
<entry key="jetbrains.mps.ide.mpsmigration.v_2023_1.JavaModuleSettingsToFacet" value="executed" />
<entry key="project.migrated.version" value="232" />
</component>
</project>
2 changes: 1 addition & 1 deletion test-projects/generate-build-solution/.mps/vcs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
</component>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
<child id="5617550519002745378" name="macros" index="1l3spd" />
<child id="5617550519002745372" name="layout" index="1l3spN" />
</concept>
<concept id="4701820937132344003" name="jetbrains.mps.build.structure.BuildLayout_Container" flags="ng" index="1y1bJS">
<concept id="4701820937132344003" name="jetbrains.mps.build.structure.BuildLayout_Container" flags="ngI" index="1y1bJS">
<child id="7389400916848037006" name="children" index="39821P" />
</concept>
</language>
<language id="ceab5195-25ea-4f22-9b92-103b95ca8c0c" name="jetbrains.mps.lang.core">
<concept id="1169194658468" name="jetbrains.mps.lang.core.structure.INamedConcept" flags="ng" index="TrEIO">
<concept id="1169194658468" name="jetbrains.mps.lang.core.structure.INamedConcept" flags="ngI" index="TrEIO">
<property id="1169194664001" name="name" index="TrG5h" />
</concept>
</language>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<solution name="my.build" uuid="a4deeaa8-8bf4-485e-b06c-d772b56fee6a" moduleVersion="0" compileInMPS="true">
<solution name="my.build" uuid="a4deeaa8-8bf4-485e-b06c-d772b56fee6a" moduleVersion="0">
<models>
<modelRoot contentPath="${module}" type="default">
<sourceRoot location="models" />
</modelRoot>
</models>
<facets>
<facet type="java">
<facet type="java" compile="mps" classes="mps" ext="no">
<classes generated="true" path="${module}/classes_gen" />
</facet>
</facets>
<sourcePath />
<dependencies>
<dependency reexport="false">422c2909-59d6-41a9-b318-40e6256b250f(jetbrains.mps.ide.build)</dependency>
</dependencies>
Expand Down
Loading
Loading