-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
99 changed files
with
3,772 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
/test-repo/**/**/classes_gen/ | ||
/test-repo/**/**/generator/ | ||
/test-repo/**/**/source_gen/ | ||
/test-repo/**/**/source_gen.caches/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/* | ||
* Copyright (c) 2023. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import org.modelix.model.server.Main | ||
|
||
buildscript { | ||
val modelixCoreVersion: String = file("../version.txt").readText() | ||
dependencies { | ||
classpath("org.modelix:model-server:$modelixCoreVersion") | ||
classpath("org.modelix:graph-lang-api:$modelixCoreVersion") | ||
} | ||
} | ||
|
||
plugins { | ||
alias(libs.plugins.kotlin.jvm) | ||
id("org.modelix.bulk-model-sync") | ||
} | ||
|
||
val modelixCoreVersion: String = file("../version.txt").readText() | ||
|
||
version = modelixCoreVersion | ||
|
||
repositories { | ||
mavenLocal() | ||
maven { url = uri("https://repo.maven.apache.org/maven2") } | ||
maven { url = uri("https://plugins.gradle.org/m2/") } | ||
mavenCentral() | ||
maven { url = uri("https://artifacts.itemis.cloud/repository/maven-mps/") } | ||
} | ||
|
||
val mps by configurations.creating | ||
val mpsDir = buildDir.resolve("mps").apply { mkdirs() } | ||
val kotlinGenDir = buildDir.resolve("metamodel/kotlin").apply { mkdirs() } | ||
|
||
dependencies { | ||
mps("com.jetbrains:mps:2021.2.5") | ||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2") | ||
implementation("org.modelix:model-server:$modelixCoreVersion") | ||
implementation("org.modelix:model-api-gen-runtime:$modelixCoreVersion") | ||
testImplementation("org.modelix:model-client:$modelixCoreVersion") | ||
testImplementation("org.modelix:bulk-model-sync-lib:$modelixCoreVersion") | ||
testImplementation("org.modelix.mps:model-adapters:$modelixCoreVersion") | ||
testImplementation("org.modelix:graph-lang-api:$modelixCoreVersion") | ||
testImplementation(kotlin("test")) | ||
testImplementation(libs.xmlunit.core) | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
|
||
kotlin { | ||
jvmToolchain(11) | ||
} | ||
|
||
tasks.register("runModelServer", JavaExec::class) { | ||
group = "modelix" | ||
|
||
description = "Launches a model-server instance to be used as a target for the test. " + | ||
"This task will block and is intended to be run in a separate process, apart from the actual test execution." | ||
|
||
classpath = sourceSets["main"].runtimeClasspath | ||
mainClass.set("org.modelix.model.server.Main") | ||
args("-inmemory") | ||
} | ||
|
||
val resolveMps by tasks.registering(Copy::class) { | ||
from(mps.resolve().map { zipTree(it) }) | ||
into(mpsDir) | ||
} | ||
|
||
val repoDir = buildDir.resolve("test-repo") | ||
|
||
val copyTestRepo by tasks.registering(Sync::class) { | ||
from(projectDir.resolve("test-repo")) | ||
into(repoDir) | ||
} | ||
|
||
modelSync { | ||
dependsOn(resolveMps) | ||
dependsOn(copyTestRepo) | ||
direction("testPush") { | ||
org.modelix.model.sync.bulk.gradle.test.GraphLanguagesHelper.registerAll() | ||
includeModule("GraphSolution") | ||
fromLocal { | ||
mpsHome = mpsDir | ||
mpsHeapSize = "2g" | ||
repositoryDir = repoDir | ||
} | ||
toModelServer { | ||
url = "http://0.0.0.0:${Main.DEFAULT_PORT}/v2" | ||
repositoryId = "ci-test" | ||
branchName = "master" | ||
} | ||
} | ||
direction("testPull") { | ||
fromModelServer { | ||
url = "http://0.0.0.0:${Main.DEFAULT_PORT}/v2" | ||
repositoryId = "ci-test" | ||
branchName = "master" | ||
} | ||
toLocal { | ||
mpsHome = mpsDir | ||
repositoryDir = repoDir | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
cd "$(dirname "$0")" | ||
|
||
( | ||
cd graph-lang-api | ||
./gradlew publishToMavenLocal --console=plain | ||
) | ||
|
||
./gradlew assemble --console=plain | ||
|
||
if [ "${CI}" != "true" ]; then | ||
trap cleanup INT TERM EXIT | ||
cleanup () { | ||
kill "${MODEL_SERVER_PID}" | ||
exit | ||
} | ||
fi | ||
|
||
./gradlew runModelServer --console=plain & | ||
MODEL_SERVER_PID=$! | ||
sleep 5 | ||
|
||
#CI needs more time | ||
if [ "${CI}" = "true" ]; then | ||
sleep 10 | ||
fi | ||
|
||
curl -X POST http://127.0.0.1:28101/v2/repositories/ci-test/init | ||
|
||
./gradlew runSyncTestPush --console=plain --stacktrace | ||
./gradlew test --tests 'PushTest' | ||
./gradlew runSyncTestPull --console=plain --stacktrace | ||
./gradlew test --tests 'PullTest' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
kotlin.code.style=official |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../gradle/wrapper/gradle-wrapper.jar |
6 changes: 6 additions & 0 deletions
6
bulk-model-sync-gradle-test/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../gradlew |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../gradlew.bat |
73 changes: 73 additions & 0 deletions
73
bulk-model-sync-gradle-test/graph-lang-api/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
plugins { | ||
id("org.modelix.model-api-gen") | ||
`maven-publish` | ||
alias(libs.plugins.kotlin.jvm) | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
gradlePluginPortal() | ||
maven { url = uri("https://artifacts.itemis.cloud/repository/maven-mps/") } | ||
mavenCentral() | ||
} | ||
|
||
val modelixCoreVersion = file("../../version.txt").readText() | ||
|
||
version = modelixCoreVersion | ||
|
||
val mps: Configuration by configurations.creating | ||
val kotlinGenDir = buildDir.resolve("metamodel/kotlin").apply { mkdirs() } | ||
|
||
dependencies { | ||
mps("com.jetbrains:mps:2021.2.5") | ||
api("org.modelix:model-api-gen-runtime:$modelixCoreVersion") | ||
} | ||
|
||
val mpsDir = buildDir.resolve("mps").apply { mkdirs() } | ||
|
||
val resolveMps by tasks.registering(Copy::class) { | ||
from(mps.resolve().map { zipTree(it) }) | ||
into(mpsDir) | ||
} | ||
|
||
val repoDir = projectDir.resolve("test-repo") | ||
|
||
val copyMetamodelToMpsHome by tasks.registering(Copy::class) { | ||
from(file(projectDir.resolve("../test-repo/languages"))) | ||
into(file(mpsDir.resolve("languages").apply { mkdirs() })) | ||
} | ||
|
||
kotlin { | ||
sourceSets.named("main") { | ||
kotlin.srcDir(kotlinGenDir) | ||
} | ||
} | ||
|
||
metamodel { | ||
dependsOn(resolveMps) | ||
dependsOn(copyMetamodelToMpsHome) | ||
mpsHome = mpsDir | ||
kotlinDir = kotlinGenDir | ||
includeLanguage("GraphLang") | ||
registrationHelperName = "org.modelix.model.sync.bulk.gradle.test.GraphLanguagesHelper" | ||
} | ||
|
||
publishing { | ||
publications { | ||
create<MavenPublication>("maven") { | ||
groupId = "org.modelix" | ||
from(components["kotlin"]) | ||
} | ||
} | ||
repositories { | ||
mavenLocal() | ||
} | ||
} | ||
|
||
tasks.named("processResources") { | ||
dependsOn("generateMetaModelSources") | ||
} | ||
|
||
tasks.named("compileKotlin") { | ||
dependsOn("generateMetaModelSources") | ||
} |
Oops, something went wrong.