-
-
Notifications
You must be signed in to change notification settings - Fork 342
/
build.gradle.kts
284 lines (253 loc) · 9.98 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
import net.ltgt.gradle.errorprone.errorprone
import org.jetbrains.gradle.ext.delegateActions
import org.jetbrains.gradle.ext.settings
import org.jetbrains.gradle.ext.taskTriggers
buildscript {
dependencies {
classpath(libs.spoon) // bump for EIG
}
}
plugins {
eclipse
alias(libs.plugins.spongeGradle.convention)
alias(libs.plugins.indra.checkstyle)
alias(libs.plugins.indra.crossdoc)
alias(libs.plugins.indra.publishing)
alias(libs.plugins.indra.publishing.sonatype)
alias(libs.plugins.eventImplGen)
alias(libs.plugins.ideaExt)
alias(libs.plugins.errorprone)
alias(libs.plugins.nexusPublish)
}
val javaTarget: String by project
val ap by sourceSets.registering {
compileClasspath += sourceSets.main.get().compileClasspath + sourceSets.main.get().output
}
configurations {
sequenceOf(apiElements, runtimeElements).forEach {
it.configure {
exclude(group = "org.jetbrains", module = "annotations")
}
}
}
// Project dependencies
dependencies {
// Directly tied to what's available from Minecraft
api(libs.log4j.api)
api(libs.gson)
// Adventure
api(platform(libs.adventure.bom))
api(libs.adventure.api)
api(libs.adventure.textSerializer.gson) {
exclude(group = "com.google.code.gson", module = "gson")
exclude(group = "net.kyori", module = "adventure-api")
}
api(libs.adventure.textSerializer.legacy) {
exclude(group = "net.kyori", module = "adventure-api")
}
api(libs.adventure.textSerializer.plain) {
exclude(group = "net.kyori", module = "adventure-api")
}
api(libs.adventure.minimessage) {
exclude(group = "net.kyori", module = "adventure-api")
}
// Dependency injection
api(libs.guice) {
exclude(group = "com.google.code.findbugs", module = "jsr305") // We don't want to use jsr305, use checkerframework
exclude(group = "javax.inject", module = "javax.inject")
exclude(group = "com.google.guava", module = "guava") // We use an older version than Guice does
exclude(group = "org.ow2.asm", module = "asm")
}
// High performance cache + guava - shaded guava
api(libs.caffeine) {
exclude(group = "org.checkerframework", module = "checker-qual")
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
exclude(group = "org.junit", module = "junit-bom")
exclude(group = "org.yaml", module = "snakeyaml")
exclude(group = "com.fasterxml.jackson", module = "jackson-bom")
exclude(group = "org.ow2.asm", module = "asm-bom")
}
// Plugin spi, includes plugin-meta
api(libs.pluginSpi) {
exclude(group = "org.checkerframework", module = "checker-qual")
exclude(group = "com.google.code.gson", module = "gson")
exclude(group = "org.apache.logging.log4j", module = "log4j-api")
}
// Configurate
api(platform(libs.configurate.bom))
api(libs.configurate.core) {
exclude(group = "org.checkerframework", module = "checker-qual") // We use our own version
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
}
api(libs.configurate.hocon) {
exclude(group = "org.spongepowered", module = "configurate-core")
exclude(group = "org.checkerframework", module = "checker-qual")
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
}
api(libs.configurate.gson) {
exclude(group = "org.spongepowered", module = "configurate-core")
exclude(group = "com.google.code.gson", module = "gson") // We have the same version technically, but use the gson we provide.
exclude(group = "org.checkerframework", module = "checker-qual")
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
}
api(libs.configurate.yaml) {
exclude(group = "org.spongepowered", module = "configurate-core")
exclude(group = "org.checkerframework", module = "checker-qual")
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
}
api(libs.configurate.extraGuice) {
exclude(group = "com.google.inject", module = "guice")
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
}
// Compile-time static analysis
compileOnly(libs.errorprone.annotations)
errorprone(libs.errorprone)
// Math library
api(libs.math) {
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
}
compileOnlyApi(libs.checkerQual)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.api)
testImplementation(libs.junit.params)
testRuntimeOnly(libs.junit.engine)
testRuntimeOnly(libs.junit.launcher)
testImplementation(libs.mockito)
}
tasks {
genEventImpl {
sourceCompatibility = "17" // TODO use javaTarget here
destinationDirectory = project.layout.buildDirectory.dir("generated/event-factory")
outputFactory = "org.spongepowered.api.event.SpongeEventFactory"
include("org/spongepowered/api/event/*/**/*")
exclude("org/spongepowered/api/event/action/InteractEvent.java")
exclude("org/spongepowered/api/event/cause/")
exclude("org/spongepowered/api/event/entity/AffectEntityEvent.java")
exclude("org/spongepowered/api/event/filter/")
exclude("org/spongepowered/api/event/impl/")
exclude("org/spongepowered/api/event/lifecycle/ProvideServiceEvent.java")
exclude("org/spongepowered/api/event/lifecycle/RegisterBuilderEvent.java")
exclude("org/spongepowered/api/event/lifecycle/RegisterRegistryEvent.java")
exclude("org/spongepowered/api/event/lifecycle/RegisterRegistryValueEvent.java")
exclude("org/spongepowered/api/event/lifecycle/RegisterCommandEvent.java")
exclude("org/spongepowered/api/event/lifecycle/RegisterFactoryEvent.java")
exclude("org/spongepowered/api/event/lifecycle/RegisterWorldEvent.java")
inclusiveAnnotations = setOf("org.spongepowered.api.util.annotation.eventgen.GenerateFactoryMethod")
exclusiveAnnotations = setOf("org.spongepowered.api.util.annotation.eventgen.NoFactoryMethod")
}
jar {
from(ap.get().output)
manifest {
attributes("Main-Class" to "org.spongepowered.api.util.InformativeMain")
attributes("Specification-Vendor" to "SpongePowered")
attributes("Specification-Title" to "SpongeAPI")
attributes("Specification-Version" to project.version)
if (!indraGit.isPresent) {
throw InvalidUserDataException("SpongeAPI must be built as a Git checkout, rather than through a zip/tar export")
}
indraGit.applyVcsInformationToManifest(this)
}
}
withType(JavaCompile::class).configureEach {
options.apply {
compilerArgs.addAll(listOf("-Xlint:-path"))
isDeprecation = false
}
}
javadoc {
options {
(this as? StandardJavadocDocletOptions)?.apply {
links(
"https://logging.apache.org/log4j/2.x/javadoc/log4j-api/",
"https://google.github.io/guice/api-docs/${libs.versions.guice.get()}/javadoc/",
"https://configurate.aoeu.xyz/${libs.versions.configurate.get()}/apidocs/",
"https://www.javadoc.io/doc/com.google.code.gson/gson/${libs.versions.gson.get()}/",
"https://jd.spongepowered.org/math/${libs.versions.math.get()}"
)
sequenceOf("api", "key", "text-serializer-gson", "text-serializer-legacy", "text-serializer-plain").forEach {
links("https://jd.advntr.dev/$it/${libs.versions.adventure.get()}/")
}
addBooleanOption("quiet", true)
}
}
}
withType(JavaCompile::class).configureEach {
options.errorprone {
disable("FutureReturnValueIgnored") // this check doesn't handle CompletableFuture properly
disable("EqualsGetClass") // conflicts with IntelliJ defaults
disable("MissingSummary") // TODO: Re-enable this check once Javadoc is in a better state
}
}
//
// val shadowJar by registering(ShadowJar::class) {
// archiveClassifier.set("shaded")
// from(ap.get().output)
//
// }
}
idea {
if (project != null) {
project.settings.run {
delegateActions {
delegateBuildRunToGradle = false
testRunner = org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner.PLATFORM
}
taskTriggers {
beforeBuild(tasks.genEventImpl)
}
}
}
}
eclipse {
synchronizationTasks(tasks.genEventImpl)
}
val organization: String by project
val projectUrl: String by project
val projectDescription: String by project
spongeConvention {
repository("SpongeAPI") {
ci(true)
publishing(true)
}
mitLicense()
licenseParameters {
this["name"] = "SpongeAPI"
this["organization"] = organization
this["url"] = projectUrl
}
}
indra {
javaVersions {
target(javaTarget.toInt())
}
checkstyle(libs.versions.checkstyle.get())
configurePublications {
artifactId = project.name.lowercase()
pom {
this.url.set(projectUrl)
this.description.set(projectDescription)
}
}
}
indraCrossdoc {
baseUrl(providers.gradleProperty("javadocPublishRoot"))
nameBasedDocumentationUrlProvider {
lowercaseProjectName.set(true)
}
}
spotless {
java {
toggleOffOn("@formatter:off", "@formatter:on")
endWithNewline()
indentWithSpaces(4)
trimTrailingWhitespace()
formatAnnotations()
removeUnusedImports()
importOrderFile(rootProject.file("extra/eclipse/sponge_eclipse.importorder"))
}
kotlinGradle {
endWithNewline()
indentWithSpaces(4)
trimTrailingWhitespace()
}
}