Skip to content

Commit

Permalink
moved mps-legacy-sync-plugin from modelix.core to here
Browse files Browse the repository at this point in the history
It's the original implementation of the synchronization plugin between MPS and the model server. It was copied from https://github.com/modelix/modelix/tree/mps/2021.1/mps/org.modelix.model.mpsplugin . Also rescued most of the tests from https://github.com/modelix/modelix/tree/mps/2021.1/integrationtests .
  • Loading branch information
slisson committed Dec 9, 2023
1 parent 882c632 commit 397bb3c
Show file tree
Hide file tree
Showing 148 changed files with 10,788 additions and 23,895 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "gradle"
open-pull-requests-limit: 20
directory: "/"
schedule:
interval: "daily"
36 changes: 36 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build

on:
push:
branches:
- 'main'
pull_request: {}
# allow manual execution just in case
workflow_dispatch:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Gradle
uses: gradle/gradle-build-action@v2
- name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew --build-cache build -PciBuild=true
- name: Archive test report
uses: actions/upload-artifact@v3
if: always()
with:
name: test-report
path: |
*/build/test-results
*/build/reports
12 changes: 12 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Code linting

on:
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
43 changes: 43 additions & 0 deletions .github/workflows/mps-compatibility.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: MPS compatibility

on:
push:
branches:
- 'main'
pull_request: {}
# allow manual execution just in case
workflow_dispatch:

jobs:
build-mps-components:

runs-on: ubuntu-latest

strategy:
matrix:
version:
# Testing with the first and last version of the supported range should be enough. Breaking changes usually stay there
# after being introduced. It's not expected that an incompatibility only exists in some intermediate version and then
# becomes compatible again.
# - "2020.3.6" VersionFixer was replaced by ModuleDependencyVersions in 2021.1 (used by model-sync-plugin)
- "2021.1.4"
# - "2021.2.6"
# - "2021.3.3"
# - "2022.2"
# - "2022.3"
- "2023.2"

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Gradle
uses: gradle/gradle-build-action@v2
- name: Build with ${{ matrix.version }}
run: >-
./gradlew --build-cache
mpsCompatibility
-Pmps.version=${{ matrix.version }}
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish

on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
workflow_dispatch:

jobs:
newRelease:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.3.0'
registry-url: 'https://artifacts.itemis.cloud/repository/npm-open/'
scope: '<@modelix>'
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Gradle
uses: gradle/gradle-build-action@v2
- name: Use tag as version
run: echo "${GITHUB_REF#refs/*/}" > version.txt
- name: Build and Publish Artifacts
run: ./gradlew --build-cache build publish -PciBuild=true -Partifacts.itemis.cloud.user=${{secrets.ARTIFACTS_ITEMIS_CLOUD_USER}} -Partifacts.itemis.cloud.pw=${{secrets.ARTIFACTS_ITEMIS_CLOUD_PW}} -Pgpr.user=${{ github.actor }} -Pgpr.key=${{ secrets.GITHUB_TOKEN }} -Pgpr.universalkey=${{ secrets.GHP_UNIVERSAL_PUBLISH_TOKEN }}
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.gradle/
/build/
/*/build/
.DS_Store
.gradletasknamecache
.idea/
*.iml
kotlin_gen
/version.txt
/node_modules
**/.ideaconfig
**/.mpsconfig
$LOG_DIR$
51 changes: 51 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
default_install_hook_types:
- pre-commit
- commit-msg
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-toml
- id: check-yaml
- id: check-added-large-files
- id: check-merge-conflict
- id: check-symlinks
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.4.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ["@commitlint/config-angular"]
args: ["--config", "./commitlint.config.js"]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.10.0
hooks:
- id: pretty-format-kotlin
args:
# IMPORTANT: keep in sync with the version configured in build.gradle.kts
- --ktlint-version=0.50.0
- --autofix
- repo: https://github.com/pre-commit/mirrors-prettier
# IMPORTANT: keep in sync with the version configured in `vue-model-api/package.json`
rev: v3.0.3
hooks:
- id: prettier
files: ^(vue-model-api)|(model-api-gen-gradle-test/vue-integration)/
- repo: https://github.com/pre-commit/mirrors-eslint
# IMPORTANT: keep versions of hook and additional dependencies in sync with the versions configured in `vue-model-api/package.json`
rev: v8.50.0
hooks:
- id: eslint
additional_dependencies:
- "[email protected]"
- "[email protected]"
- "@typescript-eslint/[email protected]"
- "@typescript-eslint/[email protected]"
files: ^vue-model-api/src/
'types': [ts]
152 changes: 152 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin

buildscript {
dependencies {
classpath(coreLibs.semver)
}
}

plugins {
`maven-publish`
`version-catalog`
alias(coreLibs.plugins.kotlin.multiplatform) apply false
alias(coreLibs.plugins.kotlin.serialization) apply false
alias(coreLibs.plugins.gitVersion)
alias(coreLibs.plugins.node) apply false
}

group = "org.modelix.mps"
version = computeVersion()
println("Version: $version")

fun computeVersion(): Any {
val versionFile = file("version.txt")
val gitVersion: groovy.lang.Closure<String> by extra
return if (versionFile.exists()) {
versionFile.readText().trim()
} else {
gitVersion()
// Avoid duplicated "-SNAPSHOT" ending
.let { if (it.endsWith("-SNAPSHOT")) it else "$it-SNAPSHOT" }
// Normalize the version so that is always a valid NPM version.
.let { if (it.matches("""\d+\.\d+.\d+-.*""".toRegex())) it else "0.0.1-$it" }
.also { versionFile.writeText(it) }
}
}

