-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
271 lines (231 loc) · 8.26 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
@file:Suppress("PropertyName")
import org.jetbrains.gradle.ext.Gradle
import org.jetbrains.gradle.ext.compiler
import org.jetbrains.gradle.ext.runConfigurations
import org.jetbrains.gradle.ext.settings
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.23")
}
}
plugins {
id("java")
id("java-library")
kotlin("jvm") version libs.versions.kotlinVersion
kotlin("plugin.serialization") version libs.versions.kotlinVersion
id("maven-publish")
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
id("eclipse")
id("com.gtnewhorizons.retrofuturagradle") version "1.3.27"
id("com.matthewprenger.cursegradle") version "1.4.0"
}
val mod_version: String by project
val maven_group: String by project
version = mod_version
group = maven_group
val archives_base_name: String by project
val use_access_transformer: String by project
val use_mixins: String by project
val use_coremod: String by project
val use_assetmover: String by project
val include_mod: String by project
val coremod_plugin_class_name: String by project
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
// Azul covers the most platforms for Java 8 toolchains, crucially including MacOS arm64
vendor.set(JvmVendorSpec.AZUL)
}
// Generate sources and javadocs jars when building and publishing
withSourcesJar()
// withJavadocJar()
}
tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
configurations {
val embed = create("embed")
implementation.configure {
extendsFrom(embed)
}
}
minecraft {
mcVersion.set("1.12.2")
// MCP Mappings
mcpMappingChannel.set("stable")
mcpMappingVersion.set("39")
// Set username here, the UUID will be looked up automatically
username.set("Developer")
// Add any additional tweaker classes here
// extraTweakClasses.add("org.spongepowered.asm.launch.MixinTweaker")
// Add various JVM arguments here for runtime
val args = mutableListOf("-ea:${group}")
if (use_coremod.toBoolean()) {
args += "-Dfml.coreMods.load=$coremod_plugin_class_name"
}
if (use_mixins.toBoolean()) {
args += "-Dmixin.hotSwap=true"
args += "-Dmixin.checks.interfaces=true"
args += "-Dmixin.debug.export=true"
}
extraRunJvmArguments.addAll(args)
// Include and use dependencies' Access Transformer files
useDependencyAccessTransformers.set(true)
// Add any properties you want to swap out for a dynamic value at build time here
// Any properties here will be added to a class at build time, the name can be configured below
injectedTags.put("VERSION", mod_version)
}
// Generate a group.archives_base_name.Tags class
tasks.injectTags.configure {
// Change Tags class' name here:
outputClassName.set("${maven_group}.${archives_base_name.lowercase()}.Tags")
}
repositories {
maven {
name = "CleanroomMC Maven"
url = uri("https://maven.cleanroommc.com")
}
maven {
name = "SpongePowered Maven"
url = uri("https://repo.spongepowered.org/maven")
}
maven {
name = "CurseMaven"
url = uri("https://cursemaven.com")
content {
includeGroup("curse.maven")
}
}
maven {
name = "JitPack"
url = uri("https://jitpack.io")
}
mavenLocal() // Must be last for caching to work
}
dependencies {
implementation("io.github.chaosunity.forgelin:Forgelin-Continuous:1.9.23.0") {
exclude("net.minecraftforge")
}
// Kotlin
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${libs.versions.kotlinVersion.get()}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2")
// Fluidlogged API
implementation(rfg.deobf("com.github.jbredwards:fluidlogged-api:47f153989e"))
// Biomes O' Plenty
implementation(rfg.deobf("curse.maven:bop-220318:2842510"))
// Serene Seasons
implementation(rfg.deobf("curse.maven:sereneseasons-291874:2799213"))
// Streams
runtimeOnly(rfg.deobf("curse.maven:streams-229769:3109315"))
runtimeOnly(rfg.deobf("curse.maven:farseek-229708:3093852"))
// Dynamic Trees
compileOnly("curse.maven:dynamictrees-252818:3812474")
// Simple Difficulty
runtimeOnly("curse.maven:simpledifficulty-for-underdog-574162:4434298")
if (use_assetmover.toBoolean()) {
implementation("com.cleanroommc:assetmover:2.5")
}
if (use_mixins.toBoolean()) {
implementation("zone.rong:mixinbooter:7.1")
}
if (use_mixins.toBoolean()) {
// Change your mixin refmap name here:
val mixin =
modUtils.enableMixins("org.spongepowered:mixin:0.8.3", "mixins.${archives_base_name.lowercase()}.refmap.json") as String
api(mixin) {
isTransitive = true
}
annotationProcessor("org.ow2.asm:asm-debug-all:5.2")
annotationProcessor("com.google.guava:guava:24.1.1-jre")
annotationProcessor("com.google.code.gson:gson:2.8.6")
annotationProcessor(mixin) {
isTransitive = false
}
}
}
// Adds Access Transformer files to tasks
if (use_access_transformer.toBoolean()) {
for (at in sourceSets.getByName("main").resources.files) {
if (at.name.lowercase().endsWith("_at.cfg")) {
tasks.deobfuscateMergedJarToSrg.get().accessTransformerFiles.from(at)
tasks.srgifyBinpatchedJar.get().accessTransformerFiles.from(at)
}
}
}
@Suppress("UnstableApiUsage")
tasks.withType<ProcessResources> {
// This will ensure that this task is redone when the versions change
inputs.property("version", mod_version)
inputs.property("mcversion", minecraft.mcVersion)
// Replace various properties in mcmod.info and pack.mcmeta if applicable
filesMatching(arrayListOf("mcmod.info", "pack.mcmeta")) {
expand(
"version" to mod_version,
"mcversion" to minecraft.mcVersion
)
}
if (use_access_transformer.toBoolean()) {
rename("(.+_at.cfg)", "META-INF/$1") // Make sure Access Transformer files are in META-INF folder
}
}
tasks.withType<Jar> {
archiveBaseName.set("$archives_base_name-${minecraft.mcVersion.get()}")
manifest {
val attributeMap = mutableMapOf<String, String>()
if (use_coremod.toBoolean()) {
attributeMap["FMLCorePlugin"] = coremod_plugin_class_name
if (include_mod.toBoolean()) {
attributeMap["FMLCorePluginContainsFMLMod"] = true.toString()
attributeMap["ForceLoadAsMod"] = (project.gradle.startParameter.taskNames[0] == "build").toString()
}
}
if (use_access_transformer.toBoolean()) {
attributeMap["FMLAT"] = archives_base_name.lowercase() + "_at.cfg"
}
attributes(attributeMap)
}
// Add all embedded dependencies into the jar
from(provider {
configurations.getByName("embed").map {
if (it.isDirectory()) it else zipTree(it)
}
})
}
idea {
module {
inheritOutputDirs = true
}
project {
settings {
runConfigurations {
add(Gradle("1. Run Client").apply {
setProperty("taskNames", listOf("runClient"))
})
add(Gradle("2. Run Server").apply {
setProperty("taskNames", listOf("runServer"))
})
add(Gradle("3. Run Obfuscated Client").apply {
setProperty("taskNames", listOf("runObfClient"))
})
add(Gradle("4. Run Obfuscated Server").apply {
setProperty("taskNames", listOf("runObfServer"))
})
}
compiler.javac {
afterEvaluate {
javacAdditionalOptions = "-encoding utf8"
moduleJavacAdditionalOptions = mutableMapOf(
(project.name + ".main") to tasks.compileJava.get().options.compilerArgs.joinToString(" ") { "\"$it\"" }
)
}
}
}
}
}
tasks.named("processIdeaSettings").configure {
dependsOn("injectTags")
}