forked from spotbugs/spotbugs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
122 lines (104 loc) · 3.21 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
plugins {
id "org.sonarqube" version "3.5.0.2730"
id "com.diffplug.spotless" version "6.11.0"
id "org.gradle.crypto.checksum" version "1.4.0"
id "com.github.spotbugs" version "5.0.13"
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
}
group = 'com.github.spotbugs'
version = '4.7.4-SNAPSHOT'
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/jacoco.gradle"
subprojects {
apply plugin: "constraints"
apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/eclipse.gradle"
apply from: "$rootDir/gradle/idea.gradle"
apply from: "$rootDir/gradle/test.gradle"
if (!project.name.equals("spotbugsTestCases")) {
apply from: "$rootDir/gradle/spotless.gradle"
}
group = 'com.github.spotbugs'
version = rootProject.version
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
}
allprojects {
repositories {
mavenCentral()
}
dependencies {
implementation platform('org.junit:junit-bom:5.9.1')
}
}
// https://discuss.gradle.org/t/merge-jacoco-coverage-reports-for-multiproject-setups/12100/6
task jacocoRootReport(type: JacocoReport) {
description = 'Merge all coverage reports before submit to SonarQube'
def reportTasks = project.getTasksByName("jacocoTestReport", true).minus(rootProject.jacocoTestReport)
dependsOn reportTasks
executionData.setFrom reportTasks.executionData
sourceDirectories.setFrom reportTasks.sourceDirectories
// Only enable class directories related to non-test project
classDirectories.setFrom files(reportTasks.classDirectories).filter {
!it.toString().contains("-test") && !it.toString().contains("Test") && !it.toString().contains("junit")
}
reports {
// JaCoCo SonarQube plugin needs a XML file to parse
// https://docs.sonarqube.org/display/PLUG/JaCoCo+Plugin
xml.required = true
}
}
import org.gradle.crypto.checksum.Checksum
def createReleaseBody = tasks.register("createReleaseBody")
def createChecksums = tasks.register("createChecksums", Checksum)
def publishTask = tasks.findByName("publish")
if (publishTask == null) {
publishTask = tasks.findByName("publishToMavenLocal")
}
def outputFile = file("$buildDir/release.md")
def inputFile = subprojects.collect {
it.hasProperty('publishing') ? it.publishing.publications.maven.artifacts : []
}.flatten().collect {
it.file
}
createChecksums.configure {
files = files(inputFile)
if (publishTask != null) {
dependsOn publishTask
}
}
createReleaseBody.configure {
inputs.files fileTree("$buildDir/checksums").matching {
include "*.sha256"
}
outputs.file outputFile
dependsOn createChecksums
doLast {
outputFile.delete()
outputFile << """SpotBugs ${project.version}
### CHANGELOG
- https://github.com/spotbugs/spotbugs/blob/${project.version}/CHANGELOG.md
### CHECKSUM
| file | checksum (sha256) |
| ---- | ----------------- |
"""
fileTree("$buildDir/checksums").matching {
include "*.sha256"
}.sort {
it.name
}.forEach {
def name = it.name.replace(".sha256", "")
def hash = it as String[]
outputFile << "| ${ name } | ${hash[0]} |\n"
}
}
}
nexusPublishing {
repositories {
sonatype()
}
}
apply from: "$rootDir/gradle/sonar.gradle"