-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.gradle.kts
208 lines (183 loc) · 7.11 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
import java.text.NumberFormat
import java.text.ParseException
import java.util.Locale
import org.apache.commons.lang3.SystemUtils
plugins {
idea
java
id("gg.essential.loom") version ("1.6.21")
id("dev.architectury.architectury-pack200") version ("0.1.3")
id("io.freefair.lombok") version ("8.11")
id("com.gradleup.shadow") version ("8.3.0")
id("net.kyori.blossom") version ("1.3.1")
}
val group: String by project
val version: String by project
val minecraftVersion: String by project
val modId = project.name.lowercase(Locale.US)
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
}
blossom {
if (project.hasProperty("runningOnCi")) {
if (!project.hasProperty("buildNumber")) {
throw InvalidUserDataException("No build number provided for CI build.")
} else if (!project.hasProperty("runAttempt")) {
throw InvalidUserDataException("No run attempt provided for CI build.")
} else {
val nf = NumberFormat.getIntegerInstance(Locale.US)
val buildNumber = project.property("buildNumber")
val runAttempt = project.property("runAttempt")
val includeRunAttempt = nf.parse(runAttempt as String).toInt() > 1
try {
if (includeRunAttempt) {
project.setProperty("buildNumber", "${buildNumber}.${nf.parse(runAttempt).toInt() - 1}")
}
project.version = "${project.version}+" + project.property("buildNumber")
} catch (e: ParseException) {
throw InvalidUserDataException("Build number could not be parsed (${e.message})", e)
}
}
}
replaceTokenIn("src/main/java/codes/biscuit/skyblockaddons/SkyblockAddons.java")
replaceToken("@VERSION@", version)
replaceToken("@MOD_ACCEPTED@", minecraftVersion)
replaceToken("@BUILD_NUMBER@", project.property("buildNumber"))
}
loom {
runConfigs {
getByName("client") {
vmArg("-Xmx3G")
property("mixin.debug", "true")
property("devauth.enabled", "true")
property("fml.coreMods.load", "codes.biscuit.skyblockaddons.tweaker.SkyblockAddonsLoadingPlugin")
programArgs("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker")
if (SystemUtils.IS_OS_MAC_OSX) {
// This argument causes a crash on macOS
vmArgs.remove("-XstartOnFirstThread")
}
}
remove(getByName("server"))
}
// Change this to one of the other log configs if desired
log4jConfigs.from(file("log-config.xml"))
forge {
pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter())
accessTransformer("src/main/resources/META-INF/skyblockaddons_at.cfg")
mixinConfig("mixins.${modId}.json")
}
mixin.defaultRefmapName = "mixins.${modId}.refmap.json"
}
sourceSets {
main {
// Forge needs resources to be in the same directory as the classes.
output.setResourcesDir(java.classesDirectory)
}
}
val bundle: Configuration by configurations.creating {
configurations.implementation.get().extendsFrom(this)
}
repositories {
mavenCentral()
gradlePluginPortal()
maven("https://repo.spongepowered.org/maven/")
maven("https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1")
maven("https://repo.hypixel.net/repository/Hypixel/")
maven("https://jitpack.io") {
content {
includeGroupByRegex("com\\.github\\..*")
}
}
}
dependencies {
minecraft("com.mojang:minecraft:${minecraftVersion}")
mappings("de.oceanlabs.mcp:mcp_stable:22-1.8.9")
forge("net.minecraftforge:forge:1.8.9-11.15.1.2318-1.8.9")
runtimeOnly("me.djtheredstoner:DevAuth-forge-legacy:1.2.1")
bundle("org.spongepowered:mixin:0.7.11-SNAPSHOT") {
isTransitive = false
}
annotationProcessor("org.spongepowered:mixin:0.8.7-SNAPSHOT:processor")
compileOnly("net.hypixel:mod-api-forge:1.0.1.1") {
exclude(group = "me.djtheredstoner", module = "DevAuth-forge-legacy")
}
bundle("net.hypixel:mod-api-forge-tweaker:1.0.1.1")
// Discord RPC for Java https://github.com/jagrosh/DiscordIPC
bundle("io.github.CDAGaming:DiscordIPC:0.10.2") {
exclude(module = "log4j")
because("Different version conflicts with Minecraft's Log4J")
exclude(module = "gson")
because("Different version conflicts with Minecraft's GSON")
}
testImplementation("org.junit.jupiter:junit-jupiter:5.11.0")
}
tasks.withType(JavaCompile::class).configureEach {
options.compilerArgs.add("-Xlint:unchecked")
options.compilerArgs.add("-Xlint:deprecation")
options.encoding = "UTF-8"
}
tasks.register("copyLicenses", Copy::class) {
from(project.projectDir) {
include(
"LICENSE",
"dependencyLicenses/**"
)
}
from(".github/docs/NOTICES.md").into(project.projectDir)
sourceSets.main.get().output.resourcesDir?.let { into(it) }
}
tasks.withType(Jar::class) {
destinationDirectory.set(layout.buildDirectory.dir("badjars"))
manifest.attributes.run {
this["Manifest-Version"] = "2.0"
this["Main-Class"] = "SkyblockAddonsInstallerFrame"
this["Implementation-Title"] = project.name
this["Implementation-Version"] = project.version
this["Implementation-Vendor"] = "Fix3dll"
this["Specification-Title"] = project.name
this["Specification-Vendor"] = "Fix3dll"
this["Specification-Version"] = project.version
this["FMLCorePlugin"] = "${project.group}.${modId}.tweaker.${project.name}LoadingPlugin"
this["ForceLoadAsMod"] = "true"
this["FMLCorePluginContainsFMLMod"] = "true"
this["ModSide"] = "CLIENT"
this["FMLAT"] = "${modId}_at.cfg"
this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker"
this["MixinConfigs"] = "mixins.${modId}.json"
}
}
val remapJar by tasks.named<net.fabricmc.loom.task.RemapJarTask>("remapJar") {
input = tasks.shadowJar.get().archiveFile
archiveFileName = "${project.name}-${version}-for-MC-${minecraftVersion}.jar"
}
tasks.processResources {
dependsOn("copyLicenses")
inputs.property("version", version)
inputs.property("mcversion", minecraftVersion)
// replace stuff in mcmod.info, nothing else
filesMatching("mcmod.info") {
// replace version and mcversion
expand("version" to version, "mcversion" to minecraftVersion)
}
}
tasks.shadowJar {
destinationDirectory = layout.buildDirectory.dir("badjars")
configurations = listOf(bundle)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
exclude(
"dummyThing",
"module-info.class",
"META-INF/versions/",
"LICENSE.txt"
)
// Relocate Discord RPC into the main codebase
relocate("com.jagrosh.discordipc", "${project.group}.${modId}.discordipc")
relocate("net.hypixel.modapi.tweaker", "${project.group}.${modId}.modapi.tweaker")
}
tasks.withType(Test::class) {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
}
}
tasks.assemble.get().dependsOn(tasks.remapJar)