Skip to content

Commit 739934d

Browse files
authored
Merge pull request #168 from modelix/feature/model-sync-gradle
MODELIX-448 bulk-model-sync-gradle: Gradle plugin for syncing models between model server and MPS
2 parents c37921b + eba5b1d commit 739934d

File tree

99 files changed

+3772
-522
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+3772
-522
lines changed

.github/workflows/build.yaml

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ jobs:
2828
arguments: |
2929
--build-cache
3030
build
31-
publishToMavenLocal
3231
-PciBuild=true
33-
- name: Test Model API Generator Gradle Plugin
34-
env:
35-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36-
run: model-api-gen-gradle-test/ci.sh
3732
- name: Archive test report
3833
uses: actions/upload-artifact@v3
3934
if: always()
@@ -42,3 +37,52 @@ jobs:
4237
path: |
4338
*/build/test-results
4439
*/build/reports
40+
41+
test-model-api-gen-gradle:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- uses: actions/checkout@v3
45+
- name: Set up JDK 11
46+
uses: actions/setup-java@v3
47+
with:
48+
distribution: 'temurin'
49+
java-version: '11'
50+
- name: Assemble
51+
uses: gradle/gradle-build-action@v2
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
with:
55+
arguments: |
56+
--build-cache
57+
assemble
58+
publishToMavenLocal
59+
-PciBuild=true
60+
- name: Test Model API Generator Gradle Plugin
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
run: model-api-gen-gradle-test/ci.sh
64+
65+
test-bulk-model-sync-gradle:
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v3
69+
- name: Set up JDK 11
70+
uses: actions/setup-java@v3
71+
with:
72+
distribution: 'temurin'
73+
java-version: '11'
74+
- name: Assemble
75+
uses: gradle/gradle-build-action@v2
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
with:
79+
arguments: |
80+
--build-cache
81+
assemble
82+
publishToMavenLocal
83+
-PciBuild=true
84+
85+
- name: Test Bulk Model Sync Gradle Plugin
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
run: bulk-model-sync-gradle-test/ci.sh

build.gradle.kts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import kotlinx.html.unsafe
1717
import org.jetbrains.dokka.base.DokkaBase
1818
import org.jetbrains.dokka.base.DokkaBaseConfiguration
1919
import org.jetbrains.dokka.gradle.DokkaTaskPartial
20+
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
21+
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper
2022
import org.semver.Version
2123

