forked from spotbugs/spotbugs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
141 lines (122 loc) · 3.89 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
plugins {
id "org.sonarqube" version "4.4.0.3356"
id "org.gradle.crypto.checksum" version "1.4.0"
id "com.github.spotbugs" version "6.0.0-beta.3"
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
}
group = 'com.github.spotbugs'
version = '4.8.0-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 {
def junitVersion = '5.10.0'
compileOnly platform("org.junit:junit-bom:$junitVersion")
testImplementation platform("org.junit:junit-bom:$junitVersion")
}
}
// 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
}
subprojects.each {
dependsOn("${it.name}:jar")
}
dependsOn(":spotbugs:javadocJar")
dependsOn(":spotbugs:sourcesJar")
dependsOn(":spotbugs-annotations:javadocJar")
dependsOn(":spotbugs-annotations:sourcesJar")
dependsOn(":spotbugs-ant:javadocJar")
dependsOn(":spotbugs-ant:sourcesJar")
dependsOn(":test-harness:javadocJar")
dependsOn(":test-harness:sourcesJar")
dependsOn(":test-harness-core:javadocJar")
dependsOn(":test-harness-core:sourcesJar")
dependsOn(":test-harness-jupiter:javadocJar")
dependsOn(":test-harness-jupiter:sourcesJar")
dependsOn(":spotbugs:distZip")
dependsOn(":spotbugs:distTar")
}
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"