-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.gradle.kts
203 lines (176 loc) · 6.18 KB
/
build.gradle.kts
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
import com.jashmore.gradle.JacocoCoverallsPlugin
import com.jashmore.gradle.ReleasePlugin
import com.jashmore.gradle.release
plugins {
java
`java-library`
checkstyle
jacoco
kotlin("jvm") version "1.9.0"
id("com.github.spotbugs")
id("com.jashmore.gradle.github.release")
id("org.jlleitschuh.gradle.ktlint") apply false
id("org.unbroken-dome.test-sets") version "4.0.0"
}
allprojects {
group = "com.jashmore"
version = "7.0.1-SNAPSHOT"
repositories {
mavenCentral()
maven(url = "https://oss.sonatype.org/content/repositories/snapshots")
jcenter()
}
}
val assertJVersion: String by project
val junitJupiterVersion: String by project
val logbackVersion: String by project
val lombokVersion: String by project
val mockitoVersion: String by project
val spotbugsVersion: String by project
subprojects {
val isKotlinProject = project.name.contains("kotlin") || project.name.contains("ktor")
val isExampleProject = project.name.contains("example")
apply(plugin = "java-library")
apply(plugin = "jacoco")
apply(plugin = "org.unbroken-dome.test-sets")
if (!isKotlinProject) {
if (!isExampleProject) {
apply(plugin = "com.github.spotbugs")
}
} else {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
}
dependencies {
// Lombok
compileOnly("org.projectlombok:lombok:$lombokVersion")
annotationProcessor("org.projectlombok:lombok:$lombokVersion")
testCompileOnly("org.projectlombok:lombok:$lombokVersion")
testAnnotationProcessor("org.projectlombok:lombok:$lombokVersion")
// Testing (JUnit, Mockito, etc)
testImplementation("org.assertj:assertj-core:$assertJVersion")
testImplementation("org.junit.jupiter:junit-jupiter:$junitJupiterVersion")
testImplementation("org.mockito:mockito-junit-jupiter:$mockitoVersion")
testImplementation("org.mockito:mockito-core:$mockitoVersion")
// Logging for tests
testImplementation("ch.qos.logback:logback-core:$logbackVersion")
testImplementation("ch.qos.logback:logback-classic:$logbackVersion")
if (!isKotlinProject && !isExampleProject) {
// SpotBugs
spotbugs("com.github.spotbugs:spotbugs:$spotbugsVersion")
}
}
tasks.withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
options.compilerArgs.addAll(setOf("-Xlint:all", "-Werror", "-Xlint:-processing", "-Xlint:-serial"))
}
if (!isKotlinProject) {
if (!isExampleProject) {
spotbugs {
excludeFilter.set(file("${project.rootDir}/configuration/spotbugs/bugsExcludeFilter.xml"))
}
}
}
tasks.withType<Test> {
useJUnitPlatform()
// Only run Jacoco in the test phase, not the integration test phase
jacoco {
toolVersion = "0.8.10"
}
}
testSets {
val integrationTest by creating {
}
}
tasks.jacocoTestReport {
reports {
xml.isEnabled = true
html.isEnabled = true
}
dependsOn(tasks.test)
}
tasks.jacocoTestCoverageVerification {
mustRunAfter(tasks.jacocoTestReport)
violationRules {
rule {
excludes = listOf(
"com.jashmore.sqs.examples*",
// these classes are better handled by integration tests
"com.jashmore.sqs.container.fifo*" ,
"com.jashmore.sqs.container.batching*",
"com.jashmore.sqs.container.prefetching*",
"com.jashmore.sqs.micronaut.configuration*",
"com.jashmore.sqs.micronaut.container*",
"com.jashmore.sqs.micronaut.placeholder*"
)
element = "PACKAGE"
limit {
minimum = 0.80.toBigDecimal()
value = "COVEREDRATIO"
counter = "LINE"
}
}
}
}
tasks.check {
dependsOn(tasks.jacocoTestReport)
dependsOn(tasks.jacocoTestCoverageVerification)
dependsOn(tasks.getByName("integrationTest"))
}
}
apply<JacocoCoverallsPlugin>()
apply<ReleasePlugin>()
release {
buildFile = getBuildFile()
sonatypeUsername = System.getenv("OSS_SONATYPE_USERNAME")
sonatypePassword = System.getenv("OSS_SONATYPE_PASSWORD")
signingKey = System.getenv("GPG_SIGNING_KEY_ASCII_ARMORED_FORMAT")
signingPassword = System.getenv("GPG_SIGNING_PASSWORD")
}
gitHubRelease {
gitHubUser = "JaidenAshmore"
repositoryName = "java-dynamic-sqs-listener"
milestoneVersion = (project.version as String).replace("-SNAPSHOT", "")
groupings = {
group {
heading = "## Enhancements"
filter = { issue ->
issue.labels.any { it.name == "enhancement" }
}
renderer = { issue, comments ->
val releaseNotes = comments
.filter { it.body.contains("### Release Notes") }
.map { it.body.substringAfter("### Release Notes") }
.firstOrNull() ?: issue.body.substringAfter("### Release Notes")
"""### ${issue.title} [GH-${issue.number}]
|
|${releaseNotes.trim()}
|
""".trimMargin()
}
}
group {
heading = "## Bug Fixes"
filter = { issue ->
issue.labels.any { it.name == "bug" }
}
renderer = { issue, _ -> "- [GH-${issue.number}]: ${issue.title}" }
}
group {
heading = "## Documentation"
filter = { issue ->
issue.labels.any { it.name == "documentation" }
}
renderer = { issue, _ -> "- [GH-${issue.number}]: ${issue.title}" }
}
}
}
/**
* Used to print out the current version so it can be saved as an output variable in a GitHub workflow.
*/
tasks.register("saveVersionForGitHub") {
doLast {
println("::set-output name=version::${project.version}")
}
}