-
Notifications
You must be signed in to change notification settings - Fork 41
/
build.gradle
1295 lines (1114 loc) · 39.7 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
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
buildscript {
repositories {
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath 'gradle.plugin.gradle-plugins:jartest:1.0.1' // necessary to depend tests on tests
//classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.5.0"
}
}
plugins {
id 'java' // required for compileJava.dependsOn, manifest etc.
id 'java-library'
id 'maven-publish'
id 'signing'
id 'jacoco'
id "com.diffplug.spotless" version "6.25.0"
}
configurations {
resultJar
emfJarConfig
aspectJarConfig
bytebuddyJarConfig
javassistJarConfig
}
spotless {
format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '*.md', '.gitignore'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces(2) // or tabs. Just in case.
endWithNewline()
}
}
dependencies {
resultJar "org.slf4j:slf4j-api:${libSlf4jApiVersion}"
resultJar "org.jctools:jctools-core:${libJctoolsVersion}"
emfJarConfig 'org.eclipse.emf:org.eclipse.emf.common:2.31.0'
emfJarConfig 'org.eclipse.emf:org.eclipse.emf.ecore.xmi:2.38.0'
emfJarConfig 'org.eclipse.emf:org.eclipse.emf.ecore:2.37.0'
aspectJarConfig "org.aspectj:aspectjweaver:${aspectjVersion}"
aspectJarConfig "com.rabbitmq:amqp-client:5.22.0"
bytebuddyJarConfig "net.bytebuddy:byte-buddy:$libBytebuddyVersion"
bytebuddyJarConfig "commons-io:commons-io:2.17.0"
javassistJarConfig "org.javassist:javassist:3.30.2-GA"
}
// We have multiple subprojects - but we do not want all of them in our JAR files.
// FIXME the jar tasks should handle this requirement instead.
// Otherwise, we need to add a new project twice: once in the settings.gradle and once in this file.
def mainSubprojects = [
project(':common'),
project(':monitoring:core'),
project(':model'),
project(':analysis'),
project(':tools'),
project(':extension-kafka'),
project(':extension-cassandra')
]
def aspectJSubprojects = [
project(':common'),
project(':monitoring:core'),
project(':monitoring:aspectj')
]
def bytebuddySubprojects = [
project(':common'),
project(':monitoring:core'),
project(':monitoring:bytebuddy')
]
def javassistSubprojects = [
project(':common'),
project(':monitoring:core'),
project(':monitoring:javassist')
]
def springSubprojects = [
project(':common'),
project(':monitoring:core'),
project(':monitoring:spring')
]
allprojects {
version = kiekerVersion
repositories { // must be above subprojects {}
mavenLocal()
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'signing'
apply plugin: 'jacoco'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'maven-publish'
sourceCompatibility = sourceVersion
targetCompatibility = targetVersion
// Encoding should be UTF-8
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
sourceSets {
main {
java {
srcDir 'src'
srcDir 'src-gen'
}
resources {
srcDirs = ['src-resources']
}
}
test {
java {
srcDir 'test'
srcDir 'test-gen'
}
resources {
srcDirs = ['test-resources']
}
}
integrationTest {
java {
srcDirs = ['test-integration']
compileClasspath += main.compileClasspath + test.compileClasspath
runtimeClasspath += main.runtimeClasspath + test.runtimeClasspath
}
}
}
test {
finalizedBy jacocoTestReport // report is always generated after tests run
systemProperty "java.io.tmpdir", "${buildDir}"
ignoreFailures = true
maxHeapSize = "2g" // Set limit to prevent Travis-CI build to crash
testLogging {
showCauses = 'true'
exceptionFormat = 'full'
showExceptions = 'true'
showStandardStreams = 'true'
}
jacoco {
enabled = true
}
afterTest { desc, result ->
println "Executed test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
}
java {
withSourcesJar()
withJavadocJar()
}
javadoc {
failOnError=false
}
artifacts {
archives javadocJar
}
publishing {
publications {
maven(MavenPublication) {
pom {
groupId = 'net.kieker-monitoring'
artifactId = project.name // Use the subproject's name
version = project.version
name = "${project.name} - Kieker Observability Framework"
description = 'Kieker: Application Performance Observability and Software Analysis'
url = 'http://kieker-monitoring.net'
licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'thomas.duellmann'
name = 'Thomas F. Duellmann'
email = 'duellmann@hitec-hamburg.de'
}
developer {
id = 'andre.van.hoorn'
name = 'Andre van Hoorn'
email = 'andre.van.hoorn@uni-hamburg.de'
}
developer {
id = 'reiner.jung'
name = 'Reiner Jung'
email = 'reiner.jung@email.uni-kiel.de'
}
developer {
id = 'david.georg.reichelt'
name = 'David Georg Reichelt'
email = 'd.g.reichelt@lancaster.ac.uk'
}
}
scm {
connection = 'scm:git:https://github.com/kieker-monitoring/kieker.git'
developerConnection = 'scm:git:git@github.com:kieker-monitoring/kieker.git'
url = 'https://github.com/kieker-monitoring/kieker'
}
}
}
}
}
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
signing {
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
sign publishing.publications.maven
println 'Going to sign subproject ' + project.name + ' for releasing: ' + isReleaseVersion
}
jacoco {
toolVersion = '0.8.6'
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.required = false
csv.required = false
html.required = true
}
}
spotless {
format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '*.md', '.gitignore'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
}
task integrationTest(type: Test) {
testClassesDirs = project.sourceSets.integrationTest.output.classesDirs
classpath = project.sourceSets.integrationTest.runtimeClasspath
}
check.dependsOn integrationTest
tasks.withType(Zip) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType(Distribution) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
// --- quality assurance plugins ---
apply plugin: 'pmd'
pmd { // is represented by the groovy class "PmdExtension"
// the used PMD version should be the same version as the PMD Eclipse plugin (https://marketplace.eclipse.org/content/eclipse-pmd) uses
toolVersion = pmdVersion
ignoreFailures = true
consoleOutput = true
threads = 4
incrementalAnalysis = false
// Clear the rule set first. Otherwise we would have a lot of additional rules in our rule set.
ruleSets = []
ruleSetFiles = files(resolveRelativeToParent(dirConfig, 'pmdrules.xml'))
}
apply plugin: 'checkstyle'
checkstyle {
toolVersion = checkstyleVersion
ignoreFailures = true
showViolations = false
configFile = resolveRelativeToParent(dirConfig, 'cs-conf.xml')
configDirectory = rootProject.file(dirConfig)
}
//apply plugin: "com.github.spotbugs"
//spotbugs {
// toolVersion = spotbugsVersion
// ignoreFailures = false
// showStackTraces = true
// showProgress = false
// effort = 'max'
// reportLevel = 'low'
// visitors = [ 'FindSqlInjection', 'SwitchFallthrough' ]
// omitVisitors = [ 'FindNonShortCircuit' ]
// reportsDir = file("$buildDir/spotbugs")
// includeFilter = file("include.xml")
// excludeFilter = resolveRelativeToParent(dirConfig, 'fb-filter.xml')
// onlyAnalyze = [ 'com.foobar.MyClass', 'com.foobar.mypkg.*' ]
// maxHeapSize = '1g'
// extraArgs = [ '-nested:false' ]
// jvmArgs = [ '-Duser.language=ja' ]
//}
tasks.withType(Pmd) {
reports {
xml.required = true
html.required = true
}
}
tasks.withType(Checkstyle) {
reports {
xml.required = true
html.required = true
html.stylesheet resources.text.fromFile(rootProject.projectDir.path + '/config/checkstyle-noframes-severity-sorted.xsl')
}
}
// tasks.withType(Spotbugs) {
// reports {
// xml.enabled = true
// html.enabled = false // Can only enable either xml OR html
// }
// }
// Those are some dependencies which are needed by all subprojects
dependencies {
// compile-time dependency due to the annotation SuppressFBWarnings()
//implementation "com.google.code.findbugs:findbugs:${fbVersion}"
implementation "org.slf4j:slf4j-api:$libSlf4jApiVersion"
// enable logging for test runs
testImplementation "ch.qos.logback:logback-classic:$libLogbackVersion"
testImplementation "org.mockito:mockito-core:$libMockitoVersion"
testImplementation "junit:junit:$libJunitVersion"
testImplementation "org.hamcrest:hamcrest:$libHamcrestVersion"
}
}
def parseCheckstyleReport(File reportFile) {
def errors = 0
def warnings = 0
def infos = 0
if (reportFile.exists()) {
def xmlFile = (new XmlParser()).parse(reportFile)
xmlFile.'file'.'error'.each { issue ->
switch (issue.attribute("severity")) {
case "error":
errors++
break;
case "warning":
warnings++
break;
default:
infos++
break;
}
}
}
return [errors, warnings, infos]
}
def parseFindbugsReport(File reportFile) {
def errors = 0
def warnings = 0
def infos = 0
if (reportFile.exists()) {
def xmlFile = (new XmlParser()).parse(reportFile)
xmlFile.'FindBugsSummary'.each { issue ->
def prio1Bugs = issue.attribute("priority_1")
def prio2Bugs = issue.attribute("priority_2")
def bugsTotal = issue.attribute("total_bugs")
def prio1BugsInt = 0
def prio2BugsInt = 0
def bugsTotalInt = 0
if (prio1Bugs != null) {
prio1BugsInt = Integer.valueOf(prio1Bugs)
}
if (prio2Bugs != null) {
prio2BugsInt = Integer.valueOf(prio2Bugs)
}
if (bugsTotal != null) {
bugsTotalInt = Integer.valueOf(bugsTotal)
}
errors += prio1BugsInt
warnings += prio2BugsInt
infos += bugsTotalInt - (prio1BugsInt + prio2BugsInt)
}
}
return [errors, warnings, infos]
}
def parsePmdReport(File reportFile) {
def errors = 0
def warnings = 0
def infos = 0
if (reportFile.exists()) {
def xmlFile = (new XmlParser()).parse(reportFile)
xmlFile.'file'.'violation'.each { issue ->
// https://github.com/jenkinsci/pmd-plugin/blob/master/src/main/java/hudson/plugins/pmd/parser/PmdParser.java#L26-L29
switch (issue.attribute("priority")) {
case "1":
case "2":
errors++
break;
case "3":
case "4":
warnings++;
break;
case "5":
default:
infos++
break;
}
}
}
return [errors, warnings, infos]
}
def checkSubprojects = [
project(':common'),
project(':monitoring:core'),
project(':monitoring:aspectj'),
project(':monitoring:bytebuddy'),
project(':monitoring:disl'),
project(':monitoring:javassist'),
project(':monitoring:spring'),
project(':model'),
project(':analysis'),
project(':tools'),
project(':tools:restructuring'),
project(':tools:behavior-analysis'),
project(':tools:cmi'),
project(':tools:collector'),
project(':tools:convert-logging-timestamp'),
project(':tools:dar'),
project(':tools:delta'),
project(':tools:fxca'),
project(':tools:log-replayer'),
project(':tools:maa'),
project(':tools:mktable'),
project(':tools:mop'),
project(':tools:mt'),
project(':tools:mvis'),
project(':tools:opad'),
project(':tools:otel-transformer'),
project(':tools:relabel'),
project(':tools:resource-monitor'),
project(':tools:rewrite-log-entries'),
project(':tools:runtime-analysis'),
project(':tools:sar'),
project(':tools:trace-analysis'),
project(':tools:trace-analysis-gui'),
project(':extension-kafka'),
project(':extension-cassandra')
]
checkSubprojects.each { project ->
configure(project) {
task checkThresholds(dependsOn: ["build"]) {
doLast {
def reportTypes = ['main', 'test']
// Begin Checkstyle report parsing
def csErrors = 0
def csWarnings = 0
def csInfos = 0
def p = project
reportTypes.each { String type ->
def reportFile = file(p.projectDir.path + '/build/reports/checkstyle/' + type + '.xml')
def reportResults = parseCheckstyleReport(reportFile)
csErrors += reportResults[0]
csWarnings += reportResults[1]
csInfos += reportResults[2]
}
// End Checkstyle report parsing
// Begin Findbugs report parsing
def fbErrors = 0
def fbWarnings = 0
def fbInfos = 0
reportTypes.each { String type ->
def reportFile = file(p.projectDir.path + '/build/reports/findbugs/' + type + '.xml')
def reportResults = parseFindbugsReport(reportFile)
fbErrors += reportResults[0]
fbWarnings += reportResults[1]
fbInfos += reportResults[2]
}
// End Findbugs report parsing
// Begin PMD report parsing
def pmdErrors = 0
def pmdWarnings = 0
def pmdInfos = 0
reportTypes.each { String type ->
def reportFile = file(p.projectDir.path + '/build/reports/pmd/' + type + '.xml')
def reportResults = parsePmdReport(reportFile)
pmdErrors += reportResults[0]
pmdWarnings += reportResults[1]
pmdInfos += reportResults[2]
}
// End PMD report parsing
// Print results
println("Static analysis results:")
println()
println(" Checkstyle:")
println(" Errors: " + csErrors + " (Threshold: " + checkstyleErrorThreshold + ")")
println(" Warnings: " + csWarnings + " (Threshold: " + checkstyleWarningThreshold + ")")
println(" Info: " + csInfos)
println()
println(" Findbugs:")
println(" Errors: " + fbErrors + " (Threshold: " + findbugsErrorThreshold + ")")
println(" Warnings: " + fbWarnings + " (Threshold: " + findbugsWarningThreshold + ")")
println(" Info: " + fbInfos)
println()
println(" PMD:")
println(" Errors: " + pmdErrors + " (Threshold: " + pmdErrorThreshold + ")")
println(" Warnings: " + pmdWarnings + " (Threshold: " + pmdWarningThreshold + ")")
println(" Info: " + pmdInfos)
println()
def eclipseUserHint = "\nNOTE: If you are using Eclipse, please make sure that you set it up properly as described at: https://github.com/kieker-monitoring/kieker#eclipse-setup-for-contributors"
// Fail build if Checkstyle thresholds are violated
if (csWarnings > Integer.valueOf(checkstyleWarningThreshold)) {
throw new GradleException("There were checkstyle warnings exceeding the warning threshold! Warnings: " + csWarnings + " Threshold: " + checkstyleWarningThreshold + "." + eclipseUserHint)
}
if (csErrors > Integer.valueOf(checkstyleErrorThreshold)) {
throw new GradleException("There were checkstyle errors exceeding the error threshold! Errors: " + csErrors + " Threshold: " + checkstyleErrorThreshold + "." + eclipseUserHint)
}
// Fail build if Findbugs thresholds are violated
if (fbWarnings > Integer.valueOf(findbugsWarningThreshold)) {
throw new GradleException("There were findbugs warnings exceeding the warning threshold! Warnings: " + fbWarnings + " Threshold: " + findbugsWarningThreshold + ".")
}
if (fbErrors > Integer.valueOf(findbugsErrorThreshold)) {
throw new GradleException("There were findbugs errors exceeding the error threshold! Errors: " + fbErrors + " Threshold: " + findbugsErrorThreshold + ".")
}
// Fail build if PMD thresholds are violated
if (pmdWarnings > Integer.valueOf(pmdWarningThreshold)) {
throw new GradleException("There were pmd warnings exceeding the warning threshold! Warnings: " + pmdWarnings + " Threshold: " + pmdWarningThreshold + "." + eclipseUserHint)
}
if (pmdErrors > Integer.valueOf(pmdErrorThreshold)) {
throw new GradleException("There were pmd errors exceeding the error threshold! Errors: " + pmdErrors + " Threshold: " + pmdErrorThreshold + "." + eclipseUserHint)
}
}
}
tasks.check.finalizedBy(checkThresholds)
}
}
// Execute 'checkThresholds' after all check tasks in the subprojects have been executed
//mainSubprojects.tasks.check*.finalizedBy(checkThresholds)
task checkThresholds(dependsOn: mainSubprojects.tasks["checkThresholds"])
def regexpReplaceInFiles(File file, String searchExp, String replaceExp) {
//println "Replacing $searchExp by $replaceExp in $file"
String contents = file.getText('UTF-8')
contents = contents.replaceAll(searchExp, replaceExp)
file.write(contents, 'UTF-8')
}
task updateLicenseHeaderYear() {
doLast {
FileTree tree = fileTree(dir: '.', include: '**/*.java')
tree.each { File file ->
regexpReplaceInFiles(file, 'Copyright 20\\d\\d Kieker Project', 'Copyright 2022 Kieker Project')
}
regexpReplaceInFiles(project.file("common/src/kieker/common/util/Version.java"), '20\\d\\d Kieker Project', '2022 Kieker Project')
}
}
task replaceHardCodedVersionNames() {
doLast {
regexpReplaceInFiles(project.file("bin/dev/release-check-short.sh"), "KIEKER_VERSION=\".*?\"", "KIEKER_VERSION=\"${version}\"")
regexpReplaceInFiles(project.file("monitoring/aspectj/integrationTest-resources/example-projects-aspectj/example-beforeafteroperationevent/gradle.properties"), "kiekerVersion=.*", "kiekerVersion=${version}")
regexpReplaceInFiles(project.file("monitoring/aspectj/integrationTest-resources/example-projects-aspectj/example-beforeafterconstructorevent/gradle.properties"), "kiekerVersion=.*", "kiekerVersion=${version}")
regexpReplaceInFiles(project.file("monitoring/aspectj/integrationTest-resources/example-projects-aspectj/example-operationexecutionrecord/gradle.properties"), "kiekerVersion=.*", "kiekerVersion=${version}")
regexpReplaceInFiles(project.file("documentation/getting-started/AspectJ-Instrumentation-Example.rst"), "kieker-.*-SNAPSHOT-aspectj.jar", "${rootProject.aspectJJar.archiveFileName}")
regexpReplaceInFiles(project.file("documentation/tutorials/How-to-apply-Kieker-in-Java-EE-Environments.rst"), "kieker-.*-SNAPSHOT-aspectj.jar", "${rootProject.aspectJJar.archiveFileName}")
regexpReplaceInFiles(project.file("documentation/getting-started/Manual-Monitoring-with-Kieker.rst"), "kieker-.*-SNAPSHOT-emf.jar", "${rootProject.emfJar.archiveFileName}")
regexpReplaceInFiles(project.file("documentation/getting-started/Download-and-Extract-Tutorial.rst"), "kieker-.*-SNAPSHOT.jar", "${rootProject.mainJar.archiveFileName}")
regexpReplaceInFiles(project.file("documentation/getting-started/AspectJ-Instrumentation-Example.rst"), "kieker-.*-SNAPSHOT.jar", "${rootProject.mainJar.archiveFileName}")
regexpReplaceInFiles(project.file("documentation/tutorials/How-to-apply-Kieker-in-Java-EE-Environments.rst"), "kieker-.*-SNAPSHOT.jar", "${rootProject.mainJar.archiveFileName}")
regexpReplaceInFiles(project.file("documentation/getting-started/Manual-Monitoring-with-Kieker.rst"), "kieker-.*/build/libs/", "kieker-${version}/build/libs/")
regexpReplaceInFiles(project.file("documentation/getting-started/Download-and-Extract-Tutorial.rst"), "kieker-.*-binaries", "kieker-${version}-binaries")
regexpReplaceInFiles(project.file("documentation/kieker-tools/Kieker-Tools.rst"), "kieker-.*-binaries", "kieker-${version}-binaries")
regexpReplaceInFiles(project.file("documentation/conf.py"), "release = '.*'", "release = '${version}'")
}
}
compileJava.dependsOn replaceHardCodedVersionNames
def resolveRelativeToParent(String directory, String file) {
return rootProject.file(directory + '/' + file)
}
def today() {
def date = new Date()
def formattedDate = date.format('yyyy-MM-dd')
return formattedDate
}
def year() {
def date = new Date()
def formattedDate = date.format('yyyy')
return formattedDate
}
def monthMMM() {
def date = new Date()
def formattedDate = date.format('MMM')
return formattedDate
}
task apidoc(type: Javadoc) {
description = 'Generate the Javadoc API documentation for the Kieker Framework'
source mainSubprojects.collect { project -> project.sourceSets.main.allJava }
classpath = files(mainSubprojects.collect { project -> project.sourceSets.main.compileClasspath })
destinationDir = new File(projectDir, 'docs')
failOnError = false
title = "Kieker Observability Framework, Vers. $kiekerVersion<br/>API Documentation"
options.header = "Kieker $kiekerVersion"
options.footer = "Kieker $kiekerVersion"
options.bottom = "Copyright " + year() + " $kiekerCopyright, <a href=\"http://monitoring.net\">http://monitoring.net</a>"
options.author = "true"
options.version = "false"
options.use = "true"
options.tags = ["generated", "ordered", "model"]
options.encoding = "UTF-8"
options.charSet = "UTF-8"
options.docEncoding = "UTF-8"
}
ext.sharedManifest = manifest {
attributes(
"Specification-Title": kiekerName,
"Specification-Version": kiekerVersion,
"Specification-Vendor": kiekerCopyright,
"Implementation-Title": kiekerName,
"Implementation-Version": kiekerVersion + " (" + today() + ")",
"Implementation-Vendor": kiekerCopyright,
"kieker" // The section name
)
}
def allArtifacts = {
mainSubprojects.each { subproject ->
from subproject.configurations.archives.allArtifacts.files.collect {
zipTree(it)
}
}
}
def aspectJArtifacts = {
aspectJSubprojects.each { subproject ->
from subproject.configurations.archives.allArtifacts.files.collect {
zipTree(it)
}
}
}
def bytebuddyArtifacts = {
bytebuddySubprojects.each { subproject ->
from subproject.configurations.archives.allArtifacts.files.collect {
zipTree(it)
}
}
}
def javassistArtifacts = {
javassistSubprojects.each { subproject ->
from subproject.configurations.archives.allArtifacts.files.collect {
zipTree(it)
}
}
}
def springArtifacts = {
springSubprojects.each { subproject ->
from subproject.configurations.archives.allArtifacts.files.collect {
zipTree(it)
}
}
}
def licence = {
from file('LICENSE')
}
def aopxml = {
from(file('examples/aop.example.xml')) {
into 'META-INF'
}
}
// Remove the default 'jar' artifact because we have our own artifacts: mainJar, emfJar, aspectJJar
// If you don't do this, we get trouble with the Maven upload task having two Jars (default, mainJar)
// with the same type and classifier.
configurations.archives.artifacts.with { archives ->
def jarArtifact
archives.each {
if (it.file =~ 'jar') {
jarArtifact = it
}
}
println "JAR to delete: ${jarArtifact}"
remove(jarArtifact)
}
/**
* Create bundle jars.
*/
task createArtifacts(dependsOn: [ 'mainJar', 'aspectJJar', 'emfJar', 'sourcesJar', 'javadocJar']) {}
/** Kieker jar without aspectj and emf. */
task mainJar(type: Jar, dependsOn: mainSubprojects.tasks["build"], group: "build",
description: "Assembles a jar archive containing all of Kieker's components, the user guide examples, the documentation etc."
) {
// default archiveName is [baseName]-[appendix]-[version]-[classifier].[extension]
configure allArtifacts
configure licence
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest = project.manifest {
from sharedManifest
}
}
/** Kieker jar with emf libraries. */
task emfJar(type: Jar, dependsOn: mainSubprojects.tasks["build"], group: "build",
description: "Assembles a jar archive containing the contents of the mainJar task and additionally the Eclipse Modeling Framework (EMF). The resulting jar can directly be used for analyzing Kieker logs."
) {
// default archiveFileName is [baseName]-[appendix]-[version]-[classifier].[extension]
archiveClassifier = 'emf'
configure allArtifacts
configure licence
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from configurations.emfJarConfig.asFileTree.files.collect { zipTree(it) }
from configurations.resultJar.allArtifacts.collect { it.isDirectory() ? it : zipTree(it) }
from('lib') {
include "org.eclipse.emf.common_${libEmfVersion}.LICENSE"
include "org.eclipse.emf.ecore_${libEmfVersion}.LICENSE"
include "org.eclipse.emf.ecore.xmi_${libEmfVersion}.LICENSE"
}
manifest = project.manifest {
from sharedManifest
}
}
/** Kieker jar with aspectJ tooling. */
task aspectJJar(type: Jar, dependsOn: aspectJSubprojects.tasks["build"], group: "build",
description: "Assembles a jar archive containing the contents of the mainJar task and additionally the aspect-oriented framework AspectJ. The resulting jar can directly be used for monitoring and tracing as javaagent."
) {
// default archiveFileName is [baseName]-[appendix]-[version]-[classifier].[extension]
archiveClassifier = 'aspectj'
configure aspectJArtifacts
configure licence
configure aopxml
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from file("lib/aspectjweaver-${aspectjVersion}.LICENSE")
from configurations.resultJar.asFileTree.files.collect { zipTree(it) }
from configurations.aspectJarConfig.asFileTree.files.collect { zipTree(it) }
from configurations.resultJar.allArtifacts.collect { it.isDirectory() ? it : zipTree(it) }
manifest = project.manifest {
from sharedManifest
attributes(
"Can-Redefine-Classes": 'true',
"Premain-Class": 'kieker.monitoring.probe.aspectj.AspectJLoader'
)
attributes(
"Specification-Title": "AspectJ Weaver Classes",
"Specification-Version": aspectjVersion,
"Specification-Vendor": "aspectj.org",
"Implementation-Title": "org.aspectj.weaver",
"Implementation-Version": aspectjVersion,
"Implementation-Vendor": "aspectj.org",
"Can-Redefine-Classes": "true",
"Premain-Class": "org.aspectj.weaver.loadtime.Agent",
"org/aspectj/weaver/" // The section name
)
}
}
/** Kieker jar with bytebuddy tooling. */
task bytebuddyJar(type: Jar, dependsOn: bytebuddySubprojects.tasks["build"], group: "build",
description: "Assembles a jar archive containing the contents of the mainJar task and additionally the a bytebuddy agent. The resulting jar can directly be used for monitoring and tracing as javaagent."
) {
archiveClassifier = 'bytebuddy'
configure bytebuddyArtifacts
configure licence
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from configurations.resultJar.asFileTree.files.collect { zipTree(it) }
from configurations.resultJar.allArtifacts.collect { it.isDirectory() ? it : zipTree(it) }
from configurations.bytebuddyJarConfig.asFileTree.files.collect { zipTree(it) }
manifest = project.manifest {
from sharedManifest
attributes(
"Can-Redefine-Classes": "true",
"Can-Retransform-Classes": "true",
"Premain-Class": "kieker.monitoring.probe.bytebuddy.PremainClass"
)
}
}
/** Kieker jar with javassist tooling. */
task javassistJar(type: Jar, dependsOn: javassistSubprojects.tasks["build"], group: "build",
description: "Assembles a jar archive containing the contents of the mainJar task and additionally the a javassist agent. The resulting jar can directly be used for monitoring and tracing as javaagent."
) {
archiveClassifier = 'javassist'
configure javassistArtifacts
configure licence
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from configurations.resultJar.asFileTree.files.collect { zipTree(it) }
from configurations.resultJar.allArtifacts.collect { it.isDirectory() ? it : zipTree(it) }
from configurations.javassistJarConfig.asFileTree.files.collect { zipTree(it) }
manifest = project.manifest {
from sharedManifest
attributes(
"Can-Redefine-Classes": "true",
"Can-Retransform-Classes": "true",
"Premain-Class": "kieker.monitoring.probe.javassist.PremainClass"
)
}
}
/** Kieker jar with spring tooling. */
task springJar(type: Jar, dependsOn: springSubprojects.tasks["build"], group: "build",
description: "Assembles a jar archive containing the contents of the mainJar task and additionally the spring framework. The resulting jar can directly be used for monitoring and tracing a spring application."
) {
archiveClassifier = 'spring'
configure springArtifacts
configure licence
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier = 'sources'
from mainSubprojects.collect { project -> project.sourceSets.main.allJava }
}
task javadocJar(type: Jar, dependsOn: apidoc) {
archiveClassifier = 'javadoc'
from apidoc.destinationDir
}
task distribute(group: 'distribution', description: 'Distributes binary and source archives.',
dependsOn: [':distributeBinaryTar', ':replaceHardCodedVersionNames'])
/**
* Collect binary content.
*/
def binaryContent = project.copySpec {
from(projectDir) {
include 'LICENSE'
include 'HISTORY'
include 'bin/**'
include 'lib/**'
include 'javadoc/**'
include 'build/libs/*'
exclude 'bin/**/*.class'
exclude '**/.gradle/**'
exclude 'lib/static-analysis/'
exclude 'bin/dev/release-check*'
exclude 'caches/**'
}
from('documentation') {
include 'README-bin'
rename 'README-bin', 'README'
}
exclude '**/*.log'
into kiekerPackagenamebase + "-" + kiekerVersion
}
def tools = [
'restructuring',
'behavior-analysis',
'cmi',
'collector',
'convert-logging-timestamp',
'dar',
'delta',
'fxca',
'log-replayer',
'maa',
'mktable',
'mop',
'mt',
'mvis',
'relabel',
'resource-monitor',
'rewrite-log-entries',
'runtime-analysis',
'sar',
'trace-analysis',
'trace-analysis-gui'
]
/** collect tools for binary distribution. */
def toolsContent = project.copySpec {
tools.each {
from("tools/${it}/build/distributions") {
include "**"
}
}
from("tools") {
include "README.md"
}
into kiekerPackagenamebase + "-" + kiekerVersion + "/tools"
}
/** collect all libraries in tools. */
def libraryContent = project.copySpec {
from('tools/**/build/libs') {
include '**jar'
}
into kiekerPackagenamebase + "-" + kiekerVersion + "/build/libs"
}
/** collect example content for the binary distribution. */
def exampleContent = project.copySpec {
from('examples') {
include '**'
exclude '**/JavaEEServletContainerExample/build.xml'
exclude '**/livedemo-source/**'
exclude '**/.gradle/**'