-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
357 lines (296 loc) · 11.9 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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
import de.itemis.mps.gradle.*
import de.itemis.mps.gradle.downloadJBR.*
import de.itemis.mps.gradle.tasks.*
plugins {
id 'de.itemis.mps.gradle.common' version '1.28.0.+'
id 'download-jbr' version '1.28.0.+'
id 'base'
id 'maven-publish'
id 'co.riiid.gradle' version '0.4.2'
id 'de.itemis.mps.gradle.launcher' version '2.5.2.+'
}
ext.jbrVers = '21.0.5-b631.8'
downloadJbr {
jbrVersion = jbrVers
}
// detect if we are in a CI build
if (System.env.CI != null && System.env.CI.toBoolean()) {
// is this github
ext.ciBuild = true
} else {
// on teamcity we are in a CI build
ext.ciBuild = project.hasProperty("teamcity")
}
// Project versions
ext.major = '999'
ext.minor = '9'
if (ciBuild) {
String branch = GitBasedVersioning.gitBranch
def buildNumber = System.env.GITHUB_RUN_NUMBER != null ? System.env.GITHUB_RUN_NUMBER.toInteger() : System.env.BUILD_NUMBER.toInteger()
if (branch.startsWith("maintenance") || branch.startsWith("mps")) {
version = "$major.$minor.$buildNumber.${GitBasedVersioning.gitShortCommitHash}"
} else {
version = GitBasedVersioning.getVersionWithCount(major, minor, buildNumber)
}
println "##teamcity[buildNumber '${version}']"
} else {
println "Local build detected, version will be SNAPSHOT"
version = "$major.$minor-SNAPSHOT"
}
configurations {
mps
languageLibs
// includes also junit tasks support
antLib
}
dependencies {
// Use the following dependency for published releases:
// mps 'com.jetbrains:mps:2024.3'
mps 'com.jetbrains.mps:mps-prerelease:243.21565.10057'
antLib "org.apache.ant:ant-junit:1.10.15"
antLib "org.jacoco:org.jacoco.ant:0.8.12"
}
repositories {
maven {
url 'https://maven.pkg.github.com/mbeddr/*'
credentials {
username = project.findProperty("github_username") ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("github_token") ?: System.getenv("GITHUB_TOKEN")
}
}
maven {
url 'https://artifacts.itemis.cloud/repository/maven-mps/'
}
mavenCentral()
}
ext.skipResolveMps = project.hasProperty('mpsHomeDir')
ext.mpsHomeDir = rootProject.file(project.findProperty('mpsHomeDir') ?: "$buildDir/mps")
if (project.skipResolveMps) {
task resolveMps {
doLast {
logger.info "MPS resolution skipped"
logger.info "MPS home: " + mpsHomeDir.getAbsolutePath()
}
}
} else {
task resolveMps(type: Sync) {
dependsOn configurations.mps
from {
configurations.mps.resolve().collect { zipTree(it) }
}
into mpsHomeDir
}
}
// tools needed for compiler support in ant calls
ext.buildScriptClasspath = project.configurations.antLib
def artifactsDir = file("$buildDir/artifacts")
def dependenciesDir = file("$buildDir/dependencies")
// ___________________ utilities ___________________
def defaultScriptArgs = [
'mps.home' : mpsHomeDir,
'mps_home' : mpsHomeDir,
'build.jna.library.path' : new File(mpsHomeDir, "lib/jna/${System.getProperty('os.arch')}"),
'mpsqa.home' : rootDir,
'build.dir' : buildDir,
'version' : version,
'build.date' : new Date(),
]
// enables https://github.com/mbeddr/mps-gradle-plugin#providing-global-defaults
task configureJava {
dependsOn "downloadJbr"
doLast {
project.ext["itemis.mps.gradle.ant.defaultScriptArgs"] = defaultScriptArgs.collect { "-D$it.key=$it.value".toString() }
project.ext["itemis.mps.gradle.ant.defaultScriptClasspath"] = buildScriptClasspath
project.ext["itemis.mps.gradle.ant.defaultJavaExecutable"] = tasks.getByName("downloadJbr").javaExecutable
println project.findProperty("itemis.mps.gradle.ant.defaultJavaExecutable")
}
}
// All MPS tasks depend on configureJava and resolveMps
tasks.withType(RunAntScript).configureEach {
dependsOn(configureJava, resolveMps)
}
File scriptFile(String name) {
file("$buildDir/scripts/$name")
}
def build_allScripts = tasks.register('build_allScripts', BuildLanguages) {
script scriptFile('build_all_scripts.xml')
}
// All other MPS tasks depend on build_allScripts
tasks.withType(RunAntScript).configureEach {
if (it.name != build_allScripts.name) {
it.dependsOn(build_allScripts)
}
}
task build_base_languages(type: BuildLanguages) {
script scriptFile('build-base-languages.xml')
}
task build_testing_languages(type: BuildLanguages, dependsOn: [build_base_languages]) {
script scriptFile('build-testing-languages.xml')
}
task test_testing(type: TestLanguages, dependsOn: [build_testing_languages]) {
// MPS build language generator is confused about the basedir of the generated script so we set it manually
scriptArgs = ["-Dbasedir=${file('code/languages/org.mpsqa.testing')}"]
script scriptFile("test-testing.xml")
}
task build_clones_languages(type: BuildLanguages, dependsOn: [build_base_languages]) {
script scriptFile("build-clones-languages.xml")
}
task build_mutant_languages(type: BuildLanguages, dependsOn: []) {
script scriptFile("build-mutant-languages.xml")
}
task build_unused_languages(type: BuildLanguages, dependsOn: []) {
script scriptFile("build-unused-languages-analysis.xml")
}
task build_arch_languages(type: BuildLanguages, dependsOn: []) {
script scriptFile("build-arch-analysis-languages.xml")
}
task build_deprecation_analysis_languages(type: BuildLanguages, dependsOn: []) {
script scriptFile("build-deprecated-analysis-languages.xml")
}
task build_lint_analysis_languages(type: BuildLanguages, dependsOn: []) {
script scriptFile("build-lint-analysis-languages.xml")
}
task build_profile_languages(type: BuildLanguages, dependsOn: []) {
script scriptFile("build-profile-languages.xml")
}
task build_sandboxes(type: BuildLanguages) {
dependsOn 'build_base_languages'
dependsOn 'build_unused_languages'
dependsOn 'build_unused_languages'
dependsOn ':testing:sandbox:assemble'
script "$buildDir/scripts/build-sandboxes.xml"
}
tasks.register('build_main_languages') {
dependsOn 'build_base_languages'
dependsOn 'build_testing_languages'
dependsOn 'build_clones_languages'
dependsOn 'build_mutant_languages'
dependsOn 'build_unused_languages'
dependsOn 'build_arch_languages'
dependsOn 'build_deprecation_analysis_languages'
dependsOn 'build_lint_analysis_languages'
dependsOn 'build_profile_languages'
}
tasks.register('build_all_languages') {
dependsOn 'build_main_languages'
dependsOn 'build_sandboxes'
}
task build_allInOne_package(type: BuildLanguages, dependsOn: [build_allScripts]) {
dependsOn 'build_main_languages'
script scriptFile("build-allInOne-package.xml")
}
task package_mpsqa(type: Zip, dependsOn: build_allInOne_package) {
archiveBaseName = 'org.mpsqa'
from artifactsDir
include 'org.mpsqa.allInOne/**'
}
task test_clones(type: TestLanguages, dependsOn: build_clones_languages) {
description "Will execute clones tests from command line"
script scriptFile("test-clones.xml")
}
task test_lint(type: TestLanguages, dependsOn: build_lint_analysis_languages) {
description "Will execute lint tests from command line"
script scriptFile("build-lint-tests.xml")
}
tasks.register('check_lint', MpsCheck) {
dependsOn(resolveMps)
dependsOn(build_lint_analysis_languages)
projectLocation = file('code/languages/org.mpsqa.lint')
mpsHome = mpsHomeDir
folderMacros.put('mpsqa.home', rootProject.layout.projectDirectory)
pluginRoots.add(layout.dir(provider { new File(mpsHomeDir, 'plugins/mps-console') }))
pluginRoots.add(layout.dir(provider { new File(mpsHomeDir, 'plugins/mps-modelchecker') }))
}
check.dependsOn(tasks.withType(TestLanguages))
assemble.dependsOn(tasks.withType(BuildLanguages))
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/mbeddr/mps-qa")
credentials {
username = project.findProperty("github_username") ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("github_token") ?: System.getenv("GITHUB_TOKEN")
}
}
if (project.hasProperty("artifacts.itemis.cloud.user") && project.hasProperty("artifacts.itemis.cloud.pw")) {
maven {
name = "ItemisNexus"
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")
}
}
}
}
publications {
MPSQA(MavenPublication) {
groupId 'org.mpsqa'
artifactId 'all-in-one'
artifact package_mpsqa
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.languageLibs.resolvedConfiguration.firstLevelModuleDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.moduleGroup)
dependencyNode.appendNode('artifactId', it.moduleName)
dependencyNode.appendNode('version', it.moduleVersion)
dependencyNode.appendNode('type', it.moduleArtifacts[0].type)
}
configurations.mps.resolvedConfiguration.firstLevelModuleDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.moduleGroup)
dependencyNode.appendNode('artifactId', it.moduleName)
dependencyNode.appendNode('version', it.moduleVersion)
dependencyNode.appendNode('type', it.moduleArtifacts[0].type)
dependencyNode.appendNode('scope', 'provided')
}
}
}
}
}
task cleanMps(type: Delete) {
delete fileTree(dir: projectDir, include: ["**/classes_gen/**", "**/source_gen/**", "**/source_gen.caches/**", "tmp/**"])
}
clean.dependsOn cleanMps
defaultTasks 'build'
task rebuild(dependsOn:[clean, build_allInOne_package])
ext.allProjectDirectoriesInDependencyOrder = [
'org.mpsqa.base',
'org.mpsqa.testing',
'org.mpsqa.build',
'org.mpsqa.arch',
'org.mpsqa.clones',
'org.mpsqa.deprecated',
'org.mpsqa.lint',
'org.mpsqa.mutant',
'org.mpsqa.profile',
'org.mpsqa.testing',
'org.mpsqa.unused'
].collect { file("code/languages/$it") }
ext.mpsPluginRoots = ['mps-build', 'mps-console', 'mps-trove', 'mps-modelchecker', 'mps-testing']
.collect { new File(mpsHomeDir, "plugins/$it") }
ext.jbrJavaLauncher = tasks.named('downloadJbr', DownloadJbrForPlatform).flatMap { it.javaLauncher }
tasks.register('migrate', MpsMigrate) {
dependsOn(resolveMps, 'downloadJbr', 'build_all_languages')
javaLauncher = jbrJavaLauncher
mpsHome = mpsHomeDir
folderMacros.put('mpsqa.home', layout.projectDirectory)
projectDirectories.from(allProjectDirectoriesInDependencyOrder)
pluginRoots.from(mpsPluginRoots)
haltOnPrecheckFailure = true
haltOnDependencyError = true
}
tasks.register('remigrate', Remigrate) {
dependsOn(resolveMps, 'downloadJbr')
mustRunAfter('migrate')
// Technically we don't need to _depend_ on build_all_languages because we can opt to rerun only migrations that
// come from MPS.
mustRunAfter('build_all_languages')
javaLauncher = jbrJavaLauncher
mpsHome = mpsHomeDir
folderMacros.put('mpsqa.home', layout.projectDirectory)
projectDirectories.from(allProjectDirectoriesInDependencyOrder)
pluginRoots.from(mpsPluginRoots)
}