1 parent
5350242f97
commit
2e47df4375
2 files changed
+101
-74
No files matched your search
+82
-50
@@ -1,10 +1,11 @@
|
||||
import com.smushytaco.lwjgl_gradle.Preset
|
||||
plugins {
|
||||
alias(libs.plugins.loom)
|
||||
alias(libs.plugins.lwjgl)
|
||||
java
|
||||
java
|
||||
}
|
||||
val modVersion: Provider<String> = providers.gradleProperty("mod_version")
|
||||
|
||||
val lwjglNatives = resolveLwjglNatives()
|
||||
|
||||
val modVersion = "${providers.gradleProperty("mod_version").get()}+${libs.versions.bta.get()}"
|
||||
val modGroup: Provider<String> = providers.gradleProperty("mod_group")
|
||||
val modName: Provider<String> = providers.gradleProperty("mod_name")
|
||||
|
||||
@@ -12,56 +13,48 @@ val javaVersion: Provider<Int> = libs.versions.java.map { it.toInt() }
|
||||
|
||||
base.archivesName = modName
|
||||
group = modGroup.get()
|
||||
version = modVersion.get()
|
||||
version = modVersion
|
||||
loom {
|
||||
customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${libs.versions.btaChannel.get()}/v${libs.versions.bta.get()}/manifest.json")
|
||||
val btaChannel = libs.versions.btaChannel.get()
|
||||
val btaVersion = (if (btaChannel == "nightly") "" else "v") + libs.versions.bta.get()
|
||||
customMinecraftMetadata.set("https://downloads.betterthanadventure.net/bta-client/${btaChannel}/$btaVersion/manifest.json")
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://maven.fabricmc.net/") { name = "Fabric" }
|
||||
maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" }
|
||||
maven("https://maven.thesignalumproject.net/releases") { name = "SignalumMavenReleases" }
|
||||
ivy("https://github.com/Better-than-Adventure") {
|
||||
patternLayout { artifact("[organisation]/releases/download/[revision]/[module]-bta-[revision].jar") }
|
||||
metadataSources { artifact() }
|
||||
}
|
||||
ivy("https://downloads.betterthanadventure.net/bta-client/${libs.versions.btaChannel.get()}/") {
|
||||
patternLayout { artifact("/v[revision]/client.jar") }
|
||||
metadataSources { artifact() }
|
||||
}
|
||||
ivy("https://downloads.betterthanadventure.net/bta-server/${libs.versions.btaChannel.get()}/") {
|
||||
patternLayout { artifact("/v[revision]/server.jar") }
|
||||
metadataSources { artifact() }
|
||||
}
|
||||
ivy("https://piston-data.mojang.com") {
|
||||
patternLayout { artifact("v1/[organisation]/[revision]/[module].jar") }
|
||||
metadataSources { artifact() }
|
||||
}
|
||||
}
|
||||
lwjgl {
|
||||
version = libs.versions.lwjgl
|
||||
implementation(Preset.MINIMAL_OPENGL)
|
||||
mavenCentral()
|
||||
maven("https://maven.fabricmc.net/") { name = "Fabric" }
|
||||
maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" }
|
||||
maven("https://maven.thesignalumproject.net/releases") { name = "SignalumMavenReleases" }
|
||||
maven("https://maven.thesignalumproject.net/nightly") { name = "SignalumMavenNightly" }
|
||||
ivy("https://piston-data.mojang.com") {
|
||||
patternLayout { artifact("v1/[organisation]/[revision]/[module].jar") }
|
||||
metadataSources { artifact() }
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
minecraft("::${libs.versions.bta.get()}")
|
||||
minecraft("::${libs.versions.bta.get()}")
|
||||
|
||||
runtimeOnly(libs.clientJar)
|
||||
// Required at compilation & runtime
|
||||
// included in builds as a runtime dependency
|
||||
implementation(libs.loader)
|
||||
// If you do not need Halplibe you can comment out or delete this line.
|
||||
implementation(libs.halplibe)
|
||||
implementation(libs.modMenu)
|
||||
implementation(libs.legacyLwjgl)
|
||||
implementation(libs.halplibe) // If you do not need halplibe you can delete this line
|
||||
|
||||
implementation(libs.slf4jApi)
|
||||
implementation(libs.guava)
|
||||
implementation(libs.log4j.slf4j2.impl)
|
||||
implementation(libs.log4j.core)
|
||||
implementation(libs.log4j.api)
|
||||
implementation(libs.log4j.api12)
|
||||
implementation(libs.gson)
|
||||
// Only required at compilation
|
||||
// provides documentation, can be removed if that isn't needed
|
||||
compileOnly(libs.bundles.btaLwjgl)
|
||||
compileOnly(libs.joml)
|
||||
compileOnly(libs.joml.primitives)
|
||||
compileOnly(libs.slf4jApi)
|
||||
|
||||
implementation(libs.commonsLang3)
|
||||
include(libs.commonsLang3)
|
||||
// Only required for development/launch at runtime, won't be part of any builds
|
||||
localRuntime(libs.modMenu) // Optional, can be removed
|
||||
runtimeClasspath(libs.clientJar)
|
||||
val lwjglVer = libs.versions.lwjgl.get()
|
||||
localRuntime(platform("org.lwjgl:lwjgl-bom:${lwjglVer}"))
|
||||
localRuntime("org.lwjgl:lwjgl::$lwjglNatives")
|
||||
localRuntime("org.lwjgl:lwjgl-glfw::$lwjglNatives")
|
||||
localRuntime("org.lwjgl:lwjgl-openal::$lwjglNatives")
|
||||
localRuntime("org.lwjgl:lwjgl-opengl::$lwjglNatives")
|
||||
localRuntime("org.lwjgl:lwjgl-stb::$lwjglNatives")
|
||||
}
|
||||
java {
|
||||
toolchain {
|
||||
@@ -113,16 +106,55 @@ tasks {
|
||||
}
|
||||
processResources {
|
||||
val resourceMap = mapOf(
|
||||
"version" to modVersion.get(),
|
||||
"version" to modVersion,
|
||||
"fabricloader" to libs.versions.loader.get(),
|
||||
"halplibe" to libs.versions.halplibe.get(),
|
||||
"java" to libs.versions.java.get(),
|
||||
"modmenu" to libs.versions.modMenu.get()
|
||||
)
|
||||
// This is needed for gradle to recognize changes
|
||||
// made to expanded files
|
||||
inputs.properties(resourceMap)
|
||||
filesMatching("fabric.mod.json") { expand(resourceMap) }
|
||||
filesMatching("**/*.mixins.json") { expand(resourceMap.filterKeys { it == "java" }) }
|
||||
|
||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||
with(copySpec {
|
||||
from("src/main/resources/") {
|
||||
include("fabric.mod.json")
|
||||
include("*.mixins.json")
|
||||
expand(resourceMap)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
// Removes all outdated manifest.json dependencies
|
||||
configurations.configureEach {
|
||||
exclude(group = "org.lwjgl.lwjgl")
|
||||
exclude(group = "net.java.jutils")
|
||||
exclude(group = "net.java.jinput")
|
||||
exclude(group = "net.sf.jopt-simple")
|
||||
exclude(group = "net.minecraft", module = "launchwrapper")
|
||||
}
|
||||
|
||||
fun resolveLwjglNatives(): String { // Sourced from https://www.lwjgl.org/
|
||||
return Pair(
|
||||
System.getProperty("os.name")!!,
|
||||
System.getProperty("os.arch")!!
|
||||
).let { (name, arch) ->
|
||||
when {
|
||||
arrayOf("Linux", "SunOS", "Unit").any { name.startsWith(it) } ->
|
||||
if (arrayOf("arm", "aarch64").any { arch.startsWith(it) })
|
||||
"natives-linux${if (arch.contains("64") || arch.startsWith("armv8")) "-arm64" else "-arm32"}"
|
||||
else
|
||||
"natives-linux"
|
||||
arrayOf("Mac OS X", "Darwin").any { name.startsWith(it) } ->
|
||||
"natives-macos${if (arch.startsWith("aarch64")) "-arm64" else ""}"
|
||||
arrayOf("Windows").any { name.startsWith(it) } ->
|
||||
if (arch.contains("64"))
|
||||
"natives-windows${if (arch.startsWith("aarch64")) "-arm64" else ""}"
|
||||
else
|
||||
"natives-windows-x86"
|
||||
else ->
|
||||
throw Error("Unrecognized or unsupported platform. Please set \"lwjglNatives\" manually")
|
||||
}
|
||||
}
|
||||
}
|
||||
// Removes LWJGL2 dependencies
|
||||
configurations.configureEach { exclude(group = "org.lwjgl.lwjgl") }
|
||||
Reference in new issue
Block a user