-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
287 lines (233 loc) · 8.54 KB
/
build.gradle
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
plugins {
id 'de.undercouch.download' version '5.6.0'
id 'base'
id 'maven-publish'
}
import de.undercouch.gradle.tasks.download.Download
import java.util.regex.Pattern
if (!project.hasProperty('mpsVersion')) {
throw new GradleException("mpsVersion property must be defined, example: '2024.1.2' or '2024.2-EAP1'")
}
def mpsMajorRegex = Pattern.compile(/^(\d{4}\.\d)(?!\d)/) // four digits, '.', a digit, not immediately followed by a digit
def mpsMajorMatcher = mpsMajorRegex.matcher(project.mpsVersion)
if (!mpsMajorMatcher.find()) {
throw new GradleException("mpsVersion property must begin with a version number, example: '2024.1.2' or '2024.2-EAP1'")
}
ext.mpsMajor = mpsMajorMatcher.group(1)
def mpsUnzipDir = layout.buildDirectory.dir("MPS-${mpsVersion}").get().asFile
def mpsDownloadFile = layout.buildDirectory.file("MPS-${mpsVersion}.zip")
def eapSuffix = (mpsVersion.contains("EAP")) ? " EAP" : ""
def mpsUnpackedDir = new File(mpsUnzipDir, "MPS ${mpsMajor}${eapSuffix}")
task testPackaging{
description "Task triggering all packaging tasks"
}
testPackaging.dependsOn {
tasks.withType(Jar).findAll {jarTask -> jarTask.name.startsWith('package')}
}
// Downloads MPS from jetbrains.com into ${mpsDownloadFile}
task downloadMPS(type: Download) {
src "http://download.jetbrains.com/mps/${mpsMajor}/MPS-${mpsVersion}.zip"
dest mpsDownloadFile
overwrite false
}
task unzipMPS(type: Sync, dependsOn: downloadMPS) {
from(zipTree(mpsDownloadFile))
into(mpsUnzipDir)
}
task publishMPS(type: Zip, dependsOn: unzipMPS) {
from mpsUnpackedDir
}
def additionalPomInfo = {
licenses {
// official SPDX identifier
// see https://spdx.org/licenses/ for list
license {
name = "Apache-2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
comments = "A business-friendly OSS license"
distribution = "repo"
}
}
organization {
name = "JetBrains s.r.o"
url = "https://www.jetbrains.com"
}
}
publishing {
repositories {
maven {
name = "itemisCloud"
url = uri("https://artifacts.itemis.cloud/repository/maven-mps-releases/")
credentials {
username = project.findProperty("artifacts.itemis.cloud.user")
password = project.findProperty("artifacts.itemis.cloud.pw")
}
}
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/mbeddr/build.publish.mps")
if (project.hasProperty("gpr.token")) {
credentials {
username = project.findProperty("gpr.user")
password = project.findProperty("gpr.token")
}
}
}
}
publications {
mps(MavenPublication) {
groupId 'com.jetbrains'
artifactId 'mps'
version mpsVersion
artifact publishMPS
pom additionalPomInfo
}
}
}
/*
* Repackage frequently needed JAR libraries shipping with MPS (in the lib and plugins folders) as individually consumable artifacts.
* This is useful for the development of command line utilities, Maven plugins, Gradle plugins, or other things
* that require only smaller parts of the MPS runtime and don't want to end up with a full MPS in their dependencies.
*/
class MpsJar {
final String name
String customArtifactId
String relativePath
String relativeSourcesPath
final List<String> sourceIncludes = new ArrayList<>()
MpsJar(String name) { this.name = name }
void sourcesInclude(String pattern) {
sourceIncludes.add(pattern)
}
}
def mpsJars = objects.domainObjectContainer(MpsJar) { new MpsJar(it) }
static String baseName(String file) {
if (file == null) {
throw new IllegalArgumentException("file must not be null")
}
String name = new File(file).name
int lastDot = name.lastIndexOf('.')
if (lastDot == -1) {
return name
} else {
return name.substring(0, lastDot)
}
}
void createPublicationsFromMpsJars(Iterable<MpsJar> mpsJars, mpsUnpackedDir, additionalPomInfo) {
mpsJars.each { mpsJar ->
final jarBaseName = baseName(mpsJar.relativePath)
def packageTask = tasks.register("package${mpsJar.name.capitalize()}", Jar) {
dependsOn(unzipMPS)
archiveBaseName = jarBaseName
from zipTree("${mpsUnpackedDir}/${mpsJar.relativePath}")
}
TaskProvider<Jar> packageSourcesTask
if (mpsJar.relativeSourcesPath == null) {
if (!mpsJar.sourceIncludes.isEmpty()) {
throw new IllegalArgumentException("MPS jar ${mpsJar.name} specified source include patterns but no source path")
}
packageSourcesTask = null
} else {
packageSourcesTask = tasks.register("package${mpsJar.name.capitalize()}Sources", Jar) {
dependsOn(unzipMPS)
archiveBaseName = jarBaseName
archiveClassifier = 'sources'
from(zipTree("$mpsUnpackedDir/${mpsJar.relativeSourcesPath ?: 'lib/MPS-src.zip'}")) { CopySpec spec ->
spec.include(mpsJar.sourceIncludes)
}
}
}
publishing.publications.create(mpsJar.name, MavenPublication) {
groupId 'com.jetbrains'
artifactId mpsJar.customArtifactId ?: jarBaseName
version mpsVersion
artifact packageTask
if (packageSourcesTask != null) {
artifact packageSourcesTask
}
pom additionalPomInfo
}
}
}
mpsJars.configure {
annotations {
relativePath = 'lib/annotations.jar'
}
mpsConsoleIdeCommandsRuntime {
relativePath = 'plugins/mps-console/lang/jetbrains.mps.console.ideCommands.runtime.jar'
relativeSourcesPath = 'plugins/mps-console/lang/jetbrains.mps.console.ideCommands.runtime-src.jar'
customArtifactId = 'mps-console-ide-commands-runtime'
}
mpsCore {
relativePath = 'lib/mps-core.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
}
mpsEditor {
relativePath = 'lib/mps-editor.jar'
}
mpsEditorApi {
relativePath = 'lib/mps-editor-api.jar'
}
mpsEditorRuntime {
relativePath = 'lib/mps-editor-runtime.jar'
}
mpsEnvironment {
relativePath = 'lib/mps-environment.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/tool/common/**'
sourcesInclude 'jetbrains/mps/tool/environment/**'
sourcesInclude 'jetbrains/mps/core/tool/environment/**'
}
mpsHttpsupportRuntime {
relativePath = 'plugins/mps-httpsupport/solutions/jetbrains.mps.ide.httpsupport.runtime.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/ide/httpsupport/runtime/**'
}
if (mpsVersion < '2023') {
// 2022.3 was the last version to have these jars
mpsMessaging {
relativePath = 'lib/mps-messaging.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/messages/**'
}
}
mpsModelchecker {
relativePath = 'plugins/mps-modelchecker/lib/modelchecker.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/ide/modelchecker/**'
}
mpsOpenApi {
relativePath = 'lib/mps-openapi.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'org/jetbrains/mps/**'
}
mpsPlatform {
relativePath = 'lib/mps-platform.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
}
mpsProjectCheck {
relativePath = 'lib/mps-project-check.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/checkers/**'
sourcesInclude 'jetbrains/mps/core/platform/MPSProjectValidation.java'
sourcesInclude 'jetbrains/mps/project/validation/**'
}
mpsRun {
relativePath = 'lib/mpsant/mps-run.jar'
// MPS-src.zip does not contain sources for mps-run.jar
//relativeSourcesPath = 'lib/MPS-src.zip'
}
mpsTool {
relativePath = 'lib/mpsant/mps-tool.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
sourcesInclude 'jetbrains/mps/tool/builder/**'
}
mpsWorkbench {
relativePath = 'lib/mps-workbench.jar'
}
util {
relativePath = 'lib/util.jar'
relativeSourcesPath = 'lib/MPS-src.zip'
}
}
createPublicationsFromMpsJars(mpsJars, mpsUnpackedDir, additionalPomInfo)