/
build.gradle.kts
298 lines (259 loc) · 9.4 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
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
import com.coditory.gradle.manifest.ManifestPluginExtension
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import io.freefair.gradle.plugins.lombok.LombokExtension
import io.freefair.gradle.plugins.lombok.tasks.Delombok
import me.champeau.jmh.JmhParameters
plugins {
signing
`java-library`
`maven-publish`
id("io.freefair.lombok").version("8.4").apply(false)
id("com.coditory.manifest").version("0.2.6").apply(false)
id("me.champeau.jmh").version("0.7.2").apply(false)
id("com.github.johnrengelman.shadow").version("8.1.1").apply(false)
id("com.github.gmazzo.buildconfig").version("5.3.5").apply(false)
}
group = group
version = version
allprojects {
repositories {
mavenCentral()
}
}
/**
* Enables com.coditory.manifest plugin for `publish` tasks or if `-PenableManifest` is supplied trough cli
*/
val enableManifest = with(project) {
gradle.startParameter.taskNames.any { s -> s.startsWith("publish") }
|| properties.containsKey("enableManifest")
}
// Subprojects
subprojects {
apply(plugin = "signing")
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "io.freefair.lombok")
apply(plugin = "me.champeau.jmh")
if (enableManifest) {
apply(plugin = "com.coditory.manifest")
project.extensions
.getByType(ManifestPluginExtension::class.java)
.apply { buildAttributes = false }
}
project.extensions.getByType(LombokExtension::class).apply {
version.set("1.18.30")
disableConfig.set(true)
}
project.extensions.getByType(JmhParameters::class).apply {
iterations.set(4)
fork.set(1)
}
// Source Compatibility
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}
// Dependency Management for Subprojects
dependencies {
constraints {
// Annotations
api(group = "org.jetbrains", name = "annotations", version = "24.1.0")
// Apache Commons
api(group = "commons-configuration", name = "commons-configuration", version = "1.10")
// Rate Limiting
api(group = "com.bucket4j", name = "bucket4j_jdk8-core", version = "8.7.0")
// HTTP
api(group = "com.squareup.okhttp3", name = "okhttp", version = "4.12.0")
// Credential Manager
api(group = "com.github.philippheuer.credentialmanager", name = "credentialmanager", version = "0.3.0")
// HTTP Client
api(group = "io.github.openfeign", name = "feign-slf4j", version = "13.1")
api(group = "io.github.openfeign", name = "feign-okhttp", version = "13.1")
api(group = "io.github.openfeign", name = "feign-jackson", version = "13.1")
api(group = "io.github.openfeign", name = "feign-hystrix", version = "13.1")
// WebSocket
api(group = "com.neovisionaries", name = "nv-websocket-client", version = "2.14")
// Regex
api(group = "com.github.tony19", name = "named-regexp", version = "0.2.8")
// Hystrix
api(group = "com.netflix.hystrix", name = "hystrix-core", version = "1.5.18")
// rich version declarations
listOf("com.fasterxml.jackson.core:jackson-annotations", "com.fasterxml.jackson.core:jackson-core", "com.fasterxml.jackson.core:jackson-databind", "com.fasterxml.jackson.datatype:jackson-datatype-jsr310").forEach { dep ->
add("api", dep) {
version {
strictly("[2.15,3-alpha[")
// renovate: depName=com.fasterxml.jackson:jackson-bom
prefer("2.16.1")
}
}
}
listOf("io.github.openfeign:feign-slf4j", "io.github.openfeign:feign-okhttp", "io.github.openfeign:feign-jackson", "io.github.openfeign:feign-hystrix").forEach { dep ->
add("api", dep) {
version {
// lower bound on accepted feign version; synced with current major version used by twitch4j
require("13.0")
}
}
}
}
// Apache Commons
api(group = "commons-io", name = "commons-io", version = "2.15.1")
api(group = "org.apache.commons", name = "commons-lang3", version = "3.14.0")
// Cache BOM
api(platform("io.github.xanthic.cache:cache-bom:0.5.0"))
// Events4J BOM
api(platform("com.github.philippheuer.events4j:events4j-bom:0.12.1"))
// Logging
api(group = "org.slf4j", name = "slf4j-api", version = "1.7.36")
// Jackson BOM
api(platform("com.fasterxml.jackson:jackson-bom:2.16.1"))
// Test
testImplementation(platform("org.junit:junit-bom:5.10.1"))
testImplementation(group = "org.junit.jupiter", name = "junit-jupiter")
// - Mocking
testImplementation(platform("org.mockito:mockito-bom:5.9.0"))
// - Await
testImplementation(group = "org.awaitility", name = "awaitility", version = "4.2.0")
// - Logging
testImplementation(group = "ch.qos.logback", name = "logback-classic", version = "1.3.14")
}
publishing {
repositories {
maven {
name = "maven"
url = uri(project.mavenRepositoryUrl)
credentials {
username = project.mavenRepositoryUsername
password = project.mavenRepositoryPassword
}
}
}
publications {
create<MavenPublication>("main") {
from(components["java"])
pom.default()
}
}
}
signing {
useGpgCmd()
sign(publishing.publications["main"])
}
// Source encoding
tasks {
// jar artifact id and version
withType<Jar> {
if (this is ShadowJar) {
archiveClassifier.set("shaded")
isEnableRelocation = true
relocationPrefix = "com.github.twitch4j.shaded.${"$version".replace(".", "_")}"
}
if (enableManifest) {
manifest.from(File(buildDir, "resources/main/META-INF/MANIFEST.MF"))
}
}
// reproducible builds
withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
// compile options
withType<JavaCompile> {
options.encoding = "UTF-8"
}
withType<Javadoc> {
options {
this as StandardJavadocDocletOptions
links(
"https://javadoc.io/doc/org.jetbrains/annotations/24.1.0",
"https://javadoc.io/doc/commons-configuration/commons-configuration/1.10",
"https://javadoc.io/doc/com.bucket4j/bucket4j_jdk8-core/8.7.0",
// "https://javadoc.io/doc/com.squareup.okhttp3/okhttp/4.12.0", // blocked by https://github.com/square/okhttp/issues/6450
"https://javadoc.io/doc/com.github.philippheuer.events4j/events4j-core/0.12.1",
"https://javadoc.io/doc/com.github.philippheuer.events4j/events4j-handler-simple/0.12.1",
"https://javadoc.io/doc/com.github.philippheuer.credentialmanager/credentialmanager/0.3.0",
"https://javadoc.io/doc/io.github.openfeign/feign-slf4j/13.1",
"https://javadoc.io/doc/io.github.openfeign/feign-okhttp/13.1",
"https://javadoc.io/doc/io.github.openfeign/feign-jackson/13.1",
"https://javadoc.io/doc/io.github.openfeign/feign-hystrix/13.1",
"https://javadoc.io/doc/org.slf4j/slf4j-api/1.7.36",
"https://javadoc.io/doc/com.neovisionaries/nv-websocket-client/2.14",
"https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/2.16.1",
"https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-core/2.16.1",
"https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-annotations/2.16.1",
"https://javadoc.io/doc/commons-io/commons-io/2.15.1",
"https://javadoc.io/doc/org.apache.commons/commons-lang3/3.14.0",
"https://javadoc.io/doc/org.projectlombok/lombok/1.18.30",
"https://twitch4j.github.io/javadoc"
)
locale = "en"
}
}
// javadoc & delombok
val delombok by getting(Delombok::class)
javadoc {
dependsOn(delombok)
source(delombok)
options {
title = "${project.name} (v${project.version})"
windowTitle = "${project.name} (v${project.version})"
encoding = "UTF-8"
overview = "../buildSrc/overview-single.html"
this as StandardJavadocDocletOptions
// hide javadoc warnings (a lot from delombok)
addStringOption("Xdoclint:none", "-quiet")
if (JavaVersion.current().isJava9Compatible) {
// javadoc / html5 support
addBooleanOption("html5", true)
}
}
}
// test
test {
useJUnitPlatform {
includeTags("unittest")
excludeTags("integration")
}
}
}
}
tasks.register<Javadoc>("aggregateJavadoc") {
enabled = JavaVersion.current().isJava9Compatible
group = JavaBasePlugin.DOCUMENTATION_GROUP
options {
title = "${rootProject.name} (v${project.version})"
windowTitle = "${rootProject.name} (v${project.version})"
encoding = "UTF-8"
this as StandardJavadocDocletOptions
overview = file("${rootDir}/buildSrc/overview-general.html").absolutePath
group("Common", "com.github.twitch4j.common*")
group("Core", "com.github.twitch4j", "com.github.twitch4j.domain*", "com.github.twitch4j.events*", "com.github.twitch4j.modules*")
group("Auth", "com.github.twitch4j.auth*")
group("Chat", "com.github.twitch4j.chat*")
group("EventSub", "com.github.twitch4j.eventsub*")
group("PubSub", "com.github.twitch4j.pubsub*")
group("Helix API", "com.github.twitch4j.helix*")
group("Twitch Message Interface - API", "com.github.twitch4j.tmi*")
group("GraphQL", "com.github.twitch4j.graphql*")
group("Extensions API", "com.github.twitch4j.extensions*")
group("Kraken API v5 (deprecated)", "com.github.twitch4j.kraken*")
addBooleanOption("html5").setValue(true)
}
source(subprojects.map { it.tasks.javadoc.get().source })
classpath = files(subprojects.map { it.tasks.javadoc.get().classpath })
setDestinationDir(file("${rootDir}/docs/static/javadoc"))
doFirst {
if (destinationDir?.exists() == true) {
destinationDir?.deleteRecursively()
}
}
doLast {
copy {
from(file("${destinationDir!!}/element-list"))
into(destinationDir!!)
rename { "package-list" }
}
}
}