Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODELIX-829 Split INode interface into multiple interfaces #1306

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5a9b914
feat(model-api): cleaned-up INode replacement IReadableNode/IWritable…
slisson Jan 9, 2025
580d8bd
fix(bulk-model-sync): deduplication of sync algorithm in ModelImporte…
slisson Jan 15, 2025
0c4dc5a
fix(bulk-model-sync): use production implementation of INodeAssociati…
slisson Jan 17, 2025
c721fd9
feat(mps-model-adapters): full support for recreating an MPS project
slisson Jan 17, 2025
9631f5d
fix(model-api-gen): suppress warnings in generated files
slisson Jan 23, 2025
d514889
feat(mps-model-adapters): support for MPS 2020.3
slisson Jan 23, 2025
3947aaa
test: fix classpath of MPS plugins
slisson Jan 28, 2025
b721e5b
build: use MPS 2024.1 by default
slisson Jan 29, 2025
5fd71f4
test(bulk-model-sync): increase heap space of ExportFunctionalTest
slisson Feb 3, 2025
37dd30d
test: specify intellij.platform.load.app.info.from.resources in build…
slisson Feb 3, 2025
bd843f1
fix(mps-model-adapters): migrated all remaining adapters to IWritable…
slisson Feb 3, 2025
f076579
fix(mps-model-adapters): replace UUID.fromString with proper MPS API …
slisson Feb 3, 2025
84f5c3f
test(model-server): ensure RestWebModelClient and ReplicatedModel get…
slisson Feb 3, 2025
29b4aad
fix(mps-model-adapters): use org.modelix.mps:stable-api:1.1.1 that is…
slisson Feb 3, 2025
88199a5
test(mps-model-adapters): provide jna.boot.library.path if available
slisson Feb 3, 2025
2cdaf78
build: include mavenLocal
slisson Feb 3, 2025
aeb7c4b
test(mps-model-adapters): disable hanging tests
slisson Feb 3, 2025
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
2 changes: 2 additions & 0 deletions .github/workflows/mps-compatibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
strategy:
matrix:
version:
- "2020.3"
- "2021.1"
- "2021.2"
- "2021.3"
Expand All @@ -42,6 +43,7 @@ jobs:
run: >-
./gradlew --build-cache
:bulk-model-sync-mps:build
:bulk-model-sync-lib:mps-test:build
:metamodel-export:build
:mps-model-adapters:build
:mps-model-adapters-plugin:build
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
// because plugins like npm and intellij may override our settings
repositories {
val modelixRegex = "org\\.modelix.*"
mavenLocal {
content {
includeGroupByRegex(modelixRegex)
}
}
gradlePluginPortal {
content {
excludeGroupByRegex(modelixRegex)
Expand All @@ -24,4 +19,5 @@ repositories {
excludeGroupByRegex(modelixRegex)
}
}
mavenLocal()
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
val modelixRegex = "org\\.modelix.*"
pluginManagement {
repositories {
mavenLocal {
content {
includeGroupByRegex(modelixRegex)
}
}
gradlePluginPortal {
content {
excludeGroupByRegex(modelixRegex)
Expand All @@ -22,6 +17,7 @@ pluginManagement {
includeGroupByRegex(modelixRegex)
}
}
mavenLocal()
}
}
dependencyResolutionManagement {
Expand All @@ -44,5 +40,6 @@ dependencyResolutionManagement {
includeGroup("com.jetbrains")
}
}
mavenLocal()
}
}
28 changes: 21 additions & 7 deletions build-logic/src/main/kotlin/org/modelix/CopyMps.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package org.modelix

import org.gradle.api.Project
import org.gradle.api.artifacts.ModuleDependency
import org.gradle.api.file.Directory
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.exclude
import java.io.File
import java.util.zip.ZipInputStream

val Project.mpsMajorVersion: String get() {
if (project != rootProject) return rootProject.mpsVersion
if (project != rootProject) return rootProject.mpsMajorVersion
return project.findProperty("mps.version.major")?.toString()?.takeIf { it.isNotEmpty() }
?: project.findProperty("mps.version")?.toString()?.takeIf { it.isNotEmpty() }?.replace(Regex("""(20\d\d\.\d+).*"""), "$1")
?: "2021.1"
?: "2024.1"
}

val Project.mpsVersion: String get() {
Expand All @@ -25,11 +27,12 @@ val Project.mpsVersion: String get() {
"2021.1" to "2021.1.4",
"2021.2" to "2021.2.6",
"2021.3" to "2021.3.5",
"2022.2" to "2022.2.3",
"2022.3" to "2022.3.1",
"2023.2" to "2023.2",
"2023.3" to "2023.3",
"2024.1" to "2024.1-EAP1",
"2022.2" to "2022.2.4",
"2022.3" to "2022.3.3",
"2023.2" to "2023.2.2",
"2023.3" to "2023.3.2",
"2024.1" to "2024.1.1",
"2024.3" to "2024.3",
)[it],
) { "Unknown MPS version: $it" }
}
Expand Down Expand Up @@ -100,3 +103,14 @@ fun Project.copyMps(): File {
println("Extracting MPS done.")
return mpsHome
}

