forked from inspectIT/inspectIT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inspectit.root.gradle
402 lines (352 loc) · 12.1 KB
/
inspectit.root.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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
/**
* Gradle build file for the inspectit.root project. Contains shared tasks.
*
* @author Rene Kugel
* @author Ivan Senic
*/
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
jcenter()
}
dependencies {
classpath "me.champeau.gradle:jmh-gradle-plugin:0.3.1"
classpath "org.standardout:bnd-platform:1.4.0"
}
}
/** apply cpd to the root project, as this was how the plugin is intended to be used **/
plugins {
id "de.aaschmid.cpd" version "1.0"
}
File propertiesFile = file("properties.gradle")
File dependenciesFile = file("dependencies.gradle")
File platformFile = file("platform.gradle")
/** Apply base plug-in to the root project so that we enable tasks like clean */
apply plugin: 'base'
allprojects {
apply from: file(propertiesFile.absolutePath)
apply from: file(dependenciesFile.absolutePath)
/**
* It is required to set the encoding for all projects to UTF-8, otherwise the build may fail on windows.
*/
System.setProperty("file.encoding", "utf-8")
/**
* If -PintegrateVersionInfo=true is passed with the build, then we will create versionInfo property for the project.
* The build must be started then with -DRELEASE_VERSION and -DBUILD_NUMBER properties set.
*/
if (project.hasProperty('integrateVersionInfo')) {
ext.versionInfo = System.getProperty('RELEASE_VERSION') + "." + System.getProperty('BUILD_NUMBER')
}
}
/**
* Unzips the Eclipse base from the configurations.eclipseBase. Only does it if the eclipse directory is not yet created.
*/
task unzipEclipse (type: Copy){
description = 'Unpacks the eclipse base needed for the PDE build.'
group = 'Build Setup'
def outputDir = file(eclipseDir)
outputs.dir outputDir
into ('') {
from zipTree(configurations.eclipseBase.asPath)
}
destinationDir = outputDir
}
unzipEclipse.onlyIf { !file(eclipseDir).exists() }
gradle.projectsEvaluated {
/**
* Release all installers. Must be in the projectsEvaluated closure as depending projects and tasks must be evaluated first.
*/
task releaseInstallers {
description = 'Releases inspectIT installers.'
group = 'Release'
dependsOn(izpack('inspectit.installer-all.windows.x64', 'Windows', '64', 'release-windows-x64', 'release-inspectit-win32.win32.x86_64'))
dependsOn(izpack('inspectit.installer-all.linux.x64', 'Linux', '64', 'release-linux-x64', 'release-inspectit-linux.gtk.x86_64'))
dependsOn(izpack('inspectit.installer-all.macosx.x64', 'MacOSX', '64', 'release-macosx-x64', 'release-inspectit-macosx.cocoa.x86_64'))
}
}
/** Specify description and group for all main targets */
task release {
description = 'Releases all artifacts in the sub-projects.'
group = 'Release'
}
task analyze {
description = 'Runs all unit tests and all checks in the sub-projects.'
group = 'Verification'
}
task releaseAndAnalyze {
description = "Runs all unit tests, all checks and releases all artifacts in the sub-projects."
group = 'Release'
}
/**
* Method to create task that produces one izpack installer artifacts.
*
* @param installerName Name of the installer file (without extension). Name of created tasks will include this as well.
* @param os Operating system to target ('Windows' or 'Linux').
* @param arch Achitecture ('32' or '64').
* @param cmrReleaseTask Task from the inspectit.server project that outputs the correct CMR package.
* @param uiReleaseTask Task from the inspectit.ui.rcp project that outputs the correct UI package.
*/
def izpack(installerName, os, arch, cmrReleaseTask, uiReleaseTask) {
return tasks.create(name: "release-${installerName}", dependsOn: [":inspectit.agent.java:release", ":inspectit.server:${cmrReleaseTask}", ":inspectit.ui.rcp:${uiReleaseTask}"]) {
// definition of all files needed, plus the output file
def agentPointer = project(':inspectit.agent.java').tasks.getByName('release').outputs.files.getSingleFile()
def cmrPointer = project(':inspectit.server').tasks.getByName(cmrReleaseTask).outputs.files.getSingleFile()
def uiPointer = project(':inspectit.ui.rcp').tasks.getByName(uiReleaseTask).outputs.files.getSingleFile()
def serviceInstallTemplate = file(installerWindowsServiceInstallTemplate)
def serviceUninstallTemplate = file(installerWindowsServiceUninstallTemplate)
def outputFile = file("${buildReleaseRoot}/${installerName}-${versionInfo}.jar")
inputs.file agentPointer
inputs.file cmrPointer
inputs.file uiPointer
inputs.file serviceInstallTemplate
inputs.file serviceUninstallTemplate
outputs.file outputFile
doLast {
// make a directory for output (otherwise we will fail with izpack)
file(buildReleaseRoot).mkdirs()
// copy service bat files if it's windows
if (os == 'Windows') {
// create command for the install service template
def commandOpts = project(':inspectit.server').serverJavaMemory64bit + ' ' + project(':inspectit.server').serverJavaOpts64bit +
' ' + project(':inspectit.server').serverJavaOptsWin + ' ' + project(':inspectit.server').serverJavaLocgcWin
// adapt for the procrun
def procrunCommandOpts = ''
commandOpts.split(" ").each {
procrunCommandOpts += procrunJvmoptsPrefix + it + " "
}
procrunCommandOpts = procrunCommandOpts.substring(0, procrunCommandOpts.length() - 1)
// copy the bat files and filter on the fly
copy {
from serviceInstallTemplate
into file(buildInstallerRoot)
filter {
line -> line.replaceAll('#COMMAND_OPTS#', procrunCommandOpts)
}
rename('template_installService.bat', 'installService.bat')
}
copy {
from serviceUninstallTemplate
into file(buildInstallerRoot)
rename('template_uninstallService.bat', 'uninstallService.bat')
}
}
// configure task, installer resources must be on classpath
ant.taskdef(name: 'izpack', classname: 'com.izforge.izpack.ant.IzPackTask', classpath: configurations.izpack.asPath) {
classpath {
pathelement(location: installerResources)
}
}
ant.taskdef(name: 'var', classname: 'net.sf.antcontrib.property.Variable', classpath: configurations.antContrib.asPath) {
classpath {
pathelement(location: installerResources)
}
}
// copy all existing properties to the ant
project.properties.entrySet().each {
ant.var(name: it.key, value: it.value)
}
// set specific properties
ant.var(name: 'targetOs', value: os)
ant.var(name: 'targetOsArch', value: arch)
ant.var(name: 'installerAgentPointer', value: agentPointer.absolutePath)
ant.var(name: 'installerCmrPointer', value: cmrPointer.absolutePath)
ant.var(name: 'installerUiPointer', value: uiPointer.absolutePath)
ant.var(name: 'installerApplicationVersion', value: versionInfo)
if (os == 'Windows') {
ant.var(name: 'installerInstallServiceBat', value: file("${buildInstallerRoot}/installService.bat").absolutePath)
ant.var(name: 'installerUninstallServiceBat', value: file("${buildInstallerRoot}/uninstallService.bat").absolutePath)
ant.var(name: 'installerWindowsServiceDisplayNamePointer', value: installerWindowsService64DisplayName)
} else {
// reset in case of other OS types
ant.var(name: 'installerInstallServiceBat', value: "")
ant.var(name: 'installerUninstallServiceBat', value: "")
}
// fire the task
ant.izpack(
input: "${installerResources}/install.xml",
output: outputFile.absolutePath,
basedir: installerBase,
inheritAll: 'true'
)
}
}
}
/**
* Task for the CPD.
*/
cpd {
skipLexicalErrors = true
minimumTokenCount = 100
}
cpdCheck {
// ignoring CPD failures on purpose
ignoreFailures = true
reports {
xml {
enabled = true
destination = file("${buildQAAnalysisCPD}/main.xml")
}
}
}
task cpdHtmlReport {
doLast {
ant.xslt(in: "${buildQAAnalysisCPD}/main.xml", style: cpdReportFile, out: "${buildQAAnalysisCPD}/../cpd.html")
}
}
cpdCheck.finalizedBy cpdHtmlReport
/** Platform settings defined in separate file */
apply from: file(platformFile.absolutePath)
/**
* All tasks that sub-projects can use.
*/
subprojects {
/** All plugins */
// plugins {} block can not be used in subprojects
apply plugin: 'java'
apply plugin: 'pmd'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'jacoco'
/** all compile, test and runtime configurations to transitive = false */
configurations.compile.transitive = false
configurations.compileOnly.transitive = false
configurations.compileClasspath.transitive = false
configurations.testCompile.transitive = false
configurations.testCompileOnly.transitive = false
configurations.testCompileClasspath.transitive = false
configurations.runtime.transitive = false
configurations.testRuntime.transitive = false
/**
* Defaults of the compile tasks.
*/
compileJava {
options.compilerArgs << '-Xlint:unchecked'
options.debug = 'true'
options.fork = 'true'
options.encoding = 'UTF-8'
}
compileTestJava {
options.compilerArgs << '-Xlint:unchecked'
options.debug = 'true'
options.fork = 'true'
options.encoding = 'UTF-8'
}
/**
* Defaults of the jar task and integrate version tasks.
*/
jar {
libsDirName = 'release'
}
/**
* All projects have same analyze task.
*/
task analyze {
description = 'Runs all unit tests and all checks.'
group = 'Verification'
dependsOn(check)
}
/**
* Tasks for the TestNG and Cobertura.
*/
/**
* Definition of the test properties.
*/
test {
useTestNG() {
outputDirectory = file(buildQATestTestdata)
useDefaultListeners = true
}
reports.html.destination = file(buildQATestTestdata)
//create html pages that link to the interesting parts
doLast {
new File(buildQATest, "coverage.html").text = "<meta http-equiv=\"refresh\" content=\"0; url=coveragedata/index.html\" >"
new File(buildQATest, "testresult.html").text = "<meta http-equiv=\"refresh\" content=\"0; url=testdata/index.html\" >"
new File(buildQATest, "testreport.html").text = "<meta http-equiv=\"refresh\" content=\"0; url=testdata/emailable-report.html\" >"
}
}
/**
* Task for the PMD.
*/
pmd {
sourceSets = [sourceSets.main]
ruleSetFiles = files(pmdRulesFile)
ruleSets = []
reportsDir = file(buildQAAnalysisPMD)
toolVersion = '5.4.1'
}
task pmdHtmlReport {
doLast {
ant.xslt(in: "${buildQAAnalysisPMD}/main.xml", style: pmdReportFile, out: "${buildQAAnalysisPMD}/sortable_report.html")
ant.copy(todir: buildQAAnalysisPMD, file: pmdSortableFile)
new File(buildQAAnalysis, "pmd.html").text = "<meta http-equiv=\"refresh\" content=\"0; url=pmd/sortable_report.html\" >"
}
}
pmdMain.finalizedBy pmdHtmlReport
/**
* Task for the Checkstyle.
*/
checkstyle {
sourceSets = [sourceSets.main]
configFile = file(checkstyleConfigFile)
reportsDir = file(buildQAAnalysisCheckstyle)
toolVersion = '5.6'
}
task checkstyleHtmlReport {
doLast {
ant.xslt(in: "${buildQAAnalysisCheckstyle}/main.xml", style: "${checkstyleReportFile}", out: "${buildQAAnalysisCheckstyle}/../checkstyle.html")
}
}
checkstyleMain.finalizedBy checkstyleHtmlReport
/**
* Task for the Findbugs.
*/
findbugs {
sourceSets = [sourceSets.main]
includeFilter = file(findbugsConfigInclude)
excludeFilter = file(findbugsConfigExclude)
reportsDir = file(buildQAAnalysisFindbugs)
toolVersion = '3.0.1'
}
task findbugsHtmlReport {
doLast {
ant.xslt(in: "${buildQAAnalysisFindbugs}/main.xml", style: findbugsConfigFancyHist, out: "${buildQAAnalysisFindbugs}/../findbugs.html")
}
}
findbugsMain.finalizedBy findbugsHtmlReport
/** Ensure that check task depends on the */
check.dependsOn(':cpdCheck')
/**
* Configures the jacoco plugin.
*/
jacoco {
reportsDir = file(buildQATestCoveragedata)
}
}
// JMH tests only to projects that do have them
["inspectit.agent.java","inspectit.server"].each { n ->
project(":$n") {
apply plugin: 'me.champeau.gradle.jmh'
/**
* JMH-Perf tests.
*/
jmhJar {
doFirst {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}
}
jmh {
/**
* Use -PjmhInclude='regular expression' to specify what tests to run with JMH.
*/
if (project.hasProperty('jmhInclude')) {
include = project.getProperty('jmhInclude')
}
humanOutputFile = file("${buildQAPerfTest}/jmh/human.txt")
resultsFile = file("${buildQAPerfTest}/jmh/results.txt")
duplicateClassesStrategy = 'exclude'
jmhVersion = jmhversion
}
}
}