-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
375 lines (338 loc) · 13.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
import java.util.Locale
plugins {
`maven-publish`
`java-library`
eclipse
id("org.spongepowered.gradle.vanilla")
id("org.cadixdev.licenser")
id("com.github.johnrengelman.shadow")
id("org.spongepowered.gradle.sponge.dev") apply false // for version json generation
id("implementation-structure")
id("org.jetbrains.gradle.plugin.idea-ext")
id("com.palantir.git-version") version "0.12.3"
}
val commonProject = project
val apiVersion: String by project
val minecraftVersion: String by project
val recommendedVersion: String by project
val asmVersion: String by project
val modlauncherVersion: String by project
val mixinVersion: String by project
val pluginSpiVersion: String by project
val guavaVersion: String by project
val junitVersion: String by project
val timingsVersion: String by project
val gitVersion: groovy.lang.Closure<String> by extra
val commonManifest = the<JavaPluginConvention>().manifest {
attributes(
"Specification-Title" to "Sponge",
"Specification-Vendor" to "SpongePowered",
"Specification-Version" to apiVersion,
"Implementation-Title" to project.name,
"Implementation-Version" to gitVersion(),
"Implementation-Vendor" to "SpongePowered"
)
}
tasks {
jar {
manifest.from(commonManifest)
}
val mixinsJar by registering(Jar::class) {
archiveClassifier.set("mixins")
manifest.from(commonManifest)
from(mixins.map { it.output })
}
val accessorsJar by registering(Jar::class) {
archiveClassifier.set("accessors")
manifest.from(commonManifest)
from(accessors.map { it.output })
}
val launchJar by registering(Jar::class) {
archiveClassifier.set("launch")
manifest.from(commonManifest)
from(launch.map { it.output })
}
val applaunchJar by registering(Jar::class) {
archiveClassifier.set("applaunch")
manifest.from(commonManifest)
from(applaunch.map { it.output })
}
test {
useJUnitPlatform()
}
check {
dependsOn(gradle.includedBuild("SpongeAPI").task(":check"))
}
}
version = gitVersion()
// Configurations
val applaunchConfig by configurations.register("applaunch")
val launchConfig by configurations.register("launch") {
extendsFrom(configurations.minecraft.get())
extendsFrom(applaunchConfig)
}
val accessorsConfig by configurations.register("accessors") {
extendsFrom(launchConfig)
}
val mixinsConfig by configurations.register("mixins") {
extendsFrom(applaunchConfig)
extendsFrom(launchConfig)
}
// create the sourcesets
val main by sourceSets
val applaunch by sourceSets.registering {
spongeImpl.applyNamedDependencyOnOutput(project, this, main, project, main.implementationConfigurationName)
project.dependencies {
mixinsConfig([email protected])
}
configurations.named(implementationConfigurationName) {
extendsFrom(applaunchConfig)
}
}
val launch by sourceSets.registering {
spongeImpl.applyNamedDependencyOnOutput(project, applaunch.get(), this, project, this.implementationConfigurationName)
project.dependencies {
mixinsConfig([email protected])
}
project.dependencies {
implementation([email protected])
}
configurations.named(implementationConfigurationName) {
extendsFrom(launchConfig)
}
}
val accessors by sourceSets.registering {
spongeImpl.applyNamedDependencyOnOutput(project, launch.get(), this, project, this.implementationConfigurationName)
spongeImpl.applyNamedDependencyOnOutput(project, this, main, project, main.implementationConfigurationName)
configurations.named(implementationConfigurationName) {
extendsFrom(accessorsConfig)
}
}
val mixins by sourceSets.registering {
spongeImpl.applyNamedDependencyOnOutput(project, launch.get(), this, project, this.implementationConfigurationName)
spongeImpl.applyNamedDependencyOnOutput(project, applaunch.get(), this, project, this.implementationConfigurationName)
spongeImpl.applyNamedDependencyOnOutput(project, accessors.get(), this, project, this.implementationConfigurationName)
spongeImpl.applyNamedDependencyOnOutput(project, main, this, project, this.implementationConfigurationName)
configurations.named(implementationConfigurationName) {
extendsFrom(mixinsConfig)
}
}
dependencies {
// api
api("org.spongepowered:spongeapi:$apiVersion")
// Database stuffs... likely needs to be looked at
implementation("com.zaxxer:HikariCP:2.6.3")
implementation("org.mariadb.jdbc:mariadb-java-client:2.0.3")
implementation("com.h2database:h2:1.4.196")
implementation("org.xerial:sqlite-jdbc:3.20.0")
implementation("javax.inject:javax.inject:1")
// Timings
implementation("org.spongepowered:timings:$timingsVersion")
// ASM - required for generating event listeners
implementation("org.ow2.asm:asm-util:$asmVersion")
implementation("org.ow2.asm:asm-tree:$asmVersion")
// Implementation-only Adventure
implementation(platform("net.kyori:adventure-bom:4.7.0"))
implementation("net.kyori:adventure-serializer-configurate4")
// Launch Dependencies - Needed to bootstrap the engine(s)
launchConfig("org.spongepowered:spongeapi:$apiVersion")
launchConfig("org.spongepowered:plugin-spi:$pluginSpiVersion")
launchConfig("org.spongepowered:mixin:$mixinVersion")
launchConfig("org.checkerframework:checker-qual:3.4.1")
launchConfig("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")
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
}
launchConfig("com.google.code.gson:gson:2.8.0")
launchConfig("org.ow2.asm:asm-tree:$asmVersion")
launchConfig("org.ow2.asm:asm-util:$asmVersion")
// Applaunch -- initialization that needs to occur without game access
applaunchConfig("org.spongepowered:plugin-spi:$pluginSpiVersion")
applaunchConfig("org.apache.logging.log4j:log4j-api:2.11.2")
applaunchConfig("com.google.guava:guava:$guavaVersion")
applaunchConfig(platform("org.spongepowered:configurate-bom:4.1.1"))
applaunchConfig("org.spongepowered:configurate-core") {
exclude(group = "org.checkerframework", module = "checker-qual") // We use our own version
}
applaunchConfig("org.spongepowered:configurate-hocon") {
exclude(group = "org.spongepowered", module = "configurate-core")
exclude(group = "org.checkerframework", module = "checker-qual") // We use our own version
}
applaunchConfig("org.spongepowered:configurate-jackson") {
exclude(group = "org.spongepowered", module = "configurate-core")
exclude(group = "org.checkerframework", module = "checker-qual") // We use our own version
}
applaunchConfig("org.apache.logging.log4j:log4j-core:2.11.2")
mixinsConfig(sourceSets.named("main").map { it.output })
mixinsConfig("org.spongepowered:timings:$timingsVersion")
add(mixins.get().implementationConfigurationName, "org.spongepowered:spongeapi:$apiVersion")
// Tests
testImplementation("org.junit.jupiter:junit-jupiter-api:$junitVersion")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$junitVersion")
}
val organization: String by project
val projectUrl: String by project
license {
properties {
this["name"] = "Sponge"
this["organization"] = organization
this["url"] = projectUrl
}
header(rootProject.file("HEADER.txt"))
include("**/*.java")
newLine(false)
}
allprojects {
configurations.configureEach {
resolutionStrategy.dependencySubstitution {
// https://github.com/zml2008/guice/tree/backport/5.0.1
substitute(module("com.google.inject:guice:5.0.1"))
.because("We need to run against Guava 21")
.using(module("ca.stellardrift.guice-backport:guice:5.0.1"))
}
}
apply(plugin = "org.jetbrains.gradle.plugin.idea-ext")
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "org.cadixdev.licenser")
base {
archivesBaseName = name.toLowerCase(Locale.ENGLISH)
}
plugins.withId("org.spongepowered.gradle.vanilla") {
minecraft {
version(minecraftVersion)
injectRepositories(false)
project.sourceSets["main"].resources
.filter { it.name.endsWith(".accesswidener") }
.files
.forEach {
accessWideners(it)
parent?.minecraft?.accessWideners(it)
}
}
}
idea {
if (project != null) {
(project as ExtensionAware).extensions["settings"].run {
(this as ExtensionAware).extensions.getByType(org.jetbrains.gradle.ext.ActionDelegationConfig::class).run {
delegateBuildRunToGradle = false
testRunner = org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner.PLATFORM
}
(this as ExtensionAware).extensions.getByType(org.jetbrains.gradle.ext.IdeaCompilerConfiguration::class).run {
addNotNullAssertions = false
useReleaseOption = JavaVersion.current().isJava10Compatible
parallelCompilation = true
}
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType<AbstractArchiveTask> {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
val spongeSnapshotRepo: String? by project
val spongeReleaseRepo: String? by project
tasks {
val emptyAnnotationProcessors = objects.fileCollection()
withType(JavaCompile::class).configureEach {
options.compilerArgs.addAll(listOf("-Xmaxerrs", "1000"))
options.encoding = "UTF-8"
if (JavaVersion.current().isJava10Compatible) {
options.release.set(8)
}
options.annotationProcessorPath = emptyAnnotationProcessors // hack so IntelliJ doesn't try to run Mixin AP
}
}
sourceSets.configureEach {
val sourceSet = this
val sourceJarName: String = if ("main".equals(this.name)) "sourceJar" else "${this.name}SourceJar"
tasks.register(sourceJarName, Jar::class.java) {
group = "build"
val classifier = if ("main".equals(sourceSet.name)) "sources" else "${sourceSet.name}sources"
archiveClassifier.set(classifier)
from(sourceSet.allJava)
}
}
afterEvaluate {
publishing {
repositories {
maven {
name = "GitHubPackages"
this.url = uri("https://maven.pkg.github.com/${System.getenv("GITHUB_REPOSITORY")}")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}
}
}
}
tasks {
val jar by existing
val sourceJar by existing
val mixinsJar by existing
val accessorsJar by existing
val launchJar by existing
val applaunchJar by existing
shadowJar {
mergeServiceFiles()
archiveClassifier.set("dev")
manifest {
attributes(mapOf(
"Access-Widener" to "common.accesswidener",
"Multi-Release" to true
))
from(commonManifest)
}
from(jar)
from(sourceJar)
from(mixinsJar)
from(accessorsJar)
from(launchJar)
from(applaunchJar)
dependencies {
include(project(":"))
}
}
}
publishing {
publications {
register("sponge", MavenPublication::class) {
from(components["java"])
artifact(tasks["sourceJar"])
artifact(tasks["mixinsJar"])
artifact(tasks["accessorsJar"])
artifact(tasks["launchJar"])
artifact(tasks["applaunchJar"])
artifact(tasks["applaunchSourceJar"])
artifact(tasks["launchSourceJar"])
artifact(tasks["mixinsSourceJar"])
artifact(tasks["accessorsSourceJar"])
pom {
artifactId = project.name.toLowerCase()
this.name.set(project.name)
this.description.set(project.description)
this.url.set(projectUrl)
licenses {
license {
this.name.set("MIT")
this.url.set("https://opensource.org/licenses/MIT")
}
}
scm {
connection.set("scm:git:git://github.com/SpongePowered/Sponge.git")
developerConnection.set("scm:git:ssh://github.com/SpongePowered/Sponge.git")
this.url.set(projectUrl)
}
}
}
}
}