|
| 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 | +} |
0 commit comments