forked from IETS3/iets3.opensource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
executable file
·225 lines (195 loc) · 7.06 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
// 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 forceLocal = project.hasProperty("forceLocalDependencies")
//ext.mpsVersion = '2017.2.2'
// Dependency versions
def mpsSnapshotVersion=System.getenv('mpsVersion')
if (mpsSnapshotVersion != null && !mpsSnapshotVersion.empty) {
ext.mpsVersion = mpsSnapshotVersion
} else {
ext.mpsVersion = '2017.2.2'
}
println "MPS Version--->>> " + ext.mpsVersion
// Project version
if (project.hasProperty('iets3OpenSourceVersion')) {
version = project.iets3OpenSourceVersion
} else {
if (ciBuild) {
version = GitBasedVersioning.getVersion('0', '1')
println "##teamcity[buildNumber '${version}']"
} else {
println "Local build detected, version will be SNAPSHOT"
version = "1.0-SNAPSHOT"
}
}
if (!project.hasProperty("mbeddrVersion")) {
if (forceLocal) {
println "Local SNAPSHOT version forced"
ext.mbeddrVersion = '1.0-SNAPSHOT'
}
else {
ext.mbeddrVersion = '1.0.+'
}
}
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
ext.dependencyRepositories = [
'https://projects.itemis.de/nexus/content/repositories/mbeddr',
'https://projects.itemis.de/nexus/content/repositories/mbeddr_snapshots',
]
ext.artifactsDir = new File(rootDir, 'artifacts')
apply plugin: 'maven-publish'
apply plugin: 'base'
task wrapper(type: Wrapper) {
gradleVersion '3.1'
distributionType 'all'
}
configurations {
mps
mpsArtifacts
}
dependencies {
mps "com.jetbrains:mps:$mpsVersion"
mpsArtifacts "com.mbeddr:allScripts:$mbeddrVersion"
mpsArtifacts "com.mbeddr:platform:$mbeddrVersion"
}
repositories {
mavenLocal()
for (repoUrl in project.dependencyRepositories) {
maven {
url repoUrl
if (project.hasProperty('nexusUsername')) {
credentials {
username project.nexusUsername
password project.nexusPassword
}
}
}
}
}
task resolveMps(type: Copy) {
dependsOn configurations.mps
from {
configurations.mps.resolve().collect { zipTree(it) }
}
into "$buildDir/mps"
}
task resolveMpsArtifacts(type: Copy) {
from {
configurations.mpsArtifacts.resolve().collect { zipTree(it) }
}
into artifactsDir
}
ant.properties['mps.home'] = resolveMps.destinationDir
ant.properties['iets3.github.opensource.home'] = rootDir
ant.properties['build.dir'] = rootDir
ant.properties['artifacts.root'] = resolveMpsArtifacts.destinationDir
ant.properties['version'] = version
ant.importBuild('code/languages/build.xml') { target -> 'ant-' + target }
tasks['ant-check-mps-home'].dependsOn resolveMps
tasks['ant-clean-and-build'].dependsOn resolveMps, resolveMpsArtifacts
task packageAllScripts(type: Zip, dependsOn: 'ant-clean-and-build') {
baseName 'org.iets3.opensource.allScripts'
from artifactsDir
include 'org.iets3.opensource.allScripts.build/**'
}
task packageOpenSource(type: Zip, dependsOn: 'ant-clean-and-build') {
baseName 'org.iets3.opensource'
from artifactsDir
include 'org.iets3.opensource/**'
}
task packageTests(type: Zip, dependsOn: 'ant-clean-and-build') {
baseName 'org.iets3.opensource.tests'
from new File(artifactsDir, 'org.iets3.opensource.tests')
}
assemble.dependsOn packageAllScripts, packageOpenSource, packageTests
publishing {
repositories {
maven {
url project.publishingRepository
if (project.hasProperty('nexusUsername')) {
credentials {
username project.nexusUsername
password project.nexusPassword
}
}
}
}
publications {
allScripts(MavenPublication) {
groupId 'org.iets3.opensource'
artifactId 'allScripts'
artifact packageAllScripts
}
openSource(MavenPublication) {
groupId 'org.iets3'
artifactId 'opensource'
artifact packageOpenSource
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.mpsArtifacts.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')
}
}
}
tests(MavenPublication) {
groupId 'org.iets3.opensource'
artifactId 'tests'
artifact packageTests
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
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)
}
}
}
}
}
// 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
}
}
ant.taskdef(name: 'junit', classname: 'org.apache.tools.ant.taskdefs.optional.junit.JUnitTask',
classpath: configurations.junitAnt.asPath)
ant.taskdef(name: 'junitreport', classname: 'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
classpath: configurations.junitAnt.asPath)
check.dependsOn 'ant-build-and-run-tests'
defaultTasks 'ant-clean-and-build'