val excludeMPSLibraries: (ModuleDependency).() -> Unit = {
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-core")
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-jdk8")
exclude("org.jetbrains.kotlinx", "kotlinx-coroutines-swing")
exclude("org.jetbrains.kotlin", "kotlin-stdlib")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-common")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk7")
exclude("org.jetbrains.kotlin", "kotlin-stdlib-jdk8")
exclude("org.jetbrains", "annotations")
}
4 changes: 4 additions & 0 deletions bulk-model-sync-gradle-test/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
kotlin.code.style=official
org.gradle.jvmargs=-Xmx1024m -Xms256m -XX:MaxMetaspaceSize=2g -XX:+HeapDumpOnOutOfMemoryError
org.gradle.parallel=true
systemProp.org.gradle.internal.http.socketTimeout=120000
kotlin.daemon.jvmargs=-Xmx2G
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.modelix.model.sync.bulk.gradle.test

import GraphLang.L_GraphLang
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.TestInstance
import org.modelix.model.api.ConceptReference
import org.xmlunit.builder.Input
import org.xmlunit.xpath.JAXPXPathEngine
import java.io.File
import javax.xml.transform.Source
import kotlin.test.assertContains
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals
Expand All @@ -25,10 +28,21 @@ class PullTest {
.readText(),
).build()

private fun getRegisteredConcepts(xml: Source): Map<ConceptReference, String> {
val conceptNodes = JAXPXPathEngine().selectNodes("model/registry/language/concept", xml)
return conceptNodes.associate { c ->
val conceptId = c.attributes.getNamedItem("id").nodeValue
val languageId = c.parentNode.attributes.getNamedItem("id").nodeValue
val shortId = c.attributes.getNamedItem("index").nodeValue
ConceptReference("mps:$languageId/$conceptId") to shortId
}
}

