1
0
mirror of https://github.com/chylex/Better-Controls.git synced 2024-11-25 01:42:45 +01:00

Compare commits

..

2 Commits

Author SHA1 Message Date
761fdb76da
Switch from separate loader jars to one multiloader jar 2024-07-03 03:23:48 +02:00
d721d6254d
Make jar files reproducible 2024-07-03 03:23:25 +02:00
6 changed files with 37 additions and 17 deletions

View File

@ -1,3 +1,5 @@
import org.gradle.jvm.tasks.Jar
val modId: String by project
val minecraftVersion: String by project
val fabricVersion: String by project
@ -45,6 +47,11 @@ tasks.jar {
exclude("com/terraformersmc/modmenu/")
}
tasks.remapJar {
archiveVersion.set(tasks.jar.get().archiveVersion)
tasks.register<Jar>("uncompressedRemapJar") {
group = "fabric"
from(tasks.remapJar.map { it.outputs.files.map(::zipTree) })
archiveClassifier.set("uncompressed")
entryCompression = ZipEntryCompression.STORED // Reduces size of multiloader jar.
}

View File

@ -18,7 +18,7 @@
"sources": "${sourcesURL}"
},
"environment": "client",
"environment": "${sidesForFabric}",
"entrypoints": {
"client": [ "chylex.bettercontrols.BetterControlsMod" ],
"modmenu": [ "chylex.bettercontrols.compatibility.ModMenuSupport" ]
@ -26,7 +26,7 @@
"mixins": [{
"config": "${id}.mixins.json",
"environment": "client"
"environment": "${sidesForFabric}"
}],
"depends": {

View File

@ -21,11 +21,11 @@ modId = "minecraft"
type = "required"
versionRange = "[${minimumMinecraftVersion},)"
ordering = "NONE"
side = "CLIENT"
side = "${sidesForNeoForge}"
[[dependencies.${id}]]
modId = "neoforge"
type = "required"
versionRange = "[${minimumNeoForgeVersion},)"
ordering = "NONE"
side = "CLIENT"
side = "${sidesForNeoForge}"

View File

@ -10,6 +10,7 @@ val modVersion: String by project
val modLicense: String by project
val modSourcesURL: String by project
val modIssuesURL: String by project
val modSides: String by project
val minecraftVersion: String by project
val mixinVersion: String by project
@ -19,7 +20,6 @@ val minimumNeoForgeVersion: String by project
val minimumFabricVersion: String by project
val modNameStripped = modName.replace(" ", "")
val jarVersion = "$minecraftVersion+v$modVersion"
plugins {
idea
@ -96,6 +96,13 @@ allprojects {
}
tasks.withType<ProcessResources> {
val (sidesForNeoForge, sidesForFabric) = when (modSides) {
"both" -> Pair("BOTH", "*")
"client" -> Pair("CLIENT", "client")
"server" -> Pair("SERVER", "server")
else -> error("Invalid modSides value: $modSides")
}
inputs.property("id", modId)
inputs.property("name", modName)
inputs.property("description", modDescription)
@ -104,6 +111,8 @@ allprojects {
inputs.property("license", modLicense)
inputs.property("sourcesURL", modSourcesURL)
inputs.property("issuesURL", modIssuesURL)
inputs.property("sidesForNeoForge", sidesForNeoForge)
inputs.property("sidesForFabric", sidesForFabric)
inputs.property("minimumMinecraftVersion", minimumMinecraftVersion)
inputs.property("minimumNeoForgeVersion", minimumNeoForgeVersion)
inputs.property("minimumFabricVersion", minimumFabricVersion)
@ -112,6 +121,11 @@ allprojects {
into("assets/$modId")
}
}
tasks.withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
}
subprojects {
@ -136,10 +150,7 @@ subprojects {
}
tasks.jar {
archiveVersion.set(jarVersion)
entryCompression = ZipEntryCompression.STORED
from(rootProject.file("LICENSE"))
entryCompression = ZipEntryCompression.STORED // Reduces size of multiloader jar.
manifest {
packageInformation(modId, "$modNameStripped-${project.name}")
@ -168,20 +179,21 @@ val multiloaderJar = tasks.register<Jar>("multiloaderJar") {
group = "build"
archiveBaseName.set(modNameStripped)
archiveVersion.set(jarVersion)
archiveVersion.set("$minecraftVersion+v$modVersion")
destinationDirectory = layout.buildDirectory.dir("dist")
fun includeJar(project: Project, jarTask: (TaskContainer) -> TaskProvider<out Jar>) {
from(jarTask(project.tasks).map { it.outputs }) {
fun includeJar(project: Project, jarTaskName: String) {
from(project.tasks.named(jarTaskName).map { it.outputs }) {
into("jars")
rename { "$modNameStripped-${project.name}.jar" }
}
}
findProject(":NeoForge")?.let { includeJar(it, TaskContainer::jar) }
findProject(":Fabric")?.let { includeJar(it, TaskContainer::remapJar) }
findProject(":NeoForge")?.let { includeJar(it, "jar") }
findProject(":Fabric")?.let { includeJar(it, "uncompressedRemapJar") }
from(rootProject.file("LICENSE"))
from(multiloaderSources.map { it.output })
manifest {

View File

@ -7,6 +7,7 @@ modVersion=1.3.1
modLicense=MPL-2.0
modSourcesURL=https://github.com/chylex/Better-Controls
modIssuesURL=https://github.com/chylex/Better-Controls/issues
modSides=client
# Dependencies
minecraftVersion=1.21

View File

@ -18,7 +18,7 @@
"sources": "${sourcesURL}"
},
"environment": "client",
"environment": "${sidesForFabric}",
"jars": [{
"file": "jars/${jarPrefix}-Fabric.jar"