-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathbuild.gradle.kts
294 lines (252 loc) · 11.1 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
// tl;dr, tells us off for using properties for versions. Too bad, we don't like trawling this file for version numbers.
@file:Suppress("GradlePackageVersionRange")
import net.modificationstation.stationapi.gradle.SubprojectHelpers.addDependencyXML
plugins {
id("maven-publish")
id("fabric-loom") version "1.9-SNAPSHOT"
id("babric-loom-extension") version "1.9.2"
}
// https://stackoverflow.com/a/40101046 - Even with kotlin, gradle can't get it's shit together.
inline fun <reified C> Project.configure(name: String, configuration: C.() -> Unit) {
(tasks.getByName(name) as C).configuration()
}
allprojects {
apply(plugin = "maven-publish")
apply(plugin = "fabric-loom")
apply(plugin = "babric-loom-extension")
java.sourceCompatibility = JavaVersion.VERSION_17
java.targetCompatibility = JavaVersion.VERSION_17
repositories {
maven(url = "https://maven.minecraftforge.net/")
maven(url = "https://maven.glass-launcher.net/babric")
maven(url = "https://maven.glass-launcher.net/snapshots")
maven(url = "https://maven.glass-launcher.net/releases")
maven(url = "https://jitpack.io/")
mavenCentral()
exclusiveContent {
forRepository {
maven(url = "https://api.modrinth.com/maven")
}
filter {
includeGroup("maven.modrinth")
}
}
}
configurations {
val transitiveImplementation = create("transitiveImplementation")
implementation.get().extendsFrom(transitiveImplementation)
// Required cause loom 0.14 for some reason doesn't remove asm-all 4.1. Ew.
all {
exclude(group = "org.ow2.asm", module = "asm-debug-all")
exclude(group = "org.ow2.asm", module = "asm-all")
}
}
dependencies {
implementation("org.slf4j:slf4j-api:1.8.0-beta4")
implementation("org.apache.logging.log4j:log4j-slf4j18-impl:2.17.2")
implementation("org.apache.logging.log4j:log4j-core:2.17.2")
implementation("com.google.guava:guava:33.2.1-jre")
implementation("com.google.code.gson:gson:2.9.0")
//to change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:${project.properties["minecraft_version"]}")
mappings("net.glasslauncher:biny:${project.properties["yarn_mappings"]}:v2")
modImplementation("net.fabricmc:fabric-loader:${project.properties["loader_version"]}")
"transitiveImplementation"("org.apache.commons:commons-lang3:3.12.0")
"transitiveImplementation"("commons-io:commons-io:2.11.0")
"transitiveImplementation"("net.jodah:typetools:${project.properties["typetools_version"]}")
"transitiveImplementation"("com.github.mineLdiver:UnsafeEvents:${project.properties["unsafeevents_version"]}")
"transitiveImplementation"("it.unimi.dsi:fastutil:${project.properties["fastutil_version"]}")
//noinspection GradlePackageUpdate
"transitiveImplementation"("com.github.ben-manes.caffeine:caffeine:${project.properties["caffeine_version"]}")
"transitiveImplementation"("com.mojang:datafixerupper:${project.properties["dfu_version"]}")
"transitiveImplementation"("maven.modrinth:spasm:${project.properties["spasm_version"]}")
// convenience stuff
// adds some useful annotations for data classes. does not add any dependencies
compileOnly("org.projectlombok:lombok:1.18.30")
annotationProcessor("org.projectlombok:lombok:1.18.30")
testCompileOnly("org.projectlombok:lombok:1.18.30")
testAnnotationProcessor("org.projectlombok:lombok:1.18.30")
// adds some useful annotations for miscellaneous uses. does not add any dependencies, though people without the lib will be missing some useful context hints.
implementation("org.jetbrains:annotations:23.0.0")
modLocalRuntime("net.glasslauncher.mods:ModMenu:${project.properties["modmenu_version"]}") {
isTransitive = false
}
modLocalRuntime("maven.modrinth:retrocommands:${project.properties["rc_version"]}") {
isTransitive = false
}
annotationProcessor("io.github.llamalad7:mixinextras-fabric:0.4.1")
}
loom {
@Suppress("UnstableApiUsage") // Too bad, this is needed.
mixin {
useLegacyMixinAp.set(true)
}
}
sourceSets {
test {
compileClasspath += sourceSets["main"].compileClasspath + sourceSets["main"].output
runtimeClasspath += sourceSets["main"].runtimeClasspath + sourceSets["main"].output
}
}
configure<ProcessResources>("processResources") {
var ver = project.properties["mod_version"]
if (project.properties["override_version"] != null) {
ver = "${project.properties["mod_version"]}+${project.properties["override_version"]}"
}
inputs.property("version", ver)
filesMatching("fabric.mod.json") {
expand(mapOf("version" to ver))
}
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
// Include license inside of the mod jar
configure<Jar>("jar") {
from("LICENSE") {
rename { "${it}_${project.properties["archivesBaseName"]}" }
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
// Makes gradle shut up
configure<JavaCompile>("compileJava") {
options.compilerArgs.add("-XDignore.symbol.file")
options.isFork = true
options.forkOptions.executable = System.getProperty("java.home") + "/bin/javac" + (if (System.getProperty("os.name").startsWith("Windows")) ".exe" else "")
}
publishing {
repositories {
if (project.hasProperty("glass_maven_url")) {
maven {
url = uri("${project.properties["glass_maven_url"]}")
credentials {
username = "${project.properties["glass_maven_username"]}"
password = "${project.properties["glass_maven_password"]}"
}
}
}
}
publications {
create<MavenPublication>("mavenJava") {
afterEvaluate {
artifact(tasks.getByName("remapJar")).builtBy(tasks.getByName("remapJar"))
artifact(tasks.getByName("remapSourcesJar")).builtBy(tasks.getByName("remapJar"))
}
pom {
withXml {
// Wipes dependency block, cause it's just hopelessly wrong, and also includes floader for some reason
val depsNode = asNode().appendNode("dependencies")
// Jank solution to an annoying issue
configurations.getByName("transitiveImplementation").dependencies.forEach {
val depNode = depsNode.appendNode("dependency")
depNode.appendNode("groupId", it.group)
depNode.appendNode("artifactId", it.name)
depNode.appendNode("version", it.version)
depNode.appendNode("scope", "compile")
}
}
}
}
}
}
}
//Subprojects will set these themselves
//Not neatly. - calm
group = project.properties["maven_group"]!!
base.archivesName.set(project.properties["archives_base_name"] as String)
version = (if (project.hasProperty("override_version")) (project.properties["override_version"] as String).substring(0, 7) else project.properties["mod_version"])!!
subprojects {
// This makes the older pre-releases easier to clean up.
group = if (rootProject.hasProperty("override_version")) {
(project.properties["maven_group"] as String) + ".StationAPI.${(project.properties["override_version"] as String).substring(0, 7)}"
}
else {
(project.properties["maven_group"] as String) + ".StationAPI.submodule.${project.properties["archivesBaseName"]}"
}
configurations {
create("out") {
isCanBeConsumed = true
isCanBeResolved = false
}
create("dev") {
isCanBeConsumed = true
isCanBeResolved = false
}
create("test") {
isCanBeConsumed = true
isCanBeResolved = false
}
}
tasks.register<Jar>("testJar") {
from(sourceSets["test"].output)
archiveClassifier.convention("test")
archiveClassifier.set("test")
}
artifacts {
artifacts.add("out", tasks.getByName("remapJar"))
artifacts.add("dev", tasks.getByName("jar"))
artifacts.add("test", tasks.getByName("testJar"))
}
//Attach the subproject to the root project
rootProject.dependencies {
implementation(project(path = ":$name", configuration = "dev"))
testImplementation(project(path = ":$name", configuration = "test"))
include(project(path = ":$name", configuration = "out"))
}
//Mark the subproject as a compile time dependency of the root project
rootProject.publishing {
publications {
getByName("mavenJava", MavenPublication::class) {
pom.withXml {
addDependencyXML(asNode(), "compile", project)
}
}
}
}
}
dependencies {
include("net.jodah:typetools:${project.properties["typetools_version"]}")
include("com.github.mineLdiver:UnsafeEvents:${project.properties["unsafeevents_version"]}")
include("it.unimi.dsi:fastutil:${project.properties["fastutil_version"]}")
include("com.github.ben-manes.caffeine:caffeine:${project.properties["caffeine_version"]}")
include("com.mojang:datafixerupper:${project.properties["dfu_version"]}")
include("maven.modrinth:spasm:${project.properties["spasm_version"]}")
}
// Makes java shut up
configure<JavaCompile>("compileTestJava") {
options.compilerArgs.add("-XDignore.symbol.file")
options.isFork = true
options.forkOptions.executable = System.getProperty("java.home") + "/bin/javac" + (if (System.getProperty("os.name").startsWith("Windows")) ".exe" else "")
}
publishing {
publications {
getByName("mavenJava", MavenPublication::class) {
artifactId = project.properties["archives_base_name"] as String
}
}
}
loom {
runs {
register("runTestmodClient") {
source("test")
client()
}
register("runTestmodServer") {
source("test")
server()
}
}
}
tasks.register<Jar>("testJar") {
from(sourceSets["test"].output)
archiveClassifier.convention("test")
archiveClassifier.set("test")
}