@Test
fun `properties were synced to local`() {
val shortConceptId = getRegisteredConcepts(solution1Xml)[L_GraphLang.Node.untyped().getReference()]
val properties = JAXPXPathEngine()
.selectNodes("model/node/node[@concept='1DmExO']/property", solution1Xml)
.selectNodes("model/node/node[@concept='$shortConceptId']/property", solution1Xml)

val actual = properties.map { it.attributes.getNamedItem("value").nodeValue }
val expected = listOf("X", "Y", "Z", "NewNode", "D", "E")
Expand All @@ -38,8 +52,9 @@ class PullTest {

@Test
fun `added child was synced to local`() {
val shortConceptId = getRegisteredConcepts(solution1Xml)[L_GraphLang.Node.untyped().getReference()]
val xpath = JAXPXPathEngine()
val nodes = xpath.selectNodes("model/node/node[@concept='1DmExO']", solution1Xml)
val nodes = xpath.selectNodes("model/node/node[@concept='$shortConceptId']", solution1Xml)

val nodeNames = nodes.flatMap { xpath.selectNodes("property", it) }
.map { it.attributes.getNamedItem("value").nodeValue }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.modelix.model.lazy.RepositoryId
import org.modelix.model.sync.bulk.asExported
import org.modelix.model.withAutoTransactions
import java.io.File
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
Expand All @@ -41,9 +40,9 @@ class PushTest {
val files = inputDir.listFiles()?.filter { it.extension == "json" } ?: error("no json files found in ${inputDir.absolutePath}")

val modules = files.map { ModelData.fromJson(it.readText()) }
val inputModel = ModelData(root = NodeData(children = modules.map { it.root }))
val inputModel = ModelData(root = NodeData(children = modules.map { it.root }).normalize())

assertContentEquals(inputModel.root.children, root.allChildren.map { it.asExported() })
assertEquals(inputModel.toJson(), ModelData(root = NodeData(children = root.allChildren.map { it.asExported() }).normalize()).toJson())
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ abstract class ExportFromModelServer : DefaultTask() {
val nameRole = BuiltinLanguages.jetbrains_mps_lang_core.INamedConcept.name

return root.allChildren.filter {
val isModule = it.concept?.getUID() == BuiltinLanguages.MPSRepositoryConcepts.Module.getUID()
val isModule = it.concept?.isSubConceptOf(BuiltinLanguages.MPSRepositoryConcepts.Module) == true
val moduleName = it.getPropertyValue(nameRole) ?: return@filter false
val isIncluded = isModuleIncluded(
moduleName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.modelix.model.sync.bulk.gradle

import io.kotest.matchers.file.shouldContainFile
import io.kotest.matchers.file.shouldContainNFiles
import org.gradle.testkit.runner.GradleRunner
import org.gradle.testkit.runner.internal.DefaultGradleRunner
import org.junit.jupiter.api.io.CleanupMode
import org.junit.jupiter.api.io.TempDir
import java.io.File
Expand All @@ -15,7 +15,7 @@ class ExportFunctionalTest {

@TempDir(cleanup = CleanupMode.ON_SUCCESS)
private lateinit var projectDir: File
private val gradle by lazy { GradleRunner.create().withProjectDir(projectDir) }
private val gradle by lazy { DefaultGradleRunner().withJvmArguments("-Xmx1024m").withProjectDir(projectDir) }

@BeforeTest
fun setup() {
Expand Down
1 change: 1 addition & 0 deletions bulk-model-sync-lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ kotlin {
val commonMain by getting {
dependencies {
implementation(project(":model-api"))
implementation(project(":model-datastructure"))
implementation(libs.kotlin.serialization.json)
implementation(libs.kotlin.logging)
}
Expand Down
22 changes: 19 additions & 3 deletions bulk-model-sync-lib/mps-test/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import org.modelix.copyMps
import org.modelix.excludeMPSLibraries
import org.modelix.mpsMajorVersion

plugins {
`modelix-kotlin-jvm`
Expand All @@ -13,12 +15,14 @@ plugins {
}

dependencies {
testImplementation(project(":bulk-model-sync-lib"))
testImplementation(project(":bulk-model-sync-mps"))
testImplementation(project(":mps-model-adapters"))
testImplementation(project(":bulk-model-sync-lib"), excludeMPSLibraries)
testImplementation(project(":bulk-model-sync-mps"), excludeMPSLibraries)
testImplementation(project(":mps-model-adapters"), excludeMPSLibraries)
testImplementation(project(":model-datastructure"), excludeMPSLibraries)
testImplementation(libs.kotlin.serialization.json)
testImplementation(libs.xmlunit.matchers)
testImplementation(libs.jimfs)
testImplementation(libs.modelix.mpsApi)
}

intellij {
Expand All @@ -33,4 +37,16 @@ tasks {
buildSearchableOptions {
enabled = false
}

test {
onlyIf {
!setOf(
"2020.3", // incompatible with the intellij plugin
"2021.2", // hangs when executed on CI
"2021.3", // hangs when executed on CI
"2022.2", // hangs when executed on CI
).contains(mpsMajorVersion)
}
jvmArgs("-Dintellij.platform.load.app.info.from.resources=true")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import java.util.regex.Pattern
private val TESTDATA_PATTERN = Pattern.compile(".*\\(testdata (.*)\\)")

abstract class MPSTestBase : HeavyPlatformTestCase() {
init {
// workaround for MPS 2023.3 failing to start in test mode
System.setProperty("intellij.platform.load.app.info.from.resources", "true")
}

protected lateinit var projectDir: Path

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ModelImporterWithMPSAdaptersTest : MPSTestBase() {
model.addRootNode(root1)
val root2 = model.createNode(classConcept)
model.addRootNode(root2)
val moduleAdapter = MPSModuleAsNode(module)
val moduleAdapter = MPSModuleAsNode(module).asLegacyNode()
// Arrange: Create export data
val dataWithRootsInOneOrder = ModelData(root = moduleAdapter.asExported())
val modelWitRootsInOneOrder = dataWithRootsInOneOrder.root.children[0]
Expand Down
Loading
Loading