2224
buildscript {
@@ -76,12 +78,25 @@ subprojects {
7678
version.set("0.50.0")
7779
}
7880

81+
val kotlinApiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_6
7982
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
8083
if (!name.lowercase().contains("test")) {
8184
kotlinOptions {
8285
jvmTarget = "11"
8386
freeCompilerArgs += listOf("-Xjvm-default=all-compatibility")
84-
apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_6.version
87+
apiVersion = kotlinApiVersion.version
88+
}
89+
}
90+
}
91+
92+
plugins.withType<KotlinMultiplatformPluginWrapper> {
93+
project.extensions.configure<KotlinMultiplatformExtension> {
94+
sourceSets.all {
95+
if (!name.lowercase().contains("test")) {
96+
languageSettings {
97+
apiVersion = kotlinApiVersion.version
98+
}
99+
}
85100
}
86101
}
87102
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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/
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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+
import org.modelix.model.server.Main
18+
19+
buildscript {
20+
val modelixCoreVersion: String = file("../version.txt").readText()
21+
dependencies {
22+
classpath("org.modelix:model-server:$modelixCoreVersion")
23+
classpath("org.modelix:graph-lang-api:$modelixCoreVersion")
24+
}
25+
}
26+
27+
plugins {
28+
alias(libs.plugins.kotlin.jvm)
29+
id("org.modelix.bulk-model-sync")
30+
}
31+
32+
val modelixCoreVersion: String = file("../version.txt").readText()
33+
34+
version = modelixCoreVersion
35+
36+
repositories {
37+
mavenLocal()
38+
maven { url = uri("https://repo.maven.apache.org/maven2") }
39+
maven { url = uri("https://plugins.gradle.org/m2/") }
40+
mavenCentral()
41+
maven { url = uri("https://artifacts.itemis.cloud/repository/maven-mps/") }
42+
}
43+
44+
val mps by configurations.creating
45+
val mpsDir = buildDir.resolve("mps").apply { mkdirs() }
46+
val kotlinGenDir = buildDir.resolve("metamodel/kotlin").apply { mkdirs() }
47+
48+
dependencies {
49+
mps("com.jetbrains:mps:2021.2.5")
50+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2")
51+
implementation("org.modelix:model-server:$modelixCoreVersion")
52+
implementation("org.modelix:model-api-gen-runtime:$modelixCoreVersion")
53+
testImplementation("org.modelix:model-client:$modelixCoreVersion")
54+
testImplementation("org.modelix:bulk-model-sync-lib:$modelixCoreVersion")
55+
testImplementation("org.modelix.mps:model-adapters:$modelixCoreVersion")
56+
testImplementation("org.modelix:graph-lang-api:$modelixCoreVersion")
57+
testImplementation(kotlin("test"))
58+
testImplementation(libs.xmlunit.core)
59+
}
60+
61+
tasks.test {
62+
useJUnitPlatform()
63+
}
64+
65+
kotlin {
66+
jvmToolchain(11)
67+
}
68+
69+
tasks.register("runModelServer", JavaExec::class) {
70+
group = "modelix"
71+
72+
description = "Launches a model-server instance to be used as a target for the test. " +
73+
"This task will block and is intended to be run in a separate process, apart from the actual test execution."
74+
75+
classpath = sourceSets["main"].runtimeClasspath
76+
mainClass.set("org.modelix.model.server.Main")
77+
args("-inmemory")
78+
}
79+
80+
val resolveMps by tasks.registering(Copy::class) {
81+
from(mps.resolve().map { zipTree(it) })
82+
into(mpsDir)
83+
}
84+
85+
val repoDir = buildDir.resolve("test-repo")
86+
87+
val copyTestRepo by tasks.registering(Sync::class) {
88+
from(projectDir.resolve("test-repo"))
89+
into(repoDir)
90+
}
91+
92+
modelSync {
93+
dependsOn(resolveMps)
94+
dependsOn(copyTestRepo)
95+
direction("testPush") {
96+
org.modelix.model.sync.bulk.gradle.test.GraphLanguagesHelper.registerAll()
97+
includeModule("GraphSolution")
98+
fromLocal {
99+
mpsHome = mpsDir
100+
mpsHeapSize = "2g"
101+
repositoryDir = repoDir
102+
}
103+
toModelServer {
104+
url = "http://0.0.0.0:${Main.DEFAULT_PORT}/v2"
105+
repositoryId = "ci-test"
106+
branchName = "master"
107+
}
108+
}
109+
direction("testPull") {
110+
fromModelServer {
111+
url = "http://0.0.0.0:${Main.DEFAULT_PORT}/v2"
112+
repositoryId = "ci-test"
113+
branchName = "master"
114+
}
115+
toLocal {
116+
mpsHome = mpsDir
117+
repositoryDir = repoDir
118+
}
119+
}
120+
}

bulk-model-sync-gradle-test/ci.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
cd "$(dirname "$0")"
6+
7+
(
8+
cd graph-lang-api
9+
./gradlew publishToMavenLocal --console=plain
10+
)
11+
12+
./gradlew assemble --console=plain
13+
14+
if [ "${CI}" != "true" ]; then
15+
trap cleanup INT TERM EXIT
16+
cleanup () {
17+
kill "${MODEL_SERVER_PID}"
18+
exit
19+
}
20+
fi
21+
22+
./gradlew runModelServer --console=plain &
23+
MODEL_SERVER_PID=$!
24+
sleep 5
25+
26+
#CI needs more time
27+
if [ "${CI}" = "true" ]; then
28+
sleep 10
29+
fi
30+
31+
curl -X POST http://127.0.0.1:28101/v2/repositories/ci-test/init
32+
33+
./gradlew runSyncTestPush --console=plain --stacktrace
34+
./gradlew test --tests 'PushTest'
35+
./gradlew runSyncTestPull --console=plain --stacktrace
36+
./gradlew test --tests 'PullTest'
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists
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

0 commit comments

Comments
 (0)