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

Compare commits

..

1 Commits

Author SHA1 Message Date
476689deb9
Switch from separate loader jars to one multiloader jar 2024-07-02 19:20:05 +02:00
6 changed files with 17 additions and 37 deletions

View File

@ -1,5 +1,3 @@
import org.gradle.jvm.tasks.Jar
val modId: String by project val modId: String by project
val minecraftVersion: String by project val minecraftVersion: String by project
val fabricVersion: String by project val fabricVersion: String by project
@ -47,11 +45,6 @@ tasks.jar {
exclude("com/terraformersmc/modmenu/") exclude("com/terraformersmc/modmenu/")
} }
tasks.register<Jar>("uncompressedRemapJar") { tasks.remapJar {
group = "fabric" archiveVersion.set(tasks.jar.get().archiveVersion)
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}" "sources": "${sourcesURL}"
}, },
"environment": "${sidesForFabric}", "environment": "client",
"entrypoints": { "entrypoints": {
"client": [ "chylex.bettercontrols.BetterControlsMod" ], "client": [ "chylex.bettercontrols.BetterControlsMod" ],
"modmenu": [ "chylex.bettercontrols.compatibility.ModMenuSupport" ] "modmenu": [ "chylex.bettercontrols.compatibility.ModMenuSupport" ]
@ -26,7 +26,7 @@
"mixins": [{ "mixins": [{
"config": "${id}.mixins.json", "config": "${id}.mixins.json",
"environment": "${sidesForFabric}" "environment": "client"
}], }],
"depends": { "depends": {

View File

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

View File

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

View File

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

View File

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