Skip to content

Commit af4ab2a

Browse files
author
Oleksandr Dzhychko
committed
feat(model-api): declare unordered child links in MPSRepositoryConcepts
This information is needed for the bulk-model-sync to no created unnecessary and forbidden move operation during imports. This also directly fixes MODELIX-742 The general setup for running JUnit test with MPS was taken from https://github.com/modelix/modelix.mps-plugins/blob/76efda60f7c0498fc246a48222645dd178b5356e/mps-legacy-sync-plugin/src/test/kotlin/SyncPluginTestBase.kt
1 parent b21dd8a commit af4ab2a

File tree

20 files changed

+629
-0
lines changed

20 files changed

+629
-0
lines changed

.github/workflows/build.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@ jobs:
7979
env:
8080
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8181
run: bulk-model-sync-gradle-test/ci.sh
82+
- name: Test bulk-sync-lib with MPS
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
run: bulk-model-sync-lib-mps-test/ci.sh
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
.gradle
2+
build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
!**/src/main/**/build/
5+
!**/src/test/**/build/
6+
7+
### IntelliJ IDEA ###
8+
.idea/modules.xml
9+
.idea/jarRepositories.xml
10+
.idea/compiler.xml
11+
.idea/libraries/
12+
*.iws
13+
*.iml
14+
*.ipr
15+
out/
16+
!**/src/main/**/out/
17+
!**/src/test/**/out/
18+
19+
### Eclipse ###
20+
.apt_generated
21+
.classpath
22+
.factorypath
23+
.project
24+
.settings
25+
.springBeans
26+
.sts4-cache
27+
bin/
28+
!**/src/main/**/bin/
29+
!**/src/test/**/bin/
30+
31+
### NetBeans ###
32+
/nbproject/private/
33+
/nbbuild/
34+
/dist/
35+
/nbdist/
36+
/.nb-gradle/
37+
38+
### VS Code ###
39+
.vscode/
40+
41+
### Mac OS ###
42+
.DS_Store
43+
/test-repo/**/**/classes_gen/
44+
/test-repo/**/**/generator/
45+
/test-repo/**/**/source_gen/
46+
/test-repo/**/**/source_gen.caches/
47+
48+
### MPS running for tests
49+
$LOG_DIR$
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* Copyright (c) 2023.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
plugins {
18+
alias(libs.plugins.kotlin.jvm)
19+
// We are not building an actual plugin here.
20+
// We use/abuse the gradle-intellij-plugin run tests with MPS.
21+
// (With enough time and effort,
22+
// one could inspect what the plugin does under the hood
23+
// and build something custom using the relevant parts.
24+
// For the time being, this solution works without much overhead and great benefit.)
25+
alias(libs.plugins.intellij)
26+
}
27+
28+
val modelixCoreVersion: String = file("../version.txt").readText()
29+
30+
version = modelixCoreVersion
31+
32+
repositories {
33+
val modelixRegex = "org\\.modelix.*"
34+
mavenLocal {
35+
content {
36+
includeGroupByRegex(modelixRegex)
37+
}
38+
}
39+
gradlePluginPortal {
40+
content {
41+
excludeGroupByRegex(modelixRegex)
42+
}
43+
}
44+
maven {
45+
url = uri("https://artifacts.itemis.cloud/repository/maven-mps/")
46+
content {
47+
includeGroupByRegex(modelixRegex)
48+
includeGroup("com.jetbrains")
49+
}
50+
}
51+
mavenCentral {
52+
content {
53+
excludeGroupByRegex(modelixRegex)
54+
}
55+
}
56+
}
57+
58+
dependencies {
59+
testImplementation("org.modelix:bulk-model-sync-lib:$modelixCoreVersion")
60+
testImplementation("org.modelix.mps:model-adapters:$modelixCoreVersion")
61+
testImplementation(libs.kotlin.serialization.json)
62+
}
63+
64+
val mpsVersion = project.findProperty("mps.version")?.toString()?.takeIf { it.isNotEmpty() }
65+
?: "2021.1.4"
66+
println("Building for MPS version $mpsVersion")
67+
68+
// Extract MPS during configuration phase, because using it in intellij.localPath requires it to already exist.
69+
val mpsHome = project.layout.buildDirectory.dir("mps-$mpsVersion")
70+
val mpsZip: Configuration by configurations.creating
71+
dependencies { mpsZip("com.jetbrains:mps:$mpsVersion") }
72+
mpsHome.get().asFile.let { baseDir ->
73+
if (baseDir.exists()) return@let // the content of MPS zip is not expected to change
74+
75+
println("Extracting MPS ...")
76+
sync {
77+
from(zipTree({ mpsZip.singleFile }))
78+
into(mpsHome)
79+
}
80+
81+
// The build number of a local IDE is expected to contain a product code, otherwise an exception is thrown.
82+
val buildTxt = mpsHome.get().asFile.resolve("build.txt")
83+
val buildNumber = buildTxt.readText()
84+
val prefix = "MPS-"
85+
if (!buildNumber.startsWith(prefix)) {
86+
buildTxt.writeText("$prefix$buildNumber")
87+
}
88+
89+
println("Extracting MPS done.")
90+
}
91+
92+
intellij {
93+
localPath = mpsHome.map { it.asFile.absolutePath }
94+
}

bulk-model-sync-lib-mps-test/ci.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
set -e
4+
(
5+
cd "$(dirname "$0")"
6+
./gradlew test --console=plain --stacktrace
7+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kotlin.code.style=official
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../gradle/wrapper/gradle-wrapper.jar
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../gradle/wrapper/gradle-wrapper.properties
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../gradlew
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../gradlew.bat
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright (c) 2023.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
pluginManagement {
18+
val modelixCoreVersion: String = file("../version.txt").readText()
19+
val modelixRegex = "org\\.modelix.*"
20+
repositories {
21+
mavenLocal {
22+
content {
23+
includeGroupByRegex(modelixRegex)
24+
}
25+
}
26+
gradlePluginPortal {
27+
content {
28+
excludeGroupByRegex(modelixRegex)
29+
}
30+
}
31+
maven {
32+
url = uri("https://artifacts.itemis.cloud/repository/maven-mps/")
33+
content {
34+
includeGroupByRegex(modelixRegex)
35+
}
36+
}
37+
mavenCentral {
38+
content {
39+
excludeGroupByRegex(modelixRegex)
40+
}
41+
}
42+
}
43+
dependencyResolutionManagement {
44+
repositories {
45+
mavenLocal {
46+
content {
47+
includeGroupByRegex(modelixRegex)
48+
}
49+
}
50+
gradlePluginPortal {
51+
content {
52+
excludeGroupByRegex(modelixRegex)
53+
}
54+
}
55+
maven {
56+
url = uri("https://artifacts.itemis.cloud/repository/maven-mps/")
57+
content {
58+
includeGroupByRegex(modelixRegex)
59+
includeGroup("com.jetbrains")
60+
}
61+
}
62+
mavenCentral {
63+
content {
64+
excludeGroupByRegex(modelixRegex)
65+
}
66+
}
67+
}
68+
versionCatalogs {
69+
create("libs") {
70+
from("org.modelix:core-version-catalog:$modelixCoreVersion")
71+
}
72+
}
73+
}
74+
}

0 commit comments

Comments
 (0)