val parentProject = project

subprojects {
val subproject = this
apply(plugin = "maven-publish")

version = rootProject.version
group = rootProject.group

val kotlinApiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_6
subproject.tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "11"
freeCompilerArgs += listOf("-Xjvm-default=all-compatibility")
if (!name.lowercase().contains("test")) {
apiVersion = kotlinApiVersion.version
}
}
}
subproject.tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile>().configureEach {
kotlinOptions {
jvmTarget = "11"
freeCompilerArgs += listOf("-Xjvm-default=all-compatibility")
if (!name.lowercase().contains("test")) {
apiVersion = kotlinApiVersion.version
}
}
}

subproject.plugins.withType<JavaPlugin> {
subproject.extensions.configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}

subproject.plugins.withType<KotlinPlatformJvmPlugin> {
subproject.extensions.configure<KotlinJvmProjectExtension> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}
}

subproject.plugins.withType<KotlinMultiplatformPluginWrapper> {
subproject.extensions.configure<KotlinMultiplatformExtension> {
sourceSets.all {
if (!name.lowercase().contains("test")) {
languageSettings {
apiVersion = kotlinApiVersion.version
}
}
}
}
}
}

allprojects {
repositories {
mavenLocal()
maven { url = uri("https://artifacts.itemis.cloud/repository/maven-mps/") }
mavenCentral()
maven { url = uri("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") }
}

publishing {
repositories {
maven {
name = "itemis"
url = if (version.toString().contains("SNAPSHOT")) {
uri("https://artifacts.itemis.cloud/repository/maven-mps-snapshots/")
} else {
uri("https://artifacts.itemis.cloud/repository/maven-mps-releases/")
}
credentials {
username = project.findProperty("artifacts.itemis.cloud.user").toString()
password = project.findProperty("artifacts.itemis.cloud.pw").toString()
}
}
}
}
}

val mpsVersion = project.findProperty("mps.version")?.toString()?.takeIf { it.isNotEmpty() }
?: "2023.2".also { ext["mps.version"] = it }
println("Building for MPS version $mpsVersion")
val mpsJavaVersion = if (mpsVersion >= "2022.2") 17 else 11
ext["mps.java.version"] = mpsJavaVersion

// Extract MPS during configuration phase, because using it in intellij.localPath requires it to already exist.
val mpsHome = project.layout.buildDirectory.dir("mps-$mpsVersion")
val mpsZip by configurations.creating
dependencies { mpsZip("com.jetbrains:mps:$mpsVersion") }
mpsHome.get().asFile.let { baseDir ->
if (baseDir.exists()) return@let // content of MPS zip is not expected to change

println("Extracting MPS ...")
sync {
from(zipTree({ mpsZip.singleFile }))
into(mpsHome)
}

// The build number of a local IDE is expected to contain a product code, otherwise an exception is thrown.
val buildTxt = mpsHome.get().asFile.resolve("build.txt")
val buildNumber = buildTxt.readText()
val prefix = "MPS-"
if (!buildNumber.startsWith(prefix)) {
buildTxt.writeText("$prefix$buildNumber")
}

println("Extracting MPS done.")
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.gradle.jvmargs=-Xmx1024m "-XX:MaxMetaspaceSize=2g"
systemProp.org.gradle.internal.http.socketTimeout=120000
kotlin.daemon.jvmargs=-Xmx2G
23 changes: 23 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[bundles]

[plugins]
modelix-model-api-gen = { id = "org.modelix.model-api-gen", version.ref = "modelixCore" }
npm-publish = { id = "dev.petuska.npm.publish", version = "3.4.1" }

[versions]
modelixCore = "3.15.0"

[libraries]
modelix-model-api = { group = "org.modelix", name = "model-api", version.ref = "modelixCore" }
modelix-model-api-gen-runtime = { group = "org.modelix", name = "model-api-gen-runtime", version.ref = "modelixCore" }
modelix-light-model-client = { group = "org.modelix", name = "light-model-client", version.ref = "modelixCore" }
modelix-authorization = { group = "org.modelix", name = "authorization", version.ref = "modelixCore" }
modelix-model-client = { group = "org.modelix", name = "model-client", version.ref = "modelixCore" }
modelix-model-server = { group = "org.modelix", name = "model-server", version.ref = "modelixCore" }
modelix-modelql-core = { group = "org.modelix", name = "modelql-core", version.ref = "modelixCore" }
modelix-modelql-untyped = { group = "org.modelix", name = "modelql-untyped", version.ref = "modelixCore" }
modelix-modelql-html = { group = "org.modelix", name = "modelql-html", version.ref = "modelixCore" }
modelix-model-datastructure = { group = "org.modelix", name = "model-datastructure", version.ref = "modelixCore" }
modelix-mps-model-adapters = { group = "org.modelix.mps", name = "model-adapters", version.ref = "modelixCore" }
kotlin-logging = { group = "io.github.oshai", name = "kotlin-logging", version = "5.1.0" }
kotlin-html = "org.jetbrains.kotlinx:kotlinx-html:0.10.1"
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 397bb3c

Please sign in to comment.