forked from MeteorDevelopment/meteor-client
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
246 lines (204 loc) · 6.63 KB
/
build.gradle.kts
File metadata and controls
246 lines (204 loc) · 6.63 KB
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
plugins {
alias(libs.plugins.fabric.loom)
id("maven-publish")
}
base {
archivesName = properties["archives_base_name"] as String
group = properties["maven_group"] as String
val suffix = if (project.hasProperty("build_number")) {
project.findProperty("build_number")
} else {
"local"
}
version = libs.versions.minecraft.get() + "-" + suffix
}
repositories {
maven {
name = "meteor-maven"
url = uri("https://maven.meteordev.org/releases")
}
maven {
name = "meteor-maven-snapshots"
url = uri("https://maven.meteordev.org/snapshots")
}
maven {
name = "Terraformers"
url = uri("https://maven.terraformersmc.com")
}
maven {
name = "ViaVersion"
url = uri("https://repo.viaversion.com")
}
mavenCentral()
exclusiveContent {
forRepository {
maven {
name = "modrinth"
url = uri("https://api.modrinth.com/maven")
}
}
filter {
includeGroup("maven.modrinth")
}
}
}
val modInclude: Configuration by configurations.creating
val jij: Configuration by configurations.creating
configurations {
// include mods
modImplementation.configure {
extendsFrom(modInclude)
}
include.configure {
extendsFrom(modInclude)
}
// include libraries (jar-in-jar)
implementation.configure {
extendsFrom(jij)
}
include.configure {
extendsFrom(jij)
}
}
sourceSets.create("launcher")
dependencies {
// Fabric
minecraft(libs.minecraft)
mappings(variantOf(libs.yarn) { classifier("v2") })
modImplementation(libs.fabric.loader)
val fapiVersion = libs.versions.fabric.api.get()
modInclude(fabricApi.module("fabric-api-base", fapiVersion))
modInclude(fabricApi.module("fabric-resource-loader-v1", fapiVersion))
// Compat fixes
modCompileOnly(fabricApi.module("fabric-renderer-indigo", fapiVersion))
modCompileOnly(libs.sodium) { isTransitive = false }
modCompileOnly(libs.lithium) { isTransitive = false }
modCompileOnly(libs.iris) { isTransitive = false }
modCompileOnly(libs.viafabricplus) { isTransitive = false }
modCompileOnly(libs.viafabricplus.api) { isTransitive = false }
modCompileOnly(libs.baritone)
modCompileOnly(libs.modmenu)
// Libraries (JAR-in-JAR)
jij(libs.orbit)
jij(libs.starscript)
jij(libs.discord.ipc)
jij(libs.reflections)
jij(libs.netty.handler.proxy) { isTransitive = false }
jij(libs.netty.codec.socks) { isTransitive = false }
jij(libs.waybackauthlib)
}
sourceSets {
val launcher = getByName("launcher")
launcher.apply {
java {
srcDir("src/launcher/java")
}
}
}
// Handle transitive dependencies for jar-in-jar
// Based on implementation from BaseProject by FlorianMichael/EnZaXD
// Source: https://github.com/FlorianMichael/BaseProject/blob/main/src/main/kotlin/de/florianmichael/baseproject/Fabric.kt
// Licensed under Apache License 2.0
afterEvaluate {
val jijConfig = configurations.findByName("jij") ?: return@afterEvaluate
// Dependencies to exclude from jar-in-jar
val excluded = setOf(
"org.slf4j", // Logging provided by Minecraft
"jsr305" // Compile time annotations only
)
jijConfig.incoming.resolutionResult.allDependencies.forEach { dep ->
val requested = dep.requested.displayName
if (excluded.any { requested.contains(it) }) return@forEach
val compileOnlyDep = dependencies.create(requested) {
isTransitive = false
}
val implDep = dependencies.create(compileOnlyDep)
dependencies.add("compileOnlyApi", compileOnlyDep)
dependencies.add("implementation", implDep)
dependencies.add("include", compileOnlyDep)
}
}
loom {
accessWidenerPath = file("src/main/resources/meteor-client.accesswidener")
}
tasks {
processResources {
val buildNumber = project.findProperty("build_number")?.toString() ?: ""
val commit = project.findProperty("commit")?.toString() ?: ""
val propertyMap = mapOf(
"version" to project.version,
"build_number" to buildNumber,
"commit" to commit,
"minecraft_version" to libs.versions.minecraft.get(),
"loader_version" to libs.versions.fabric.loader.get()
)
inputs.properties(propertyMap)
filesMatching("fabric.mod.json") {
expand(propertyMap)
}
}
// Compile launcher with Java 8 for backwards compatibility
getByName<JavaCompile>("compileLauncherJava") {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
options.compilerArgs.add("-Xlint:-options")
}
jar {
inputs.property("archivesName", project.base.archivesName.get())
from("LICENSE") {
rename { "${it}_${inputs.properties["archivesName"]}" }
}
// Include launcher classes
val launcher = sourceSets.getByName("launcher")
from(launcher.output.classesDirs)
from(launcher.output.resourcesDir)
manifest {
attributes["Main-Class"] = "meteordevelopment.meteorclient.Main"
}
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
if (System.getenv("CI")?.toBoolean() == true) {
withSourcesJar()
withJavadocJar()
}
}
withType<JavaCompile> {
options.compilerArgs.add("-Xlint:deprecation")
options.compilerArgs.add("-Xlint:unchecked")
}
javadoc {
with(options as StandardJavadocDocletOptions) {
addStringOption("Xdoclint:none", "-quiet")
addStringOption("encoding", "UTF-8")
addStringOption("charSet", "UTF-8")
}
}
build {
if (System.getenv("CI")?.toBoolean() == true) {
dependsOn("javadocJar")
}
}
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
artifactId = "meteor-client"
version = libs.versions.minecraft.get() + "-SNAPSHOT"
}
}
repositories {
maven("https://maven.meteordev.org/snapshots") {
name = "meteor-maven"
credentials {
username = System.getenv("MAVEN_METEOR_ALIAS")
password = System.getenv("MAVEN_METEOR_TOKEN")
}
authentication {
create<BasicAuthentication>("basic")
}
}
}
}