Skip to content

Commit 3bf3f8d

Browse files
committed
Merge remote-tracking branch 'origin/main' into feature/MODELIX-461-Enable-ktlint-in-modelix-core
2 parents 93b37be + dc419d5 commit 3bf3f8d

File tree

12 files changed

+119
-20
lines changed

12 files changed

+119
-20
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: MPS compatibility
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
pull_request: {}
8+
# allow manual execution just in case
9+
workflow_dispatch:
10+
11+
jobs:
12+
build-mps-model-adapters:
13+
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Set up JDK 11
19+
uses: actions/setup-java@v3
20+
with:
21+
distribution: 'temurin'
22+
java-version: '11'
23+
- name: Build with MPS 2020.3.6
24+
run: ./gradlew :mps-model-adapters:build -Pmps.version=2020.3.6
25+
- name: Build with MPS 2021.1.4
26+
run: ./gradlew :mps-model-adapters:build -Pmps.version=2021.1.4
27+
- name: Build with MPS 2021.2.6
28+
run: ./gradlew :mps-model-adapters:build -Pmps.version=2021.2.6
29+
- name: Build with MPS 2021.3.3
30+
run: ./gradlew :mps-model-adapters:build -Pmps.version=2021.3.3
31+
- name: Build with MPS 2022.2
32+
run: ./gradlew :mps-model-adapters:build -Pmps.version=2022.2
33+
- name: Build with MPS 2022.3
34+
run: ./gradlew :mps-model-adapters:build -Pmps.version=2022.3

build.gradle.kts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ plugins {
3838
alias(libs.plugins.dokka)
3939
}
4040

41-
repositories {
42-
mavenLocal()
43-
maven { url = uri("https://artifacts.itemis.cloud/repository/maven-mps/") }
44-
mavenCentral()
45-
}
46-
4741
group = "org.modelix"
4842
description = "Projectional Editor"
4943
version = computeVersion()
@@ -88,7 +82,9 @@ subprojects {
8882
freeCompilerArgs += listOf("-Xjvm-default=all-compatibility")
8983
}
9084
}
85+
}
9186

