-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
220 lines (194 loc) · 7.4 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
import com.github.spotbugs.snom.Effort
import org.gradle.api.tasks.testing.logging.TestLogEvent
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
classpath group: 'com.diffplug.spotless', name: 'spotless-plugin-gradle', version: '6.25.0'
classpath group: 'gradle.plugin.com.github.spotbugs.snom', name: 'spotbugs-gradle-plugin', version: '4.7.5'
classpath group: 'net.ltgt.gradle', name: 'gradle-errorprone-plugin', version: '4.0.1'
classpath group: 'net.ltgt.gradle', name: 'gradle-nullaway-plugin', version: '2.0.0'
classpath group: 'gradle.plugin.com.dorongold.plugins', name: 'task-tree', version: '1.5'
classpath group: 'gradle.plugin.com.github.johnrengelman', name: 'shadow', version: '8.0.0'
}
}
allprojects { project ->
apply plugin: 'java'
apply plugin: 'checkstyle'
apply plugin: "com.github.spotbugs"
apply plugin: 'maven-publish'
apply plugin: 'java-library'
apply plugin: "jacoco"
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: 'com.diffplug.spotless'
apply plugin: "com.github.spotbugs"
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'net.ltgt.nullaway'
apply plugin: "com.dorongold.task-tree"
group 'com.nosto.beanie'
version '3.2.0'
repositories {
mavenCentral()
}
dependencies {
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.11.0'
testRuntimeOnly group: 'org.junit.vintage', name: 'junit-vintage-engine', version: '5.11.0'
implementation group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: '4.8.6'
testImplementation group: 'com.github.spotbugs', name: 'spotbugs-annotations', version: '4.8.6'
errorprone group: 'com.uber.nullaway', name: 'nullaway', version: '0.11.2'
errorprone group: 'com.google.errorprone', name: 'error_prone_core', version: '2.30.0'
spotbugsPlugins group: 'com.h3xstream.findsecbugs', name: 'findsecbugs-plugin', version: '1.13.0'
}
// Configuration for the nullaway extension. The rest of the parameters must be
// specified on the java-compile tasks. The only option that be specified here
// is the name of the root package to be analysed.
nullaway {
annotatedPackages.add("com.nosto")
}
// Configuration for the Jacoco plugin. It seems that it isn't possible to define
// the output report formats here and those seem to be defined on the individual
// task level.
// I'm not sure why the tool version is defined here and it isn't managed as a
// dependency.
jacoco {
toolVersion = "0.8.10"
}
// We only need the XML report so that the CI tools can parse it. The HTML isn't needed.
jacocoTestReport {
reports {
csv.required.set(true)
xml.required.set(false)
html.required.set(true)
}
dependsOn(test) // tests are required to run before generating the report
}
test {
useJUnitPlatform()
testLogging {
events = [TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED]
}
reports {
junitXml.required.set(true)
html.required.set(true)
}
maxParallelForks = (Runtime.runtime.availableProcessors() / 2 + 1) as int
finalizedBy(jacocoTestReport) // report is always generated after tests run
}
javadoc {
options {
addBooleanOption('html5', true)
}
}
tasks.register('sourcesJar', Jar) {
dependsOn(tasks.named('classes'))
archiveClassifier.set("sources")
from(sourceSets.main.allSource)
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withSourcesJar()
withJavadocJar()
}
// Configuration for the Spotbugs plugin. It seems that it isn't possible to define
// the output report formats here and those seem to be defined on the individual
// task level.
// I'm not sure why the tool version is defined here and it isn't managed as a
// dependency.
spotbugs {
toolVersion.set('4.8.6')
ignoreFailures.set(true)
effort.set(Effort.MAX)
excludeFilter.set(file("$rootDir/gradle/config/spotbugs/exclude.xml"))
}
// We only need the XML report so that the CI tools can parse it. The HTML isn't needed.
spotbugsMain {
reports {
xml.required.set(true)
}
}
// We only need the XML report so that the CI tools can parse it. The HTML isn't needed.
spotbugsTest {
reports {
xml.required.set(true)
}
}
// Configuration for the Checkstyle plugin. It seems that it isn't possible to define
// the output report formats here and those seem to be defined on the individual
// task level.
// I'm not sure why the tool version is defined here and it isn't managed as a
// dependency.
checkstyle {
toolVersion = "10.18.1"
config = rootProject.resources.text.fromFile("gradle/config/checkstyle/checkstyle.xml")
}
// We only need the XML report so that the CI tools can parse it. The HTML isn't needed
// and must be explicitly disabled
checkstyleMain {
reports {
xml.required.set(true)
html.required.set(false)
}
}
// We only need the XML report so that the CI tools can parse it. The HTML isn't needed.
checkstyleTest {
reports {
xml.required.set(true)
html.required.set(false)
}
}
publishing {
repositories {
maven {
name = "github"
url = uri("https://maven.pkg.github.com/nosto/beanie")
credentials(PasswordCredentials)
}
}
publications {
create("maven", MavenPublication) {
from components.java
pom {
name.set("Beanie")
description.set("A simple library to sanity-check your bean ser-deser")
url.set("https://github.com/nosto/beanie")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
scm {
connection.set("scm:git:git://github.com/nosto/beanie.git")
developerConnection.set("scm:git:ssh://github.com/nosto/beanie.git")
url.set("https://github.com/nosto/beanie")
}
issueManagement {
system.set("Github")
url.set("https://github.com/nosto/beanie/issues")
}
}
}
}
}
}
// Task for building the zip file for upload
tasks.register('buildZip', Zip) {
zip64 = true
archiveFileName.set("${rootProject.name}.zip")
from(compileJava)
from(processResources)
into('lib') {
from(configurations.runtimeClasspath)
}
}
shadowJar {
zip64 = true
}
build {
dependsOn(tasks.named('buildZip'))
}