forked from eclipse/buildship
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
377 lines (347 loc) · 17.5 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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
import eclipsebuild.Config
import eclipsebuild.BuildshipConfig
import org.gradle.internal.os.OperatingSystem
apply plugin: eclipsebuild.BuildDefinitionPlugin
// define version mapping for the 3rd-party dependencies that are not specific to a particular Eclipse version
def eclipseVersionAgnosticDependencies = [
'com.gradleware.tooling.utils' : '0.7.0',
'com.gradleware.tooling.client' : '0.7.0',
'com.gradleware.tooling.model' : '0.7.0',
'org.gradle.toolingapi' : '2.7.0',
'org.slf4j.api' : '1.7.2',
'org.slf4j.simple' : '1.7.2',
'com.google.guava' : '15.0.0',
'com.google.gson' : '2.2.4',
'org.junit' : '4.11.0',
'org.apache.log4j' : '1.2.15',
'org.eclipse.swtbot.eclipse.finder' : '2.2.1',
'org.eclipse.swtbot.junit4_x' : '2.2.1',
]
// target platform definition for all major Eclipse releases between version 3.6 and 4.5
// the default version is 44 which can be overridden through -Peclipse.version=<version>
// also the target platforms contain 1) the Eclipse SDK 2) the latest junit 3) SWTBot 2.2.1
eclipseBuild {
defaultEclipseVersion = '45'
final def swtPluginId = "org.eclipse.swt.${ECLIPSE_WS}.${ECLIPSE_OS}.${ECLIPSE_ARCH}"
targetPlatform {
eclipseVersion = '36'
targetDefinition = file('tooling-e36.target')
versionMapping = [
'org.eclipse.core.runtime' : '3.6.0',
'org.eclipse.core.resources' : '3.6.1',
'org.eclipse.core.variables' : '3.2.400',
'org.eclipse.core.filesystem' : '1.3.1',
'org.eclipse.jdt.core' : '3.6.2',
'org.eclipse.jdt.junit.core' : '3.6.1',
'org.eclipse.jdt.launching' : '3.5.200',
'org.eclipse.debug.core' : '3.6.0',
'org.eclipse.core.databinding' : '1.3.100',
'org.eclipse.core.databinding.beans' : '1.2.100',
'org.eclipse.core.databinding.property' : '1.3.0',
'org.eclipse.help' : '3.5.0',
'org.eclipse.ui' : '3.6.2',
'org.eclipse.ui.ide' : '3.6.2',
'org.eclipse.ui.console' : '3.5.0',
'org.eclipse.ui.editors' : '3.6.1',
'org.eclipse.ui.views' : '3.5.1',
'org.eclipse.debug.ui' : '3.6.3',
'org.eclipse.jdt.ui' : '3.6.2',
'com.ibm.icu' : '4.2.1',
'org.eclipse.jface.databinding' : '1.4.0',
'org.eclipse.jface.text' : '3.6.1',
"$swtPluginId" : '3.6.2'
] + eclipseVersionAgnosticDependencies
}
targetPlatform {
eclipseVersion = '37'
targetDefinition = file('tooling-e37.target')
versionMapping = [
'org.eclipse.core.runtime' : '3.7.0',
'org.eclipse.core.resources' : '3.7.101',
'org.eclipse.core.variables' : '3.2.500',
'org.eclipse.core.filesystem' : '1.3.100',
'org.eclipse.jdt.core' : '3.7.3',
'org.eclipse.jdt.junit.core' : '3.7.0',
'org.eclipse.jdt.launching' : '3.6.1',
'org.eclipse.debug.core' : '3.7.1',
'org.eclipse.core.databinding' : '1.4.0',
'org.eclipse.core.databinding.beans' : '1.2.100',
'org.eclipse.core.databinding.property' : '1.4.0',
'org.eclipse.help' : '3.5.100',
'org.eclipse.ui' : '3.7.0',
'org.eclipse.ui.ide' : '3.7.0',
'org.eclipse.ui.console' : '3.5.100',
'org.eclipse.ui.editors' : '3.7.0',
'org.eclipse.ui.views' : '3.6.0',
'org.eclipse.debug.ui' : '3.7.102',
'org.eclipse.jdt.ui' : '3.7.2',
'com.ibm.icu' : '4.4.2',
'org.eclipse.jface.databinding' : '1.5.0',
'org.eclipse.jface.text' : '3.7.2',
"$swtPluginId" : '3.7.2'
] + eclipseVersionAgnosticDependencies
}
targetPlatform {
eclipseVersion = '42'
targetDefinition = file('tooling-e42.target')
versionMapping = [
'org.eclipse.core.runtime' : '3.8.0',
'org.eclipse.core.resources' : '3.8.1',
'org.eclipse.core.variables' : '3.2.600',
'org.eclipse.core.filesystem' : '1.3.200',
'org.eclipse.jdt.core' : '3.8.3',
'org.eclipse.jdt.junit.core' : '3.7.100',
'org.eclipse.jdt.launching' : '3.6.101',
'org.eclipse.debug.core' : '3.7.100',
'org.eclipse.core.databinding' : '1.4.1',
'org.eclipse.core.databinding.beans' : '1.2.200',
'org.eclipse.core.databinding.property' : '1.4.100',
'org.eclipse.help' : '3.6.0',
'org.eclipse.ui' : '3.104.0',
'org.eclipse.ui.ide' : '3.8.2',
'org.eclipse.ui.console' : '3.5.100',
'org.eclipse.ui.editors' : '3.8.0',
'org.eclipse.ui.views' : '3.6.100',
'org.eclipse.debug.ui' : '3.8.2',
'org.eclipse.jdt.ui' : '3.8.2',
'com.ibm.icu' : '4.4.2',
'org.eclipse.jface.databinding' : '1.6.0',
'org.eclipse.jface.text' : '3.8.2',
"$swtPluginId" : '3.100.1'
] + eclipseVersionAgnosticDependencies
}
targetPlatform {
eclipseVersion = '43'
targetDefinition = file('tooling-e43.target')
versionMapping = [
'org.eclipse.core.runtime' : '3.9.100',
'org.eclipse.core.resources' : '3.8.101',
'org.eclipse.core.variables' : '3.2.700',
'org.eclipse.core.filesystem' : '1.4.0',
'org.eclipse.jdt.core' : '3.9.2',
'org.eclipse.jdt.junit.core' : '3.7.200',
'org.eclipse.jdt.launching' : '3.7.1',
'org.eclipse.debug.core' : '3.8.0',
'org.eclipse.core.databinding' : '1.4.1',
'org.eclipse.core.databinding.beans' : '1.2.200',
'org.eclipse.core.databinding.property' : '1.4.200',
'org.eclipse.help' : '3.6.0',
'org.eclipse.ui' : '3.105.0',
'org.eclipse.ui.ide' : '3.9.2',
'org.eclipse.ui.console' : '3.5.200',
'org.eclipse.ui.editors' : '3.8.100',
'org.eclipse.ui.views' : '3.6.100',
'org.eclipse.debug.ui' : '3.9.0',
'org.eclipse.jdt.ui' : '3.9.2',
'com.ibm.icu' : '50.1.1',
'org.eclipse.jface.databinding' : '1.6.200',
'org.eclipse.jface.text' : '3.8.101',
"$swtPluginId" : '3.102.1'
] + eclipseVersionAgnosticDependencies
}
targetPlatform {
eclipseVersion = '44'
targetDefinition = file('tooling-e44.target')
versionMapping = [
'org.eclipse.core.runtime' : '3.10.0',
'org.eclipse.core.resources' : '3.9.1',
'org.eclipse.core.variables' : '3.2.800',
'org.eclipse.core.filesystem' : '1.4.100',
'org.eclipse.jdt.core' : '3.10.2',
'org.eclipse.jdt.junit.core' : '3.7.300',
'org.eclipse.jdt.launching' : '3.7.102',
'org.eclipse.debug.core' : '3.9.1',
'org.eclipse.core.databinding' : '1.4.2',
'org.eclipse.core.databinding.beans' : '1.2.200',
'org.eclipse.core.databinding.property' : '1.4.200',
'org.eclipse.help' : '3.6.0',
'org.eclipse.ui' : '3.106.1',
'org.eclipse.ui.ide' : '3.10.2',
'org.eclipse.ui.console' : '3.5.300',
'org.eclipse.ui.editors' : '3.8.200',
'org.eclipse.ui.views' : '3.7.0',
'org.eclipse.debug.ui' : '3.10.2',
'org.eclipse.jdt.ui' : '3.10.2',
'com.ibm.icu' : '52.1.1',
'org.eclipse.jface.databinding' : '1.6.200',
'org.eclipse.jface.text' : '3.9.2',
"$swtPluginId" : '3.103.2'
] + eclipseVersionAgnosticDependencies
}
targetPlatform {
eclipseVersion = '45'
targetDefinition = file('tooling-e45.target')
versionMapping = [
'org.eclipse.core.runtime' : '3.11.0',
'org.eclipse.core.resources' : '3.10.0',
'org.eclipse.core.variables' : '3.2.800',
'org.eclipse.core.filesystem' : '1.5.0',
'org.eclipse.jdt.core' : '3.11.0',
'org.eclipse.jdt.junit.core' : '3.7.400',
'org.eclipse.jdt.launching' : '3.8.0',
'org.eclipse.debug.core' : '3.10.0',
'org.eclipse.core.databinding' : '1.5.0',
'org.eclipse.core.databinding.beans' : '1.3.0',
'org.eclipse.core.databinding.property' : '1.5.0',
'org.eclipse.help' : '3.6.0',
'org.eclipse.ui' : '3.107.0',
'org.eclipse.ui.ide' : '3.11.0',
'org.eclipse.ui.console' : '3.6.0',
'org.eclipse.ui.editors' : '3.9.0',
'org.eclipse.ui.views' : '3.8.0',
'org.eclipse.debug.ui' : '3.11.0',
'org.eclipse.jdt.ui' : '3.11.0',
'org.eclipse.jface.databinding' : '1.7.0',
'org.eclipse.jface.text' : '3.10.0',
'com.ibm.icu' : '54.1.1',
"$swtPluginId" : "3.104.0"
] + eclipseVersionAgnosticDependencies
}
}
// read the current version from an external file and add a timestamp suffix if requested by the caller
version = getVersion(file('version.txt').text.trim())
subprojects {
// set the calculated version on all projects in the hierarchy
version = rootProject.version
// for all Eclipse versions before Mars, the built plugins must be Java 6 compatible
// for Mars and later Eclipse versions, the minimum execution environment is Java 7 (https://www.eclipse.org/projects/project-plan.php?planurl=/eclipse/development/plans/eclipse_project_plan_4_5.xml)
// try to compile with the minimum required JDK if the location is specified by the caller or if it can be derived
plugins.withType(eclipsebuild.BundlePlugin) {
sourceCompatibility = 1.6
targetCompatibility = Config.on(project).targetPlatform.eclipseVersion >= "45" ? 1.7 : 1.6
tasks.withType(AbstractCompile).all {
// enable all warnings except for different sourceCompatibility and targetCompatibility value
options.compilerArgs << '-Xlint:all'
options.compilerArgs << '-Xlint:-options'
options.fork = true
if (OperatingSystem.current().isMacOsX()) {
options.compilerArgs << '-Werror'
options.forkOptions.executable = "/usr/libexec/java_home -v $targetCompatibility".execute().text.trim() + "/bin/javac"
} else if (project.hasProperty('compiler.location')) {
// quotes required on TeamCity to pass property with spaces, e.g. a Windows file path
options.compilerArgs << '-Werror'
options.forkOptions.executable = project.property('compiler.location').replace('\"', '').replace('\'', '')
}
}
}
// apply Checkstyle plugin, mainly to ensure license/copyright and javadoc is present
apply plugin: 'checkstyle'
// share checkstyle config across all sub-projects
def checkstyleConfigDir = "$rootDir/gradle/config/checkstyle"
tasks.withType(Checkstyle).all {
configFile = "$checkstyleConfigDir/checkstyle.xml" as File
configProperties = ['checkstyleConfigDir': checkstyleConfigDir]
inputs.file "$checkstyleConfigDir/suppressions.xml" as File
}
// configure the repositories where the external dependencies can be found
repositories {
maven {
name = 'mavenized-target-platform'
url "${eclipsebuild.Config.on(project).mavenizedTargetPlatformDir}"
}
maven {
name = 'gradle-snapshots'
url gradleSnapshotsRepositoryUrl
}
maven {
name = 'gradle-releases'
url gradleReleasesRepositoryUrl
}
maven {
name = 'gradle-remote'
url gradleRemoteRepositoryUrl
}
}
}
gradle.buildFinished {
if (project.hasProperty('build.invoker') && project.property('build.invoker') == 'ci') {
killAllGradleDaemons()
}
}
// tag the HEAD of the current branch and push the new tag
task tag << {
def tagVersion = file('version.txt').text.trim()
// create and push tag
exec { commandLine("git", "tag", "-a", "REL_$tagVersion", "-m", "Create tag REL_$tagVersion") }
exec { commandLine("git", "push", "origin", "REL_$tagVersion") }
}
task incrementVersion << {
def oldVersion = file('version.txt').text.trim()
def newVersion = ""
def matcher = version =~ "^(\\d+)\\.(\\d+).(\\d+)"
if (matcher.find()) {
def serviceSegment = Integer.parseInt(matcher.group(3)) + 1
newVersion = matcher.group(1) + "." + matcher.group(2) + "." + serviceSegment
file('version.txt').text = newVersion
} else {
throw new IllegalStateException("Unparseable version: $oldVersion.")
}
exec { commandLine("git", "commit", "-a", "-m", "Increment version from $oldVersion to $newVersion") }
exec { commandLine("git", "push", "origin", "master") }
}
void killAllGradleDaemons() {
def output = new ByteArrayOutputStream()
def queryString
if (org.gradle.internal.os.OperatingSystem.current().windows) {
queryString = ".*(?:-cp|-classpath).*gradle-launcher.*.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon.* ([0-9]+) +\$"
exec {
commandLine('wmic', 'process', 'get', 'processid,commandline')
standardOutput = output
}
} else {
queryString = "([0-9]+).*(?:-cp|-classpath).*gradle-launcher.*.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon.* "
exec {
commandLine('ps', 'x')
standardOutput = output
}
}
output.toString().readLines().each { String process ->
logger.debug("[PSTABLE]$process")
def processMatcher = process =~ queryString
if (processMatcher.find()) {
def pid = processMatcher.group(1)
logger.warn("Killing Gradle daemon process: pid=$pid, cmd=$process")
killProcess(pid)
}
}
}
void killProcess(String pid) {
def killOutput = new ByteArrayOutputStream()
def result = exec {
if (org.gradle.internal.os.OperatingSystem.current().windows) {
commandLine = ["taskkill.exe", "/F", "/T", "/PID", pid]
} else {
commandLine = ["kill", pid]
}
standardOutput = killOutput
errorOutput = killOutput
ignoreExitValue = true
}
if (result.exitValue != 0) {
String out = killOutput.toString()
if (!out.contains('No such process')) {
logger.warn("""Failed to kill daemon process $pid. Maybe already killed? Output: ${killOutput}""")
}
}
}
String getVersion(def baseVersion) {
def config = BuildshipConfig.on(project)
// determine suffix for snapshot and milestone builds
def suffix
if (config.isRelease()) {
suffix = ''
} else if (config.isMilestone()) {
suffix = '-m'
} else if (config.isSnapshot()) {
suffix = '-s'
} else {
throw new IllegalStateException("BuildshipConfig must either be a release, milestone, or snapshot.")
}
// use full timestamp on CI vs. date-only for local builds
if (project.hasProperty('build.invoker') && project.property('build.invoker') == 'ci') {
// note that for Eclipse plugin versions, the '-' and '.' character are invalid in front of the build id
baseVersion + '.v' + new Date().format('yyyyMMdd-kkmm', TimeZone.getTimeZone('GMT')) + suffix
} else {
baseVersion + '.v' + new Date().format('yyyyMMdd', TimeZone.getTimeZone('GMT')) + suffix
}
}