Skip to content

Commit 204c12b

Browse files
committed
update buildscript
1 parent aa547cb commit 204c12b

File tree

3 files changed

+52
-58
lines changed

3 files changed

+52
-58
lines changed

build.gradle.kts

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2020
import dev.architectury.plugin.ArchitectPluginExtension
2121
import groovy.json.JsonOutput
2222
import groovy.json.JsonSlurper
23+
import me.modmuss50.mpp.ModPublishExtension
2324
import net.fabricmc.loom.api.LoomGradleExtensionAPI
2425
import net.fabricmc.loom.task.RemapJarTask
2526
import org.objectweb.asm.ClassReader
@@ -32,6 +33,8 @@ import java.util.jar.JarEntry
3233
import java.util.jar.JarFile
3334
import java.util.jar.JarOutputStream
3435
import java.util.zip.Deflater
36+
import dev.ithundxr.silk.ChangelogText
37+
import me.modmuss50.mpp.ReleaseType
3538

3639
plugins {
3740
java
@@ -163,7 +166,7 @@ subprojects {
163166
platformSetupLoomIde()
164167
}
165168

166-
tasks.named<RemapJarTask>("remapJar") {
169+
val remapJar = tasks.named<RemapJarTask>("remapJar") {
167170
from("${rootProject.projectDir}/LICENSE")
168171
val shadowJar = project.tasks.named<ShadowJar>("shadowJar").get()
169172
inputFile.set(shadowJar.archiveFile)
@@ -248,6 +251,51 @@ subprojects {
248251
skip()
249252
}
250253
}
254+
255+
val isFabric = project.name == "fabric"
256+
val releaseType =
257+
if (version.toString().contains("alpha")) {
258+
ReleaseType.ALPHA;
259+
} else if (version.toString().contains("beta")) {
260+
ReleaseType.BETA;
261+
} else {
262+
ReleaseType.STABLE;
263+
}
264+
configure<ModPublishExtension> {
265+
file.set(remapJar.get().archiveFile)
266+
version.set(project.version.toString())
267+
changelog = ChangelogText.getChangelogText(rootProject).toString()
268+
type = releaseType
269+
displayName = "Steam 'n' Rails ${"mod_version"()} $capitalizedName ${"minecraft_version"()}"
270+
if (isFabric) {
271+
modLoaders.add("fabric")
272+
modLoaders.add("quilt")
273+
} else {
274+
modLoaders.add("forge")
275+
modLoaders.add("neoforge")
276+
}
277+
278+
val createVersionType = if (project.name == "fabric") "create-fabric" else "create"
279+
curseforge {
280+
projectId = "curseforge_id"()
281+
accessToken = providers.environmentVariable("CURSEFORGE_TOKEN")
282+
minecraftVersions.add("minecraft_version"())
283+
284+
requires {
285+
slug = createVersionType
286+
}
287+
}
288+
289+
modrinth {
290+
projectId = "modrinth_id"()
291+
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
292+
minecraftVersions.add("minecraft_version"())
293+
294+
requires {
295+
slug = createVersionType
296+
}
297+
}
298+
}
251299
}
252300

253301
fun transformJar(jar: File) {
@@ -383,7 +431,7 @@ fun calculateGitHash(): String {
383431
commandLine("git", "rev-parse", "HEAD")
384432
}
385433
return output.standardOutput.asText.get().trim()
386-
} catch(ignored: Throwable) {
434+
} catch(_: Throwable) {
387435
return "unknown"
388436
}
389437
}
@@ -394,7 +442,7 @@ fun calculateGitBranch(): String {
394442
commandLine("git", "rev-parse", "--abbrev-ref", "HEAD")
395443
}
396444
return output.standardOutput.asText.get().trim()
397-
} catch(ignored: Throwable) {
445+
} catch(_: Throwable) {
398446
return "unknown"
399447
}
400448
}
@@ -408,7 +456,7 @@ fun hasUnstaged(): Boolean {
408456
if (result.isNotEmpty())
409457
println("Found stageable results:\n${result}\n")
410458
return result.isNotEmpty()
411-
} catch(ignored: Throwable) {
459+
} catch(_: Throwable) {
412460
return false
413461
}
414462
}

fabric/build.gradle.kts

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -108,34 +108,6 @@ dependencies {
108108
}
109109
}
110110

111-
publishMods {
112-
file = tasks.remapJar.get().archiveFile
113-
version.set(project.version.toString())
114-
changelog = ChangelogText.getChangelogText(rootProject).toString()
115-
type = ReleaseType.valueOf(System.getenv().getOrDefault("RELEASE_TYPE", "STABLE"))
116-
displayName = "Steam 'n' Rails ${"mod_version"()} Fabric ${"minecraft_version"()}"
117-
modLoaders.add("fabric")
118-
modLoaders.add("quilt")
119-
120-
curseforge {
121-
projectId = "curseforge_id"()
122-
accessToken = System.getenv("CURSEFORGE_TOKEN")
123-
minecraftVersions.add("minecraft_version"())
124-
125-
requires("fabric-api")
126-
requires("create-fabric")
127-
}
128-
129-
modrinth {
130-
projectId = "modrinth_id"()
131-
accessToken = System.getenv("MODRINTH_TOKEN")
132-
minecraftVersions.add("minecraft_version"())
133-
134-
requires("fabric-api")
135-
requires("create-fabric")
136-
}
137-
}
138-
139111
operator fun String.invoke(): String {
140112
return rootProject.ext[this] as? String
141113
?: throw IllegalStateException("Property $this is not defined")

forge/build.gradle.kts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -109,32 +109,6 @@ dependencies {
109109
annotationProcessor(implementation(include("io.github.llamalad7:mixinextras-forge:${"mixin_extras_version"()}")!!)!!)
110110
}
111111

112-
publishMods {
113-
file = tasks.remapJar.get().archiveFile
114-
version.set(project.version.toString())
115-
changelog = ChangelogText.getChangelogText(rootProject).toString()
116-
type = ReleaseType.valueOf(System.getenv().getOrDefault("RELEASE_TYPE", "STABLE"))
117-
displayName = "Steam 'n' Rails ${"mod_version"()} Forge ${"minecraft_version"()}"
118-
modLoaders.add("forge")
119-
modLoaders.add("neoforge")
120-
121-
curseforge {
122-
projectId = "curseforge_id"()
123-
accessToken = System.getenv("CURSEFORGE_TOKEN")
124-
minecraftVersions.add("minecraft_version"())
125-
126-
requires("create")
127-
}
128-
129-
modrinth {
130-
projectId = "modrinth_id"()
131-
accessToken = System.getenv("MODRINTH_TOKEN")
132-
minecraftVersions.add("minecraft_version"())
133-
134-
requires("create")
135-
}
136-
}
137-
138112
operator fun String.invoke(): String {
139113
return rootProject.ext[this] as? String
140114
?: throw IllegalStateException("Property $this is not defined")

0 commit comments

Comments
 (0)