|
| 1 | +plugins { |
| 2 | + id("dev.architectury.loom") |
| 3 | + id("architectury-plugin") |
| 4 | + id("me.modmuss50.mod-publish-plugin") |
| 5 | + id("com.github.johnrengelman.shadow") |
| 6 | + `maven-publish` |
| 7 | +} |
| 8 | + |
| 9 | +val minecraft = stonecutter.current.version |
| 10 | +val loader = loom.platform.get().name.lowercase() |
| 11 | + |
| 12 | +version = "${mod.version}+$minecraft" |
| 13 | +group = mod.group |
| 14 | +base { |
| 15 | + archivesName.set("${mod.id}-$loader") |
| 16 | +} |
| 17 | + |
| 18 | +repositories { |
| 19 | + maven("https://maven.neoforged.net/releases/") |
| 20 | + maven("https://api.modrinth.com/maven") |
| 21 | + |
| 22 | + // modmenu |
| 23 | + maven("https://maven.terraformersmc.com/") |
| 24 | + maven("https://maven.nucleoid.xyz/") |
| 25 | + |
| 26 | + // MidnightLib |
| 27 | + maven("https://maven.midnightdust.eu/releases/") |
| 28 | + |
| 29 | + // LambdAurora |
| 30 | + maven("https://aperlambda.github.io/maven") |
| 31 | + maven("https://maven.gegy.dev") |
| 32 | + |
| 33 | + // Compat |
| 34 | + maven("https://server.bbkr.space/artifactory/libs-release") |
| 35 | + maven("https://maven.terraformersmc.com/releases/") |
| 36 | + maven("https://maven.kosmx.dev") |
| 37 | + maven("https://maven.isxander.dev/releases") |
| 38 | + maven("https://maven.shedaniel.me/") |
| 39 | + maven("https://jitpack.io") |
| 40 | + maven("https://api.modrinth.com/maven") |
| 41 | + maven("https://maven.quiltmc.org/repository/release") |
| 42 | +} |
| 43 | +dependencies { |
| 44 | + minecraft("com.mojang:minecraft:$minecraft") |
| 45 | + implementation ("org.aperlambda:lambdajcommon:1.8.1") { |
| 46 | + exclude(group = "com.google.code.gson") |
| 47 | + exclude(group = "com.google.guava") |
| 48 | + } |
| 49 | + |
| 50 | + // MidnightLib |
| 51 | + val midnightlib = "eu.midnightdust:midnightlib:${mod.dep("midnightlib_version")}+${minecraft}-${loader}" |
| 52 | + modImplementation(midnightlib) |
| 53 | + include(midnightlib) |
| 54 | + |
| 55 | + // Compatibility mods |
| 56 | + modCompileOnlyApi ("com.terraformersmc:modmenu:${mod.dep("modmenu_version")}") { |
| 57 | + exclude(group = "net.fabricmc.fabric-api") |
| 58 | + } |
| 59 | + modCompileOnlyApi ("io.github.cottonmc:LibGui:${mod.dep("libgui_version")}") |
| 60 | + modCompileOnlyApi ("org.quiltmc:quilt-json5:1.0.0") |
| 61 | + modImplementation ("maven.modrinth:sodium:${mod.dep("sodium_version")}-fabric") |
| 62 | + modCompileOnlyApi ("maven.modrinth:emi:${mod.dep("emi_version")}+${loader}") |
| 63 | + modCompileOnlyApi ("maven.modrinth:emotecraft:${mod.dep("emotecraft_version")}+${minecraft}-${loader.replace("neo","")}") |
| 64 | + modCompileOnlyApi ("io.github.kosmx:bendy-lib:${mod.dep("bendylib_version")}") |
| 65 | + modCompileOnlyApi ("dev.isxander:yet-another-config-lib:${mod.dep("yacl_version")}+${minecraft}-${loader}") |
| 66 | + modCompileOnlyApi ("maven.modrinth:inventory-tabs-updated:${mod.dep("inventorytabs_version")}") |
| 67 | + modCompileOnlyApi ("maven.modrinth:bedrockify:${mod.dep("bedrockify_version")}") |
| 68 | + // Required for Inventory Tabs |
| 69 | + modCompileOnlyApi("me.shedaniel.cloth:cloth-config-fabric:${mod.dep("clothconfig_version")}") { |
| 70 | + exclude(group = "net.fabricmc.fabric-api") |
| 71 | + } |
| 72 | + |
| 73 | + val spruceui = "dev.lambdaurora:spruceui:${mod.dep("spruceui_version")}" |
| 74 | + |
| 75 | + if (loader == "fabric") { |
| 76 | + modImplementation("net.fabricmc:fabric-loader:${mod.dep("fabric_loader")}") |
| 77 | + modImplementation("net.fabricmc.fabric-api:fabric-api:${mod.dep("fabric_version")}") |
| 78 | + |
| 79 | + modImplementation (spruceui) |
| 80 | + include (spruceui) |
| 81 | + include("dev.yumi.mc.core:yumi-mc-foundation:1.0.0-beta.1+1.21.11") |
| 82 | + include("org.aperlambda:lambdajcommon:1.8.1") |
| 83 | + //modCompileOnly "maven.modrinth:emi:${mod.dep("emi_version")}" |
| 84 | + } |
| 85 | + if (loader == "neoforge") { |
| 86 | + "neoForge"("net.neoforged:neoforge:${mod.dep("neoforge_loader")}") |
| 87 | + |
| 88 | + val mappingsAttribute = Attribute.of("net.minecraft.mappings", String::class.java) |
| 89 | + |
| 90 | + implementation(spruceui) { |
| 91 | + attributes { |
| 92 | + attribute(mappingsAttribute, "mojmap") |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + include("dev.yumi.mc.core:yumi-mc-foundation:1.0.0-beta.1+1.21.11") { |
| 97 | + attributes { |
| 98 | + attribute(mappingsAttribute, "mojmap") |
| 99 | + } |
| 100 | + } |
| 101 | + include(spruceui) |
| 102 | + } |
| 103 | + mappings (loom.officialMojangMappings()) |
| 104 | +} |
| 105 | + |
| 106 | +loom { |
| 107 | + accessWidenerPath = rootProject.file("src/main/resources/midnightcontrols.accesswidener") |
| 108 | + |
| 109 | + decompilers { |
| 110 | + get("vineflower").apply { // Adds names to lambdas - useful for mixins |
| 111 | + options.put("mark-corresponding-synthetics", "1") |
| 112 | + } |
| 113 | + } |
| 114 | +} |
| 115 | + |
| 116 | +publishMods { |
| 117 | + val modrinthToken = System.getenv("MODRINTH_TOKEN") |
| 118 | + val curseforgeToken = System.getenv("CURSEFORGE_TOKEN") |
| 119 | + val githubToken = System.getenv("GITHUB_TOKEN").orEmpty() |
| 120 | + |
| 121 | + file = project.tasks.remapJar.get().archiveFile |
| 122 | + dryRun = modrinthToken == null || curseforgeToken == null |
| 123 | + |
| 124 | + displayName = "${mod.name} ${mod.version} - ${loader.replaceFirstChar { it.uppercase() }} ${property("mod.mc_title")}" |
| 125 | + version = "${mod.version}+${property("mod.mc_title")}-${loader}" |
| 126 | + changelog = rootProject.file("CHANGELOG.md").readText() |
| 127 | + type = STABLE |
| 128 | + |
| 129 | + modLoaders.add(loader) |
| 130 | + if (loader == "fabric") { |
| 131 | + modLoaders.add("quilt") |
| 132 | + } |
| 133 | + |
| 134 | + val targets = property("mod.mc_targets").toString().split(' ') |
| 135 | + modrinth { |
| 136 | + projectId = property("publish.modrinth").toString() |
| 137 | + accessToken = modrinthToken |
| 138 | + targets.forEach(minecraftVersions::add) |
| 139 | + requires("midnightlib") |
| 140 | + if (loader == "fabric") { |
| 141 | + requires("fabric-api") |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + curseforge { |
| 146 | + projectId = property("publish.curseforge").toString() |
| 147 | + accessToken = curseforgeToken.toString() |
| 148 | + targets.forEach(minecraftVersions::add) |
| 149 | + requires("midnightlib") |
| 150 | + if (loader == "fabric") { |
| 151 | + requires("fabric-api") |
| 152 | + } |
| 153 | + } |
| 154 | + |
| 155 | +// github { |
| 156 | +// accessToken = githubToken |
| 157 | +// repository = "TeamMidnightDust/CullLeaves" |
| 158 | +// commitish = "multiversion" // This is the branch the release tag will be created from |
| 159 | +// |
| 160 | +// tagName = "v" + properties["mod.version"] |
| 161 | +// |
| 162 | +// // Allow the release to be initially created without any files. |
| 163 | +// allowEmptyFiles = true |
| 164 | +// } |
| 165 | +} |
| 166 | +publishing { |
| 167 | + repositories { |
| 168 | + maven { |
| 169 | + name = "MidnightDust" |
| 170 | + url = uri("https://maven.midnightdust.eu/releases") |
| 171 | + credentials(PasswordCredentials::class) |
| 172 | + } |
| 173 | + } |
| 174 | + publications { |
| 175 | + create<MavenPublication>("mavenJava") { |
| 176 | + pom { |
| 177 | + groupId = "eu.midnightdust" |
| 178 | + artifactId = project.mod.id |
| 179 | + version = "${project.version}-${loader}" |
| 180 | + |
| 181 | + from(components["java"]) |
| 182 | + } |
| 183 | + } |
| 184 | + } |
| 185 | +} |
| 186 | + |
| 187 | + |
| 188 | +java { |
| 189 | + withSourcesJar() |
| 190 | + val java = if (stonecutter.eval(minecraft, ">=1.20.5")) JavaVersion.VERSION_21 else JavaVersion.VERSION_17 |
| 191 | + targetCompatibility = java |
| 192 | + sourceCompatibility = java |
| 193 | +} |
| 194 | + |
| 195 | +val shadowBundle: Configuration by configurations.creating { |
| 196 | + isCanBeConsumed = false |
| 197 | + isCanBeResolved = true |
| 198 | +} |
| 199 | + |
| 200 | +tasks.shadowJar { |
| 201 | + configurations = listOf(shadowBundle) |
| 202 | + archiveClassifier = "dev-shadow" |
| 203 | +} |
| 204 | + |
| 205 | +tasks.remapJar { |
| 206 | + injectAccessWidener = true |
| 207 | + input = tasks.shadowJar.get().archiveFile |
| 208 | + archiveClassifier = null |
| 209 | + dependsOn(tasks.shadowJar) |
| 210 | +} |
| 211 | + |
| 212 | +tasks.jar { |
| 213 | + archiveClassifier = "dev" |
| 214 | +} |
| 215 | + |
| 216 | +val buildAndCollect = tasks.register<Copy>("buildAndCollect") { |
| 217 | + group = "build" |
| 218 | + from(tasks.remapJar.get().archiveFile, tasks.remapSourcesJar.get().archiveFile) |
| 219 | + into(rootProject.layout.buildDirectory.file("libs/${mod.version}/$loader")) |
| 220 | + dependsOn("build") |
| 221 | +} |
| 222 | + |
| 223 | +if (stonecutter.current.isActive) { |
| 224 | + rootProject.tasks.register("buildActive") { |
| 225 | + group = "project" |
| 226 | + dependsOn(buildAndCollect) |
| 227 | + } |
| 228 | + |
| 229 | + rootProject.tasks.register("runActive") { |
| 230 | + group = "project" |
| 231 | + dependsOn(tasks.named("runClient")) |
| 232 | + } |
| 233 | +} |
| 234 | + |
| 235 | +tasks.processResources { |
| 236 | + properties( |
| 237 | + listOf("fabric.mod.json"), |
| 238 | + "id" to mod.id, |
| 239 | + "name" to mod.name, |
| 240 | + "version" to mod.version, |
| 241 | + "minecraft" to mod.prop("mc_dep_fabric") |
| 242 | + ) |
| 243 | + properties( |
| 244 | + listOf("META-INF/mods.toml", "pack.mcmeta"), |
| 245 | + "id" to mod.id, |
| 246 | + "name" to mod.name, |
| 247 | + "version" to mod.version, |
| 248 | + "minecraft" to mod.prop("mc_dep_forgelike") |
| 249 | + ) |
| 250 | + properties( |
| 251 | + listOf("META-INF/neoforge.mods.toml", "pack.mcmeta"), |
| 252 | + "id" to mod.id, |
| 253 | + "name" to mod.name, |
| 254 | + "version" to mod.version, |
| 255 | + "minecraft" to mod.prop("mc_dep_forgelike") |
| 256 | + ) |
| 257 | +} |
| 258 | + |
| 259 | +tasks.build { |
| 260 | + group = "versioned" |
| 261 | + description = "Must run through 'chiseledBuild'" |
| 262 | +} |
| 263 | + |
| 264 | + |
| 265 | +stonecutter { |
| 266 | + constants { |
| 267 | + arrayOf("fabric", "neoforge", "forge").forEach { it -> put(it, loader == it) } |
| 268 | + } |
| 269 | +} |
0 commit comments