forked from SpongePowered/SpongeAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
287 lines (254 loc) · 10.6 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
import net.ltgt.gradle.errorprone.errorprone
buildscript {
dependencies {
classpath("fr.inria.gforge.spoon:spoon-core:10.2.0") // bump for EIG
}
}
plugins {
eclipse
id("org.spongepowered.gradle.sponge.dev")
id("net.kyori.indra.checkstyle")
id("net.kyori.indra.crossdoc")
id("net.kyori.indra.publishing")
id("net.kyori.indra.publishing.sonatype")
id("org.spongepowered.gradle.event-impl-gen")
id("org.jetbrains.gradle.plugin.idea-ext")
id("net.ltgt.errorprone")
}
repositories {
maven("https://repo.spongepowered.org/repository/maven-public/") {
name = "sponge"
}
}
val ap by sourceSets.registering {
compileClasspath += sourceSets.main.get().compileClasspath + sourceSets.main.get().output
}
// Project dependencies
val adventureVersion: String by project
val configurateVersion: String by project
val gsonVersion: String by project
val guavaVersion: String by project
val log4jVersion: String by project
val mathVersion: String by project
dependencies {
val caffeineVersion: String by project
val errorproneVersion: String by project
val junitVersion: String by project
val mockitoVersion: String by project
val pluginSpiVersion: String by project
// Directly tied to what's available from Minecraft
api("org.apache.logging.log4j:log4j-api:$log4jVersion")
api("com.google.guava:guava:$guavaVersion") {
exclude(group ="com.google.code.findbugs", module = "jsr305") // We don't want to use jsr305, use checkerframework
exclude(group = "org.checkerframework", module = "checker-qual") // We use our own version
exclude(group = "com.google.j2objc", module = "j2objc-annotations")
exclude(group = "org.codehaus.mojo", module = "animal-sniffer-annotations")
}
api("com.google.code.gson:gson:$gsonVersion")
// Adventure
api(platform("net.kyori:adventure-bom:$adventureVersion"))
api("net.kyori:adventure-api")
api("net.kyori:adventure-text-serializer-gson") {
exclude(group = "com.google.code.gson", module = "gson")
exclude(group = "net.kyori", module = "adventure-api")
}
api("net.kyori:adventure-text-serializer-legacy") {
exclude(group = "net.kyori", module = "adventure-api")
}
api("net.kyori:adventure-text-serializer-plain") {
exclude(group = "net.kyori", module = "adventure-api")
}
api("net.kyori:adventure-text-minimessage") {
exclude(group = "net.kyori", module = "adventure-api")
}
// Dependency injection
api("com.google.inject:guice:5.0.1") {
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
}
// High performance cache + guava - shaded guava
api("com.github.ben-manes.caffeine:caffeine:$caffeineVersion") {
exclude(group= "org.checkerframework", module = "checker-qual")
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
}
implementation("com.github.ben-manes.caffeine:guava:$caffeineVersion") {
exclude(group = "com.google.guava", module = "guava")
exclude(group= "org.checkerframework", module = "checker-qual")
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
}
// Plugin spi, includes plugin-meta
api("org.spongepowered:plugin-spi:$pluginSpiVersion")
// Configurate
api(platform("org.spongepowered:configurate-bom:$configurateVersion"))
api("org.spongepowered:configurate-core") {
exclude(group = "org.checkerframework", module = "checker-qual") // We use our own version
}
api("org.spongepowered:configurate-hocon") {
exclude(group = "org.spongepowered", module = "configurate-core")
exclude(group= "org.checkerframework", module = "checker-qual")
}
api("org.spongepowered: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")
}
api("org.spongepowered:configurate-yaml") {
exclude(group = "org.spongepowered", module = "configurate-core")
exclude(group= "org.checkerframework", module = "checker-qual")
}
api("org.spongepowered:configurate-extra-guice") {
exclude(group = "com.google.inject", module = "guice")
}
// Compile-time static analysis
compileOnly("com.google.errorprone:error_prone_annotations:$errorproneVersion")
errorprone("com.google.errorprone:error_prone_core:$errorproneVersion")
// Math library
api("org.spongepowered:math:$mathVersion")
testImplementation(platform("org.junit:junit-bom:$junitVersion"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testImplementation("org.hamcrest:hamcrest:2.2")
testImplementation("org.mockito:mockito-core:$mockitoVersion")
}
tasks {
genEventImpl {
sourceCompatibility = "16"
destinationDir = project.layout.buildDirectory.dir("generated/event-factory").get().asFile
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/log4j-$log4jVersion/log4j-api/apidocs/",
"https://google.github.io/guice/api-docs/5.0.1/javadoc/",
"https://guava.dev/releases/$guavaVersion/api/docs/",
"https://configurate.aoeu.xyz/$configurateVersion/apidocs/",
"https://www.javadoc.io/doc/com.google.code.gson/gson/$gsonVersion/",
"https://jd.spongepowered.org/math/$mathVersion"
)
sequenceOf("api", "key", "text-serializer-gson", "text-serializer-legacy", "text-serializer-plain").forEach {
links("https://jd.advntr.dev/$it/$adventureVersion/")
}
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 as ExtensionAware).extensions["settings"].run {
require(this is ExtensionAware)
this.extensions.getByType(org.jetbrains.gradle.ext.ActionDelegationConfig::class).run {
delegateBuildRunToGradle = false
testRunner = org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner.PLATFORM
}
this.extensions.getByType(org.jetbrains.gradle.ext.TaskTriggersConfig::class).run {
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 {
val checkstyleVersion: String by project
javaVersions {
target(17)
}
checkstyle(checkstyleVersion)
configurePublications {
artifactId = project.name.toLowerCase()
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()
}
}