87+
allprojects {
9288
repositories {
9389
mavenLocal()
9490
maven { url = uri("https://artifacts.itemis.cloud/repository/maven-mps/") }

docs/global/modules/core/pages/reference/component-model-api-gen-gradle.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ Inside of the `metamodel` block the following settings can be configured.
8282
|File
8383
|Target Kotlin directory of the generator
8484

85+
|`modelqlKotlinDir`
86+
|File
87+
|The generation of the ModelQL API is optional, because the output has a dependency on the ModelQL runtime.
88+
If this option is set, you have to add a dependency on `org.modelix:modelql-typed`.
89+
90+
Can be the same as `kotlinDir` or a directory in a separate subproject,
91+
if you run into memory issues of the Kotlin compiler.
92+
8593
|`kotlinProject`
8694
|Project
8795
|Target Kotlin project of the generator

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ dokka = {id = "org.jetbrains.dokka", version = "1.8.20"}
2020
[versions]
2121
kotlin = "1.9.0"
2222
kotlinCoroutines="1.7.3"
23-
ktor="2.3.2"
23+
ktor="2.3.3"
2424
kotlinHtml="0.8.0"
2525
kotlinSerialization="1.5.1"
2626
ignite="2.15.0"
27-
apacheCxf="3.5.5"
27+
apacheCxf="3.6.1"
2828

2929
[libraries]
3030

@@ -64,7 +64,7 @@ ktor-serialization-json = { group = "io.ktor", name = "ktor-serialization-kotlin
6464

6565
keycloak-authz-client = { group = "org.keycloak", name = "keycloak-authz-client", version = "22.0.1" }
6666
guava = { group = "com.google.guava", name = "guava", version = "32.1.2-jre" }
67-
modelix-incremental = { group = "org.modelix", name = "incremental", version = "0.1.4" }
67+
modelix-incremental = { group = "org.modelix", name = "incremental", version = "0.2.0" }
6868
kotlinpoet = { group = "com.squareup", name = "kotlinpoet", version = "1.14.2" }
6969
vavr = { group = "io.vavr", name = "vavr", version = "0.10.4" }
7070
apache-commons-lang = { group = "org.apache.commons", name = "commons-lang3", version = "3.13.0" }

model-api-gen-gradle-test/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ metamodel {
9393
dependsOn(resolveMps)
9494
mpsHome = mpsDir
9595
kotlinDir = kotlinGenDir
96+
modelqlKotlinDir = kotlinGenDir
9697
kotlinProject = project
9798
typescriptDir = projectDir.resolve("typescript_src")
9899
includeNamespace("jetbrains")

model-api-gen-gradle/src/main/kotlin/org/modelix/metamodel/gradle/GenerateMetaModelSources.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ abstract class GenerateMetaModelSources @Inject constructor(of: ObjectFactory) :
3131
@Optional
3232
val kotlinOutputDir: DirectoryProperty = of.directoryProperty()
3333

34+
@get:OutputDirectory
35+
@Optional
36+
val modelqlKotlinOutputDir: DirectoryProperty = of.directoryProperty()
37+
3438
@get:OutputDirectory
3539
@Optional
3640
val typescriptOutputDir: DirectoryProperty = of.directoryProperty()
@@ -92,7 +96,11 @@ abstract class GenerateMetaModelSources @Inject constructor(of: ObjectFactory) :
9296

9397
val kotlinOutputDir = this.kotlinOutputDir.orNull?.asFile
9498
if (kotlinOutputDir != null) {
95-
val generator = MetaModelGenerator(kotlinOutputDir.toPath(), nameConfig.get())
99+
val generator = MetaModelGenerator(
100+
kotlinOutputDir.toPath(),
101+
nameConfig.get(),
102+
this.modelqlKotlinOutputDir.orNull?.asFile?.toPath()
103+
)
96104
generator.generate(processedLanguages)
97105
registrationHelperName.orNull?.let {
98106
generator.generateRegistrationHelper(it, processedLanguages)

model-api-gen-gradle/src/main/kotlin/org/modelix/metamodel/gradle/MetaModelGradlePlugin.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class MetaModelGradlePlugin : Plugin<Project> {
8787
project.afterEvaluate {
8888
generateMetaModelSources.configure { task ->
8989
settings.kotlinDir?.let { task.kotlinOutputDir.set(it) }
90+
settings.modelqlKotlinDir?.let { task.modelqlKotlinOutputDir.set(it) }
9091
settings.typescriptDir?.let { task.typescriptOutputDir.set(it) }
9192
task.includedNamespaces.addAll(settings.includedLanguageNamespaces)
9293
task.includedLanguages.addAll(settings.includedLanguages)

model-api-gen-gradle/src/main/kotlin/org/modelix/metamodel/gradle/MetaModelGradleSettings.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ open class MetaModelGradleSettings {
2020
val includedConcepts: MutableSet<String> = HashSet()
2121
val includedModules: MutableSet<String> = HashSet()
2222
var kotlinDir: File? = null
23+
var modelqlKotlinDir: File? = null
2324
var kotlinProject: Project? = null
2425
set(value) {
2526
if (kotlinDir == null && value != null) {

model-api-gen/src/main/kotlin/org/modelix/metamodel/generator/MetaModelGenerator.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import org.modelix.modelql.typed.TypedModelQL
5656
import java.nio.file.Path
5757
import kotlin.reflect.KClass
5858

59-
class MetaModelGenerator(val outputDir: Path, val nameConfig: NameConfig = NameConfig()) {
59+
class MetaModelGenerator(val outputDir: Path, val nameConfig: NameConfig = NameConfig(), val modelqlOutputDir: Path? = null) {
6060
var alwaysUseNonNullableProperties: Boolean = true
6161

6262
private val headerComment = "\ngenerated by modelix model-api-gen \n"
@@ -128,16 +128,18 @@ class MetaModelGenerator(val outputDir: Path, val nameConfig: NameConfig = NameC
128128
FileSpec.builder(language.generatedClassName().packageName, language.generatedClassName().simpleName)
129129
val file = builder.addFileComment(headerComment)
130130
.addType(generateLanguage(language)).build()
131+
file.write()
132+
131133
for (enum in language.getEnums()) {
132134
generateEnumFile(enum)
133135
}
136+
134137
for (concept in language.getConcepts()) {
135138
generateConceptFile(concept)
136-
if (concept.getOwnRoles().isNotEmpty()) {
139+
if (modelqlOutputDir != null && concept.getOwnRoles().isNotEmpty()) {
137140
generateModelQLFile(concept)
138141
}
139142
}
140-
file.write()
141143
}
142144
}
143145

@@ -469,7 +471,7 @@ class MetaModelGenerator(val outputDir: Path, val nameConfig: NameConfig = NameC
469471
}
470472
}
471473
}
472-
.build().write()
474+
.build().writeTo(modelqlOutputDir!!)
473475
}
474476

475477
private fun generateConceptObject(concept: ProcessedConcept): TypeSpec {

mps-model-adapters/build.gradle.kts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ plugins {
33
`maven-publish`
44
}
55

6+
val mpsVersion = project.findProperty("mps.version")?.toString().takeIf { !it.isNullOrBlank() } ?: "2020.3.6"
7+
68
dependencies {
79
api(project(":model-api"))
810

9-
compileOnly("com.jetbrains:mps-openapi:2021.1.4")
10-
compileOnly("com.jetbrains:mps-core:2021.1.4")
11-
compileOnly("com.jetbrains:mps-environment:2021.1.4")
11+
compileOnly("com.jetbrains:mps-openapi:$mpsVersion")
12+
compileOnly("com.jetbrains:mps-core:$mpsVersion")
13+
compileOnly("com.jetbrains:mps-environment:$mpsVersion")
1214

1315
implementation(kotlin("stdlib"))
1416
implementation(libs.kotlin.logging)

0 commit comments

Comments
 (0)