-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
321 lines (280 loc) · 11.4 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
import de.itemis.mps.gradle.*
//will pull the groovy classes/types from nexus to the classpath
buildscript {
repositories {
maven { url 'https://projects.itemis.de/nexus/content/repositories/mbeddr' }
}
dependencies {
classpath 'de.itemis.mps:mps-gradle-plugin:1.2.175.cc60dc8'
}
}
plugins {
id 'base'
id 'maven-publish'
}
// Detect jdk location, required to start ant with tools.jar on classpath otherwise javac and tests will fail
def jdk_home
if (ext.has('java11_home')) {
jdk_home = ext.get('java11_home')
} else if (System.getenv('JB_JAVA11_HOME') != null) {
jdk_home = System.getenv('JB_JAVA11_HOME')
} else {
def expected = JavaVersion.VERSION_11
if (JavaVersion.current() != expected) {
throw new GradleException("This build script requires Java 11 but you are currently using ${JavaVersion.current()}.\nWhat you can do:\n"
+ " * Use project property java11_home to point to the Java 11 JDK.\n"
+ " * Use environment variable JB_JAVA11_HOME to point to the Java 11 JDK\n"
+ " * Run Gradle using Java 11")
}
jdk_home = System.getProperty('java.home')
}
// Check JDK location
if (!new File(jdk_home, "lib").exists()) {
throw new GradleException("Unable to locate JDK home folder. Detected folder is: $jdk_home")
}
logger.info 'Using JDK at {}', jdk_home
ext.jdk_home = jdk_home
// detect if we are in a CI build
if (project.hasProperty("forceCI")) {
ext.ciBuild = true
} else {
//on teamcity we are in a CI build
ext.ciBuild = project.hasProperty("teamcity")
}
// Project version
def major = '2020'
def minor = '3'
// if building a against a special branch from mbeddr/iets3 opensource is required, add the name here
// the name is enough no trailing "." is required, also the plain name from git can
// be used here. No need to convert "/" the script will take care of that.
def mbeddrBranch = ''
def osBranch = ''
// Project version
if (project.hasProperty('iets3CoreVersion')) {
version = project.iets3CoreVersion
} else {
if (ciBuild) {
String gitBranch = GitBasedVersioning.gitBranch
def buildNumber = System.env.BUILD_NUMBER.toInteger()
if (gitBranch.startsWith("maintenance") || gitBranch.startsWith("mps")) {
version = "$major.$minor.$buildNumber.${GitBasedVersioning.gitShortCommitHash}"
} else {
version = GitBasedVersioning.getVersionWithCount(major, minor, buildNumber)
}
println "##teamcity[buildNumber '${version}']"
} else {
version = "$major.$minor-SNAPSHOT"
println "Local build detected, version will be $version"
}
}
def forceLocal = project.hasProperty("forceLocalDependencies")
// Dependency versions
ext.mpsVersion = '2020.3'
//ext.iets3OpenSourceVersion = '2020.1.4561.e649db7'
ext.iets3Version = '2020.3.6137.4f33f08'
//
//if (project.hasProperty('iets3OpenSourceVersion')) {
// ext.iets3OpenSourceVersion = project.iets3OpenSourceVersion
// logger.log(LogLevel.WARN, "IETS 3 open source versions externally overwritten to $ext.iets3OpenSourceVersion")
//} else {
// if (forceLocal) {
// ext.iets3OpenSourceVersion = "$major.$minor-SNAPSHOT"
// logger.log(LogLevel.WARN, "Forced local iets3.opensource of version $ext.iets3OpenSourceVersion")
// } else {
// if (osBranch != null && !osBranch.trim().isEmpty()) {
// ext.iets3OpenSourceVersion = "${osBranch.trim().replace("/", "-")}.$major.$minor.+"
// } else {
// ext.iets3OpenSourceVersion = "$major.$minor.+"
// }
// }
//}
ext.releaseRepository = 'https://projects.itemis.de/nexus/content/repositories/iets3'
ext.snapshotRepository = 'https://projects.itemis.de/nexus/content/repositories/iets3_snapshots'
ext.publishingRepository = version.toString().endsWith("-SNAPSHOT") ? snapshotRepository : releaseRepository
ext.dependencyRepositories = [
'https://projects.itemis.de/nexus/content/repositories/mbeddr',
'https://projects.itemis.de/nexus/content/repositories/mbeddr_snapshots',
'https://projects.itemis.de/nexus/content/repositories/iets3',
'https://projects.itemis.de/nexus/content/repositories/iets3_snapshots'
]
ext.artifactsDir = file("$buildDir/artifacts")
ext.incrementalBuild = !project.hasProperty("disableIncrementalBuild")
wrapper {
gradleVersion '5.5.1'
distributionType Wrapper.DistributionType.ALL
}
configurations {
mps
languageLibs
languageTestLibs
junitAnt
resolveExternalLibs
}
dependencies {
mps "com.jetbrains:mps:$mpsVersion"
// languageLibs "org.iets3:opensource:$iets3OpenSourceVersion"
// languageTestLibs("org.iets3.opensource:tests:$iets3OpenSourceVersion") {
// // don't need MPS transitive dependency
// exclude group: 'com.jetbrains', module: 'mps'
// }
languageLibs "org.iets3:core:$iets3Version"
junitAnt 'org.apache.ant:ant-junit:1.10.6'
resolveExternalLibs group: 'com.google.code.gson', name: 'gson', version: '2.8.2'
}
configurations.languageLibs {
resolutionStrategy {
// fail eagerly on version conflict (includes transitive dependencies)
failOnVersionConflict()
// e.g. multiple different versions of the same dependency (group and name are equal)
if (mbeddrBranch != null && !mbeddrBranch.trim().isEmpty()) {
force "com.mbeddr:platform:${mbeddrBranch.replace("/", "-")}.1.1+"
}
}
}
repositories {
mavenLocal()
for (repoUrl in project.dependencyRepositories) {
maven {
url repoUrl
if (project.hasProperty('nexusUsername')) {
credentials {
username project.nexusUsername
password project.nexusPassword
}
}
}
}
mavenCentral()
}
task resolveMps(type: Copy) {
dependsOn configurations.mps
from {
configurations.mps.resolve().collect { zipTree(it) }
}
into "$buildDir/mps"
}
task resolveAllLanguageLibs(type: Copy) {
from {
def configs = [configurations.languageTestLibs, configurations.languageLibs]
configs.collectMany { it.resolve() }.collect { zipTree(it) }
}
into "$buildDir/dependencies"
}
task resolveExternalLibs(type: Copy) {
from {
def configs = [configurations.languageTestLibs, configurations.languageLibs]
configs.collectMany { it.resolve() }.collect { zipTree(it) }
}
into "$buildDir/dependencies" //Copy nach lib-Folder in Ziel-Labguage.
}
// Default arguments for ant scripts
def defaultScriptArgs = [
'mps.home' : resolveMps.destinationDir,
'iets3.github.core.home' : projectDir,
'build.dir' : buildDir,
'mps.generator.skipUnmodifiedModels': incrementalBuild,
'version' : version
]
def defaultScriptClasspath = project.configurations.junitAnt.fileCollection { true } +
project.files("$ext.jdk_home/lib/tools.jar")
// enables https://github.com/mbeddr/mps-gradle-plugin#providing-global-defaults
ext["itemis.mps.gradle.ant.defaultScriptArgs"] = defaultScriptArgs.collect { "-D$it.key=$it.value".toString() }
ext["itemis.mps.gradle.ant.defaultScriptClasspath"] = defaultScriptClasspath
ext["itemis.mps.gradle.ant.defaultJavaExecutable"] = new File(jdk_home, 'bin/java')
task buildAllScripts(type: BuildLanguages, dependsOn: [resolveMps, resolveAllLanguageLibs]) {
script "$buildDir/scripts/build-allScripts.xml"
}
task buildLanguages(type: BuildLanguages, dependsOn: buildAllScripts) {
script "$buildDir/scripts/build-languages.xml"
}
task buildAndRunTests(type: TestLanguages, dependsOn: buildLanguages) { task ->
script "$buildDir/scripts/build-tests.xml"
doFirst {
// patch heap size setting for tests execution
// see https://youtrack.jetbrains.com/issue/MPS-27715
def antTestScriptFile = rootProject.file(task.script)
antTestScriptFile.text = antTestScriptFile.text.replace("-Xmx1024m", "-Xmx4096m")
}
doLast {
ant.taskdef(name: 'junitreport',
classname: 'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
classpath: configurations.junitAnt.asPath)
ant.junitreport {
fileset(dir: "$buildDir", includes: '**/TEST*.xml')
report(format: 'frames', todir: "$buildDir/junitreport")
}
ant.echo("JUnit report placed into $buildDir/junitreport/index.html")
}
}
check.dependsOn buildAndRunTests
task packageAllScripts(type: Zip, dependsOn: buildAllScripts) {
archiveBaseName = 'hansebloc.allScripts'
from artifactsDir
include 'hansebloc.build/**'
}
task packageLanguages(type: Zip, dependsOn: buildLanguages) {
archiveBaseName = 'hansebloc'
from artifactsDir
include 'hansebloc/**'
}
assemble.dependsOn packageAllScripts, packageLanguages
//def pomWithdep(pom, config, configMPS) {
// pom.withXml {
// def dependenciesNode = asNode().appendNode('dependencies')
// config.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)
// }
// configMPS.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')
// }
// }
//}
//publishing {
// repositories {
// maven {
// url project.publishingRepository
// if (project.hasProperty('nexusUsername')) {
// credentials {
// username project.nexusUsername
// password project.nexusPassword
// }
// }
// }
// }
// publications {
// allScripts(MavenPublication) {
// groupId 'hansebloc'
// artifactId 'allScripts'
// artifact packageAllScripts
// pomWithdep pom, configurations.languageLibs, configurations.mps
// }
// core(MavenPublication) {
// groupId 'org.iets3'
// artifactId 'core'
// artifact packageLanguages
// pomWithdep pom, configurations.languageLibs, configurations.mps
// }
// }
//}
task generateLibrariesXml(type: GenerateLibrariesXml) {
dependsOn resolveAllLanguageLibs
description "Will read project libraries from projectlibraries.properties and generate libraries.xml in .mps directory. Libraries are loaded in mps during start."
defaults rootProject.file('projectlibraries.properties')
overrides rootProject.file('projectlibraries.overrides.properties')
destination file('code/languages/mpszinc/.mps/libraries.xml')
}
task setup {
dependsOn generateLibrariesXml
dependsOn resolveAllLanguageLibs
description 'Set up MPS project libraries. Libraries are read in from projectlibraries.properties file.'
}
defaultTasks 'buildLanguages'