-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
212 lines (177 loc) · 7.01 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
212 lines (177 loc) · 7.01 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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("dev.kikugie.loom-back-compat")
id("org.jetbrains.kotlin.jvm") version "2.4.0"
id("org.jetbrains.kotlin.plugin.compose") version "2.4.0"
id("dev.deftu.gradle.bloom") version "0.2.0"
id("me.modmuss50.mod-publish-plugin") version "1.1.0"
}
val modid = property("mod.id") as String
val modname = property("mod.name") as String
val modversion = property("mod.version") as String
val moddescription = property("mod.description") as String
val mcversion = stonecutter.current.version
val oneconfigversion = property("oneconfig_version") as String
val loaderversion = property("loader_version") as String
val isModern = stonecutter.eval(mcversion, ">=26.1")
val hasOfficialMappings = !isModern
val javaVersion = if (isModern) 25 else 21
val modmenuVersion = when {
stonecutter.eval(mcversion, ">=26.2") -> "20.0.0-beta.4"
stonecutter.eval(mcversion, ">=26.1") -> "18.0.0-beta.1"
stonecutter.eval(mcversion, ">=1.21.11") -> "17.0.0"
stonecutter.eval(mcversion, ">=1.21.9") -> "16.0.1"
stonecutter.eval(mcversion, ">=1.21.6") -> "15.0.2"
stonecutter.eval(mcversion, ">=1.21.5") -> "14.0.2"
stonecutter.eval(mcversion, ">=1.21.4") -> "13.0.4"
else -> "11.0.4"
}
val accessWidener = when {
stonecutter.eval(mcversion, ">=26.2") -> "chatting-26.2.accesswidener"
isModern -> "chatting-26.accesswidener"
stonecutter.eval(mcversion, ">=1.21.11") -> "chatting-1.21.11.accesswidener"
stonecutter.eval(mcversion, ">=1.21.6") -> "chatting-1.21.6.accesswidener"
stonecutter.eval(mcversion, ">=1.21.5") -> "chatting-1.21.5.accesswidener"
stonecutter.eval(mcversion, ">=1.21.4") -> "chatting-1.21.4.accesswidener"
else -> "chatting.accesswidener"
}
val allAccessWideners = listOf(
"chatting.accesswidener", "chatting-1.21.4.accesswidener", "chatting-1.21.5.accesswidener",
"chatting-1.21.6.accesswidener", "chatting-1.21.11.accesswidener", "chatting-26.accesswidener",
"chatting-26.2.accesswidener"
)
base {
archivesName.set("$modid-$modversion+$mcversion")
}
repositories {
mavenCentral()
gradlePluginPortal()
google()
maven("https://repo.polyfrost.org/releases")
maven("https://repo.polyfrost.org/snapshots")
maven("https://central.sonatype.com/repository/maven-snapshots/") {
content { includeGroup("net.kyori") }
}
maven("https://maven.deftu.dev/releases") {
content {
includeGroup("dev.deftu")
}
}
maven("https://maven.fabricmc.net/releases") {
content {
includeGroup("net.fabricmc")
}
}
//maven("https://maven.terraformersmc.com/releases") {
maven("https://maven.gnomecraft.net/releases/") {
content {
includeGroup("com.terraformersmc")
}
}
}
loom {
runConfigs.all {
ideConfigGenerated(stonecutter.current.isActive)
runDir = "../../run" // Shared run directory across all Minecraft versions.
}
runConfigs.remove(runConfigs["server"]) // Removes server run configs.
accessWidenerPath.set(rootProject.file("src/main/resources/$accessWidener"))
}
dependencies {
minecraft("com.mojang:minecraft:$mcversion")
if (hasOfficialMappings) {
@Suppress("UnstableApiUsage")
mappings(loom.layered {
officialMojangMappings()
})
}
modImplementation("net.fabricmc:fabric-loader:$loaderversion")
modImplementation("org.polyfrost.oneconfig:$mcversion-fabric:$oneconfigversion")
modImplementation("org.polyfrost.oneconfig:commands:$oneconfigversion")
modImplementation("org.polyfrost.oneconfig:config:$oneconfigversion")
modImplementation("org.polyfrost.oneconfig:config-impl:$oneconfigversion")
modImplementation("org.polyfrost.oneconfig:events:$oneconfigversion")
modImplementation("org.polyfrost.oneconfig:internal:$oneconfigversion")
modImplementation("org.polyfrost.oneconfig:ui:$oneconfigversion")
modImplementation("org.polyfrost.oneconfig:utils:$oneconfigversion")
modImplementation("org.polyfrost.oneconfig:hud:$oneconfigversion")
modImplementation("org.polyfrost.oneconfig:notifications:$oneconfigversion")
modCompileOnly("com.terraformersmc:modmenu:$modmenuVersion") { isTransitive = false }
testImplementation("org.junit.jupiter:junit-jupiter:6.1.2")
testImplementation("net.fabricmc:fabric-loader-junit:$loaderversion")
}
bloom {
replacement("@MOD_ID@", modid)
replacement("@MOD_NAME@", modname)
replacement("@MOD_VERSION@", modversion)
}
tasks.processResources {
val props = mapOf(
"mod_id" to modid,
"mod_name" to modname,
"mod_version" to modversion,
"mod_description" to moddescription,
"mc_version" to mcversion,
"loader_version" to loaderversion,
"aw" to accessWidener
)
inputs.properties(props)
filesMatching("fabric.mod.json") {
expand(props)
}
// Bundle only the selected widener
allAccessWideners.filter { it != accessWidener }.forEach { exclude(it) }
}
tasks.test {
useJUnitPlatform()
testLogging {
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
}
}
tasks.withType<JavaCompile>().configureEach {
options.release.set(javaVersion)
}
tasks.withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(javaVersion.toString()))
}
java {
withSourcesJar()
toolchain {
languageVersion.set(JavaLanguageVersion.of(javaVersion))
}
}
tasks.jar {
inputs.property("archivesName", base.archivesName)
from("LICENSE") {
rename { "${it}_${inputs.properties["archivesName"]}" }
}
}
val modrinthMinecraftVersionOverride = mapOf(
"26.1" to listOf("26.1", "26.1.1", "26.1.2")
)
val modrinthId = listOf("oneconfig.publish.modrinth", "publish.modrinth").firstNotNullOfOrNull { findProperty(it) }?.toString()?.takeIf { it.isNotBlank() }
val modrinthToken = listOf("oneconfig.publish.modrinth.token", "publish.modrinth.token", "modrinth.token").firstNotNullOfOrNull { findProperty(it) }?.toString()?.takeIf { it.isNotBlank() }
val minecraftVersion = modrinthMinecraftVersionOverride[mcversion] ?: listOf(mcversion)
val publishJarTaskName = if ("remapJar" in tasks.names) "remapJar" else "jar"
val changelogs = rootProject.file("CHANGELOG.md").takeIf { it.exists() }?.readText() ?: "No changelog provided."
publishMods {
file = tasks.named<AbstractArchiveTask>(publishJarTaskName).flatMap { it.archiveFile }
displayName = modversion
version = "v$modversion"
changelog = changelogs
type = STABLE
modLoaders.add("fabric")
dryRun = modrinthId == null || modrinthToken == null
if (modrinthId != null) {
modrinth {
projectId = modrinthId
accessToken = modrinthToken.orEmpty()
minecraftVersions.addAll(minecraftVersion)
requires("oneconfig")
requires("fabric-language-kotlin")
}
}
}