This repository has been archived by the owner on Oct 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle
195 lines (162 loc) · 5.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
//will pull the groovy classes/types from nexus to the classpath
buildscript {
repositories {
maven { url 'https://projects.itemis.de/nexus/content/repositories/mbeddr' }
mavenCentral()
}
dependencies {
classpath 'de.itemis.mps:mps-gradle-plugin:1.0+'
}
}
apply plugin: 'maven-publish'
apply plugin: 'base'
import de.itemis.mps.gradle.*
// Specify the required MPS version
ext.mpsVersion = '2019.3+'
// Specify the required mbeddr version or branch name
ext.mbeddrVersion = '2019.3.22398.30a8a0a'
// detect if we are in a CI build
if (project.hasProperty("forceCI")) {
ext.ciBuild = true
} else {
//on teamcity we are in a CI build
if (project.hasProperty("teamcity")) {
ext.ciBuild = true
} else {
ext.ciBuild = false
}
}
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()}.\nPlease do one of the following:\n"
+ " * Use project property java11_home to point to a Java 11 JDK\n"
+ " * Use the environment variable JAVA11_HOME to point to a 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")
}
ext.jdk_home = jdk_home
logger.info 'Using JDK at {}', jdk_home
// Default repository credentials
if (!project.hasProperty('nexusUsername')) {
ext.nexusUsername = ''
ext.nexusPassword = ''
}
logger.info 'Repository username: {}', project.nexusUsername
ext.dependencyRepositories = [
'https://projects.itemis.de/nexus/content/repositories/mbeddr',
'https://projects.itemis.de/nexus/content/repositories/mbeddr_snapshots',
]
// artifacts version. this is the default versioning that is used
def minor = '1'
def major = '0'
def commitHash = GitBasedVersioning.getGitShortCommitHash()
version = "$major.$minor.${GitBasedVersioning.getGitCommitCount()}.$commitHash"
ext.releaseRepository = 'https://projects.itemis.de/nexus/content/repositories/mbeddr'
ext.snapshotRepository = 'https://projects.itemis.de/nexus/content/repositories/mbeddr_snapshots'
ext.publishingRepository = version.toString().endsWith("-SNAPSHOT") ? snapshotRepository : releaseRepository
configurations {
mps
mbeddrPlatformArtifacts
ant_lib
}
dependencies {
mps "com.jetbrains:mps:$mpsVersion"
mbeddrPlatformArtifacts "com.mbeddr:allScripts:$mbeddrVersion"
mbeddrPlatformArtifacts "com.mbeddr:platform:$mbeddrVersion"
ant_lib "org.apache.ant:ant-junit:1.10.1"
}
repositories {
mavenLocal()
for (repoUrl in project.dependencyRepositories) {
maven {
url repoUrl
}
}
}
ext.buildScriptClasspath = project.configurations.ant_lib.fileCollection({
true
})
ext["itemis.mps.gradle.ant.defaultScriptClasspath"] = buildScriptClasspath
ext["itemis.mps.gradle.ant.defaultJavaExecutable"] = new File(jdk_home, 'bin/java')
task resolveMps(type: Copy) {
dependsOn configurations.mps
from {
configurations.mps.resolve().collect { zipTree(it) }
}
into "$buildDir/mps"
}
def artifactsDir = new File(rootDir, 'artifacts')
def buildDir = new File(rootDir, 'build')
ext.mps_home = '-Dmps_home=' + resolveMps.destinationDir.getAbsolutePath()
ext.mps_home_ext = '-Dmps.home=' + resolveMps.destinationDir.getAbsolutePath()
ext.build_dir = '-Dbuild.dir=' + file(rootProject.projectDir.absolutePath).getAbsolutePath()
ext.artifacts_dir = '-Dartifacts.root=' + artifactsDir
ext.pluginVersion = "-Dversion=" + version
ext.buildDate = "-DbuildDate=" + new Date().toString()
// ___________________ utilities ___________________
File scriptFile(String relativePath) {
new File("$buildDir/$relativePath")
}
def defaultScriptArgs = [mps_home, mps_home_ext, build_dir, artifacts_dir, ext.buildDate, ext.pluginVersion]
task resolveMpsArtifacts(type: Copy) {
dependsOn configurations.mbeddrPlatformArtifacts
from {
configurations.mbeddrPlatformArtifacts.resolve().collect { zipTree(it) }
}
into artifactsDir
doFirst { delete artifactsDir }
}
task build_allScripts(type: BuildLanguages, dependsOn: [resolveMps, resolveMpsArtifacts]){
script scriptFile('allScripts/build.xml')
scriptArgs = defaultScriptArgs
scriptClasspath = buildScriptClasspath
}
task build_languages(type: BuildLanguages, dependsOn: [build_allScripts]){
script scriptFile('code/build.xml')
scriptArgs = defaultScriptArgs
scriptClasspath = buildScriptClasspath
}
task install_modelchecker(type: Copy, dependsOn: build_languages) {
from zipTree(project.file("$artifactsDir/org.inca.build/org.inca.modelchecker.zip"))
into "$buildDir/mps/plugins"
}
task run_tests(type: TestLanguages, dependsOn: install_modelchecker) {
description "Will execute all tests from command line"
script scriptFile('test/build.xml')
scriptArgs = defaultScriptArgs
scriptClasspath = buildScriptClasspath
}
task generateLibrariesXml(type: GenerateLibrariesXml) {
dependsOn resolveMpsArtifacts
defaults rootProject.file('libraries.properties')
overrides rootProject.file('libraries.overrides.properties')
destination file('code/.mps/libraries.xml')
}
defaultTasks 'build_languages', 'generateLibrariesXml'
// Ant <junit> task support
repositories {
mavenCentral()
}
configurations {
junitAnt
}
dependencies {
junitAnt 'junit:junit:4.12'
junitAnt('org.apache.ant:ant-junit:1.9.7') {
transitive = false
}
junitAnt('org.apache.ant:ant-junit4:1.9.7') {
transitive = false
}
}