-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
179 lines (159 loc) · 6.13 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
import org.jetbrains.intellij.tasks.BuildPluginTask
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
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport
import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension
import org.modelix.copyMps
import org.semver.Version
buildscript {
dependencies {
classpath(coreLibs.semver)
classpath(libs.modelix.build.tools.lib)
}
}
plugins {
`maven-publish`
id("com.palantir.git-version") version "3.1.0"
id("com.dorongold.task-tree") version "4.0.0"
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.serialization) apply false
id("org.jetbrains.intellij") version "1.17.4" apply false
alias(libs.plugins.npm.publish) apply false
}
group = "org.modelix"
description = "KernelF editor implemented with Modelix "
version = computeVersion()
println("Version: $version")
fun computeVersion(): Any {
val versionFile = file("version.txt")
if (versionFile.exists()) return versionFile.readText().trim()
val gitVersion: groovy.lang.Closure<String> by extra
var version = if (versionFile.exists()) versionFile.readText().trim() else gitVersion()
if (!versionFile.exists() && "true" != project.findProperty("ciBuild")) {
version = "$version-SNAPSHOT"
}
// NPM requires a valid semantic version
try {
Version.parse(version)
} catch (_: IllegalArgumentException) {
version = "0.0.0-$version"
}
versionFile.writeText(version)
return version
}
val tsModelApiPath = rootDir.parentFile.resolve("modelix.core").resolve("ts-model-api")
val tsModelApiVersion = "3.16.0" // if (tsModelApiPath.exists()) "file:${tsModelApiPath.absolutePath}" else libs.versions.modelixCore.get()
ext.set("ts-model-api.version", tsModelApiVersion)
subprojects {
apply(plugin = "maven-publish")
version = rootProject.version
group = rootProject.group
repositories {
maven { url = uri("https://artifacts.itemis.cloud/repository/maven-mps/") }
maven { url = uri("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") }
mavenCentral()
mavenLocal()
}
}
allprojects {
publishing {
repositories {
if (project.hasProperty("artifacts.itemis.cloud.user")) {
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()
}
}
}
}
}
}
subprojects {
val sourceFile = rootDir.resolve(".npmrc")
val targetFile = projectDir.resolve(".npmrc")
if (!targetFile.exists() && sourceFile.exists() && projectDir.resolve("package.json").exists()) {
sourceFile.copyTo(targetFile)
}
val kotlinApiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_1_8
plugins.withType<JavaPlugin> {
extensions.configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
}
plugins.withType<KotlinPlatformJvmPlugin> {
extensions.configure<KotlinJvmProjectExtension> {
jvmToolchain(17)
sourceSets.all {
if (!name.lowercase().contains("test")) {
languageSettings {
apiVersion = kotlinApiVersion.version
}
}
}
}
}
plugins.withType<KotlinMultiplatformPluginWrapper> {
extensions.configure<KotlinMultiplatformExtension> {
jvmToolchain(17)
sourceSets.all {
if (!name.lowercase().contains("test")) {
languageSettings {
apiVersion = kotlinApiVersion.version
}
}
}
}
}
}
rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin::class.java) {
rootProject.the<YarnRootExtension>().yarnLockMismatchReport =
YarnLockMismatchReport.WARNING // NONE | FAIL
rootProject.the<YarnRootExtension>().reportNewYarnLock = false // true
rootProject.the<YarnRootExtension>().yarnLockAutoReplace = false // true
}
copyMps()
// make all 'packJsPackage' tasks depend on all 'kotlinNodeJsSetup' tasks, because gradle complained about this being missing
tasks.register("setupNodeEverywhere") {
dependsOn(":kernelf-apigen:kotlinNodeJsSetup")
dependsOn(":kernelf-editor:kotlinNodeJsSetup")
dependsOn(":parser:kotlinNodeJsSetup")
dependsOn(":projectional-editor:kotlinNodeJsSetup")
dependsOn(":projectional-editor-ssr-client:kotlinNodeJsSetup")
dependsOn(":projectional-editor-ssr-client-lib:kotlinNodeJsSetup")
dependsOn(":projectional-editor-ssr-common:kotlinNodeJsSetup")
}
val packageAllPlugins by tasks.registering(Zip::class) {
val zipTask = this
archiveBaseName = "all-editor-plugins"
subprojects {
tasks.all {
if (this.name == "buildPlugin") {
val buildPluginTask = this as BuildPluginTask
zipTask.dependsOn(buildPluginTask)
zipTask.from(zipTree(buildPluginTask.archiveFile))
}
}
}
}
// publish all-editor-plugins.zip to GitHub packages to make it appear on the releases page
publishing {
publications {
create<MavenPublication>("maven") {
artifactId = "all-editor-plugins"
artifact(packageAllPlugins) {
extension = "zip"
}
}
}
}