From 25ce160a7f0c4f901420605f16b64e13c97e8034 Mon Sep 17 00:00:00 2001 From: Michael Huster Date: Mon, 30 Oct 2023 16:44:59 +0100 Subject: [PATCH 01/10] fix(bulk-model-sync-gradle): add missing includedModules checks for model-server tasks --- .../sync/bulk/gradle/ModelSyncGradlePlugin.kt | 4 +++ .../gradle/tasks/ExportFromModelServer.kt | 27 ++++++++++++++++--- .../gradle/tasks/ImportIntoModelServer.kt | 14 ++++++++-- .../org/modelix/model/sync/bulk/Util.kt | 15 +++++++++++ 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/ModelSyncGradlePlugin.kt b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/ModelSyncGradlePlugin.kt index f88ac0e839..2a48bb9758 100644 --- a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/ModelSyncGradlePlugin.kt +++ b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/ModelSyncGradlePlugin.kt @@ -113,6 +113,8 @@ class ModelSyncGradlePlugin : Plugin { it.repositoryId.set(serverSource.repositoryId) it.branchName.set(serverSource.branchName) it.revision.set(serverSource.revision) + it.includedModules.set(syncDirection.includedModules) + it.includedModulePrefixes.set(syncDirection.includedModulePrefixes) } return exportFromModelServer } @@ -173,6 +175,8 @@ class ModelSyncGradlePlugin : Plugin { it.url.set(serverTarget.url) it.repositoryId.set(serverTarget.repositoryId) it.branchName.set(serverTarget.branchName) + it.includedModules.set(syncDirection.includedModules) + it.includedModulePrefixes.set(syncDirection.includedModulePrefixes) } project.tasks.register("runSync${syncDirection.name.replaceFirstChar { it.uppercaseChar() }}") { diff --git a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt index 1f76faceef..2398fd4ca6 100644 --- a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt +++ b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt @@ -20,6 +20,7 @@ import kotlinx.coroutines.runBlocking import org.gradle.api.DefaultTask import org.gradle.api.file.DirectoryProperty import org.gradle.api.model.ObjectFactory +import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property import org.gradle.api.tasks.Input import org.gradle.api.tasks.Optional @@ -28,6 +29,7 @@ import org.gradle.api.tasks.TaskAction import org.modelix.model.ModelFacade import org.modelix.model.api.BuiltinLanguages import org.modelix.model.api.IBranch +import org.modelix.model.api.INode import org.modelix.model.api.PBranch import org.modelix.model.api.getRootNode import org.modelix.model.client2.IModelClientV2 @@ -36,6 +38,7 @@ import org.modelix.model.client2.ModelClientV2PlatformSpecificBuilder import org.modelix.model.client2.getReplicatedModel import org.modelix.model.lazy.RepositoryId import org.modelix.model.sync.bulk.ModelExporter +import org.modelix.model.sync.bulk.isModuleIncluded import javax.inject.Inject abstract class ExportFromModelServer @Inject constructor(of: ObjectFactory) : DefaultTask() { @@ -58,6 +61,12 @@ abstract class ExportFromModelServer @Inject constructor(of: ObjectFactory) : De @OutputDirectory val outputDir: DirectoryProperty = of.directoryProperty() + @Input + val includedModules: ListProperty = of.listProperty(String::class.java) + + @Input + val includedModulePrefixes: ListProperty = of.listProperty(String::class.java) + @TaskAction fun export() { val client = ModelClientV2PlatformSpecificBuilder() @@ -76,15 +85,27 @@ abstract class ExportFromModelServer @Inject constructor(of: ObjectFactory) : De val root = branch.getRootNode() logger.info("Got root node: {}", root) val outputDir = outputDir.get().asFile - root.allChildren.forEach { - val nameRole = BuiltinLanguages.jetbrains_mps_lang_core.INamedConcept.name - val fileName = it.getPropertyValue(nameRole) + + getIncludedModules(root).forEach { + val fileName = it.getPropertyValue(BuiltinLanguages.jetbrains_mps_lang_core.INamedConcept.name) val outputFile = outputDir.resolve("$fileName.json") ModelExporter(it).export(outputFile) } } } + private fun getIncludedModules(root: INode): Iterable { + val nameRole = BuiltinLanguages.jetbrains_mps_lang_core.INamedConcept.name + + return root.allChildren.filter { + val isModule = it.concept == BuiltinLanguages.MPSRepositoryConcepts.Module + val moduleName = it.getPropertyValue(nameRole) ?: return@filter false + val isIncluded = isModuleIncluded(moduleName, includedModules.get(), includedModulePrefixes.get()) + + isModule && isIncluded + } + } + private fun getBranchByRepoIdAndBranch(client: ModelClientV2): IBranch { val repoId = RepositoryId(repositoryId.get()) val branchRef = ModelFacade.createBranchReference(repoId, branchName.get()) diff --git a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ImportIntoModelServer.kt b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ImportIntoModelServer.kt index 12fef823a2..c2f0981956 100644 --- a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ImportIntoModelServer.kt +++ b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ImportIntoModelServer.kt @@ -20,6 +20,7 @@ import kotlinx.coroutines.runBlocking import org.gradle.api.DefaultTask import org.gradle.api.file.DirectoryProperty import org.gradle.api.model.ObjectFactory +import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.Input @@ -35,6 +36,7 @@ import org.modelix.model.client2.runWrite import org.modelix.model.lazy.RepositoryId import org.modelix.model.sync.bulk.ModelImporter import org.modelix.model.sync.bulk.importFilesAsRootChildren +import org.modelix.model.sync.bulk.isModuleIncluded import javax.inject.Inject abstract class ImportIntoModelServer @Inject constructor(of: ObjectFactory) : DefaultTask() { @@ -55,6 +57,12 @@ abstract class ImportIntoModelServer @Inject constructor(of: ObjectFactory) : De @Input val registeredLanguages: SetProperty = of.setProperty(ILanguage::class.java) + @Input + val includedModules: ListProperty = of.listProperty(String::class.java) + + @Input + val includedModulePrefixes: ListProperty = of.listProperty(String::class.java) + @TaskAction fun import() { registeredLanguages.get().forEach { @@ -66,8 +74,10 @@ abstract class ImportIntoModelServer @Inject constructor(of: ObjectFactory) : De val branchRef = ModelFacade.createBranchReference(repoId, branchName.get()) val client = ModelClientV2PlatformSpecificBuilder().url(url.get()).build() - val files = inputDir.listFiles()?.filter { it.extension == "json" } - if (files.isNullOrEmpty()) error("no json files found") + val files = inputDir.listFiles()?.filter { + it.extension == "json" && isModuleIncluded(it.nameWithoutExtension, includedModules.get(), includedModulePrefixes.get()) + } + if (files.isNullOrEmpty()) error("no json files found for included modules") runBlocking { client.init() diff --git a/bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk/Util.kt b/bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk/Util.kt index 8ef875d147..42106f89d0 100644 --- a/bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk/Util.kt +++ b/bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk/Util.kt @@ -21,6 +21,21 @@ import org.modelix.model.api.BuiltinLanguages import org.modelix.model.data.ModelData import org.modelix.model.data.NodeData +/** + * Helper-method used by the gradle plugin and the MPS solution. + * Checks if a module is included in the sync. + * + * @param moduleName name of the module to be checked + * @param includedModules collection of included module names + * @param includedPrefixes collection of included module name prefixes + */ +fun isModuleIncluded(moduleName: String, includedModules: Collection, includedPrefixes: Collection): Boolean { + val includedDirectly = includedModules.contains(moduleName) + val includedByPrefix = includedPrefixes.any { prefix -> moduleName.startsWith(prefix) } + + return includedDirectly || includedByPrefix +} + fun mergeModelData(models: Collection): ModelData { return ModelData(root = NodeData(children = models.map { it.root })) } From a08eb31eccb240bbedbb6dbd34481b4ee429308d Mon Sep 17 00:00:00 2001 From: Michael Huster Date: Mon, 30 Oct 2023 16:48:15 +0100 Subject: [PATCH 02/10] fix(bulk-model-sync-gradle): change includedModules property type to set --- .../model/sync/bulk/gradle/tasks/ExportFromModelServer.kt | 6 +++--- .../model/sync/bulk/gradle/tasks/GenerateAntScriptForMps.kt | 6 +++--- .../model/sync/bulk/gradle/tasks/ImportIntoModelServer.kt | 5 ++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt index 2398fd4ca6..0476b3b874 100644 --- a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt +++ b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt @@ -20,8 +20,8 @@ import kotlinx.coroutines.runBlocking import org.gradle.api.DefaultTask import org.gradle.api.file.DirectoryProperty import org.gradle.api.model.ObjectFactory -import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property +import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.Input import org.gradle.api.tasks.Optional import org.gradle.api.tasks.OutputDirectory @@ -62,10 +62,10 @@ abstract class ExportFromModelServer @Inject constructor(of: ObjectFactory) : De val outputDir: DirectoryProperty = of.directoryProperty() @Input - val includedModules: ListProperty = of.listProperty(String::class.java) + val includedModules: SetProperty = of.setProperty(String::class.java) @Input - val includedModulePrefixes: ListProperty = of.listProperty(String::class.java) + val includedModulePrefixes: SetProperty = of.setProperty(String::class.java) @TaskAction fun export() { diff --git a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/GenerateAntScriptForMps.kt b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/GenerateAntScriptForMps.kt index 96bd0cc8ff..f6a9cd3098 100644 --- a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/GenerateAntScriptForMps.kt +++ b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/GenerateAntScriptForMps.kt @@ -19,8 +19,8 @@ package org.modelix.model.sync.bulk.gradle.tasks import org.gradle.api.DefaultTask import org.gradle.api.file.RegularFileProperty import org.gradle.api.model.ObjectFactory -import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property +import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.CacheableTask import org.gradle.api.tasks.Input import org.gradle.api.tasks.Optional @@ -55,10 +55,10 @@ abstract class GenerateAntScriptForMps @Inject constructor(of: ObjectFactory) : val antScriptFile: RegularFileProperty = of.fileProperty() @Input - val includedModules: ListProperty = of.listProperty(String::class.java) + val includedModules: SetProperty = of.setProperty(String::class.java) @Input - val includedModulePrefixes: ListProperty = of.listProperty(String::class.java) + val includedModulePrefixes: SetProperty = of.setProperty(String::class.java) @Optional @Input diff --git a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ImportIntoModelServer.kt b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ImportIntoModelServer.kt index c2f0981956..a73f85d861 100644 --- a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ImportIntoModelServer.kt +++ b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ImportIntoModelServer.kt @@ -20,7 +20,6 @@ import kotlinx.coroutines.runBlocking import org.gradle.api.DefaultTask import org.gradle.api.file.DirectoryProperty import org.gradle.api.model.ObjectFactory -import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property import org.gradle.api.provider.SetProperty import org.gradle.api.tasks.Input @@ -58,10 +57,10 @@ abstract class ImportIntoModelServer @Inject constructor(of: ObjectFactory) : De val registeredLanguages: SetProperty = of.setProperty(ILanguage::class.java) @Input - val includedModules: ListProperty = of.listProperty(String::class.java) + val includedModules: SetProperty = of.setProperty(String::class.java) @Input - val includedModulePrefixes: ListProperty = of.listProperty(String::class.java) + val includedModulePrefixes: SetProperty = of.setProperty(String::class.java) @TaskAction fun import() { From 7bb204024271d9cfe8f5134f47a2d621f0239c4d Mon Sep 17 00:00:00 2001 From: Michael Huster Date: Mon, 6 Nov 2023 10:15:46 +0100 Subject: [PATCH 03/10] refactor(bulk-model-sync-solution): use new helper method and mps string type --- .../org.modelix.mps.model.sync.bulk.mps | 151 ++++-------------- 1 file changed, 29 insertions(+), 122 deletions(-) diff --git a/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps b/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps index cd810dde78..2fb7c75c5d 100644 --- a/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps +++ b/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps @@ -7,7 +7,7 @@ - + @@ -18,7 +18,6 @@ - @@ -54,7 +53,6 @@ - @@ -63,6 +61,7 @@ + @@ -145,9 +144,6 @@ - - - @@ -163,7 +159,6 @@ - @@ -171,7 +166,6 @@ - @@ -194,9 +188,7 @@ - - - + @@ -209,9 +201,7 @@ - - - + @@ -226,9 +216,7 @@ - - - + @@ -238,10 +226,8 @@ - - - - + + @@ -257,9 +243,7 @@ - - - + @@ -269,9 +253,7 @@ - - - + @@ -282,9 +264,7 @@ - - - + @@ -300,9 +280,7 @@ - - - + @@ -366,55 +344,23 @@ - - - - - + + + + + + + - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + @@ -428,6 +374,7 @@ + @@ -456,9 +403,7 @@ - - - + @@ -469,39 +414,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -673,9 +585,7 @@ - - - + @@ -908,9 +818,7 @@ - - - + @@ -926,7 +834,6 @@ - From e70c101a36e0be0ba34e7de7d9225ac92947fd98 Mon Sep 17 00:00:00 2001 From: Michael Huster Date: Mon, 6 Nov 2023 11:29:32 +0100 Subject: [PATCH 04/10] fix(bulk-model-sync-solution): enforce included check during mps import --- .../org.modelix.mps.model.sync.bulk.mps | 262 +++++++++++------- 1 file changed, 168 insertions(+), 94 deletions(-) diff --git a/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps b/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps index 2fb7c75c5d..1196090636 100644 --- a/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps +++ b/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps @@ -60,15 +60,16 @@ + - + @@ -164,6 +165,7 @@ + @@ -185,102 +187,38 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + @@ -581,6 +519,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -622,7 +597,69 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -636,19 +673,6 @@ - - - - - - - - - - - - - @@ -733,6 +757,9 @@ + + + @@ -807,6 +834,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 2c3e5f30e074bb565b06662fdc37503b9f839f1e Mon Sep 17 00:00:00 2001 From: Michael Huster Date: Mon, 6 Nov 2023 11:44:32 +0100 Subject: [PATCH 05/10] fix(bulk-model-sync-solution): add missing progress indicator for mps import --- .../org.modelix.mps.model.sync.bulk.mps | 147 ++++++++++++++---- 1 file changed, 116 insertions(+), 31 deletions(-) diff --git a/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps b/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps index 1196090636..2b307fb1b2 100644 --- a/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps +++ b/bulk-model-sync-solution/solutions/org.modelix.mps.model.sync.bulk/models/org.modelix.mps.model.sync.bulk.mps @@ -53,6 +53,7 @@ + @@ -165,7 +166,6 @@ - @@ -269,7 +269,7 @@ - + @@ -316,9 +316,7 @@ - - - + @@ -327,12 +325,10 @@ - - - + - + @@ -489,7 +485,7 @@ - + @@ -597,30 +593,33 @@ + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - @@ -651,6 +650,9 @@ + + + @@ -659,7 +661,29 @@ - + + + + + + + + + + + + + + + + + + + + + + + @@ -674,6 +698,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From d2ae392afd76127079e28108454e7629bb82262a Mon Sep 17 00:00:00 2001 From: Michael Huster Date: Mon, 6 Nov 2023 12:45:30 +0100 Subject: [PATCH 06/10] test(bulk-model-sync-gradle): fix test setup for pull direction --- bulk-model-sync-gradle-test/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/bulk-model-sync-gradle-test/build.gradle.kts b/bulk-model-sync-gradle-test/build.gradle.kts index 1ac317c3eb..871804bca3 100644 --- a/bulk-model-sync-gradle-test/build.gradle.kts +++ b/bulk-model-sync-gradle-test/build.gradle.kts @@ -107,6 +107,7 @@ modelSync { } } direction("testPull") { + includeModule("GraphSolution") fromModelServer { url = "http://0.0.0.0:${Main.DEFAULT_PORT}/v2" repositoryId = "ci-test" From 25ca9bcfab5300085251fc625830886e2e00fbec Mon Sep 17 00:00:00 2001 From: Michael Huster Date: Tue, 7 Nov 2023 15:51:13 +0100 Subject: [PATCH 07/10] fix(bulk-model-sync-gradle): close client after model server export --- .../model/sync/bulk/gradle/tasks/ExportFromModelServer.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt index 0476b3b874..d0840e2a52 100644 --- a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt +++ b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt @@ -92,6 +92,7 @@ abstract class ExportFromModelServer @Inject constructor(of: ObjectFactory) : De ModelExporter(it).export(outputFile) } } + client.close() } private fun getIncludedModules(root: INode): Iterable { From 012a0eaae57ef365de37bb51302f0e2e29e8bda6 Mon Sep 17 00:00:00 2001 From: Michael Huster Date: Tue, 7 Nov 2023 15:52:00 +0100 Subject: [PATCH 08/10] fix(bulk-model-sync-gradle): correctly check for module instances --- .../model/sync/bulk/gradle/tasks/ExportFromModelServer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt index d0840e2a52..3adc680e61 100644 --- a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt +++ b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt @@ -99,7 +99,7 @@ abstract class ExportFromModelServer @Inject constructor(of: ObjectFactory) : De val nameRole = BuiltinLanguages.jetbrains_mps_lang_core.INamedConcept.name return root.allChildren.filter { - val isModule = it.concept == BuiltinLanguages.MPSRepositoryConcepts.Module + val isModule = it.concept?.getUID() == BuiltinLanguages.MPSRepositoryConcepts.Module.getUID() val moduleName = it.getPropertyValue(nameRole) ?: return@filter false val isIncluded = isModuleIncluded(moduleName, includedModules.get(), includedModulePrefixes.get()) From c338e8b0a8e58f32a0111405cf7e4861e37ebb66 Mon Sep 17 00:00:00 2001 From: Michael Huster Date: Thu, 9 Nov 2023 09:05:27 +0100 Subject: [PATCH 09/10] docs(bulk-model-sync-lib): remove usage hint --- .../src/commonMain/kotlin/org/modelix/model/sync/bulk/Util.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk/Util.kt b/bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk/Util.kt index 42106f89d0..c0f6db3f27 100644 --- a/bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk/Util.kt +++ b/bulk-model-sync-lib/src/commonMain/kotlin/org/modelix/model/sync/bulk/Util.kt @@ -22,7 +22,6 @@ import org.modelix.model.data.ModelData import org.modelix.model.data.NodeData /** - * Helper-method used by the gradle plugin and the MPS solution. * Checks if a module is included in the sync. * * @param moduleName name of the module to be checked From 4b60d3599820aa30db6aa965b25b60dc43cf056f Mon Sep 17 00:00:00 2001 From: Michael Huster Date: Thu, 9 Nov 2023 09:10:59 +0100 Subject: [PATCH 10/10] fix(bulk-model-sync-gradle): use kotlin io use instead of closing client manually --- .../gradle/tasks/ExportFromModelServer.kt | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt index 3adc680e61..3a613e8d22 100644 --- a/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt +++ b/bulk-model-sync-gradle/src/main/kotlin/org/modelix/model/sync/bulk/gradle/tasks/ExportFromModelServer.kt @@ -69,30 +69,30 @@ abstract class ExportFromModelServer @Inject constructor(of: ObjectFactory) : De @TaskAction fun export() { - val client = ModelClientV2PlatformSpecificBuilder() + val modelClient = ModelClientV2PlatformSpecificBuilder() .url(url.get()) .build() + modelClient.use { client -> + runBlocking { client.init() } - runBlocking { client.init() } - - val branch = if (revision.isPresent) { - getBranchByRevision(client) - } else { - getBranchByRepoIdAndBranch(client) - } + val branch = if (revision.isPresent) { + getBranchByRevision(client) + } else { + getBranchByRepoIdAndBranch(client) + } - branch.runRead { - val root = branch.getRootNode() - logger.info("Got root node: {}", root) - val outputDir = outputDir.get().asFile + branch.runRead { + val root = branch.getRootNode() + logger.info("Got root node: {}", root) + val outputDir = outputDir.get().asFile - getIncludedModules(root).forEach { - val fileName = it.getPropertyValue(BuiltinLanguages.jetbrains_mps_lang_core.INamedConcept.name) - val outputFile = outputDir.resolve("$fileName.json") - ModelExporter(it).export(outputFile) + getIncludedModules(root).forEach { + val fileName = it.getPropertyValue(BuiltinLanguages.jetbrains_mps_lang_core.INamedConcept.name) + val outputFile = outputDir.resolve("$fileName.json") + ModelExporter(it).export(outputFile) + } } } - client.close() } private fun getIncludedModules(root: INode): Iterable {