Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 199 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
plugins {
alias(libs.plugins.loom)
java
}

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")

val javaVersion: Provider<Int> = libs.versions.java.map { it.toInt() }

base.archivesName = modName
group = modGroup.get()
version = modVersion
loom {
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()
ivy("https://piston-data.mojang.com") {
patternLayout { artifact("v1/[organisation]/[revision]/[module].jar") }
metadataSources { artifact() }
}
maven("https://maven.fabricmc.net/") { name = "Fabric" }
maven("https://maven.danygames2014.net/signalum") { name = "SignalumMavenMirror1" }
maven("https://maven.thesignalumproject.net/infrastructure") { name = "SignalumMavenInfrastructure" }
maven("https://maven.thesignalumproject.net/releases") { name = "SignalumMavenReleases" }
maven("https://maven.thesignalumproject.net/nightly") { name = "SignalumMavenNightly" }
maven("https://api.modrinth.com/maven") { name = "Modrinth"
content {
includeGroup("maven.modrinth")
}
}
}
dependencies {
minecraft("::${libs.versions.bta.get()}")

// Required at compilation & runtime
// included in builds as a runtime dependency
implementation(libs.loader)
implementation(libs.halplibe) // If you do not need halplibe you can delete this line

//-Dmixin.debug.export=true mixin flag

compileOnly(libs.btabackpacks)
compileOnly(libs.paxels)
compileOnly(libs.commandly)

// for later
// compileOnly(libs.aether)


// 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)

// 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 {
languageVersion = javaVersion.map { JavaLanguageVersion.of(it) }
vendor = JvmVendorSpec.ADOPTIUM
}
sourceCompatibility = JavaVersion.toVersion(javaVersion.get())
targetCompatibility = JavaVersion.toVersion(javaVersion.get())
withSourcesJar()
}
val licenseFile = run {
val rootLicense = layout.projectDirectory.file("LICENSE")
val parentLicense = layout.projectDirectory.file("../LICENSE")
when {
rootLicense.asFile.exists() -> {
logger.lifecycle("Using LICENSE from project root: {}", rootLicense.asFile)
rootLicense
}
parentLicense.asFile.exists() -> {
logger.lifecycle("Using LICENSE from parent directory: {}", parentLicense.asFile)
parentLicense
}
else -> {
logger.warn("No LICENSE file found in project or parent directory.")
null
}
}
}
tasks {
withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
sourceCompatibility = javaVersion.get().toString()
targetCompatibility = javaVersion.get().toString()
if (javaVersion.get() > 8) options.release = javaVersion
}
named<UpdateDaemonJvm>("updateDaemonJvm") {
languageVersion = libs.versions.gradleJava.map { JavaLanguageVersion.of(it.toInt()) }
vendor = JvmVendorSpec.ADOPTIUM
}
withType<JavaExec>().configureEach { defaultCharacterEncoding = "UTF-8" }
withType<Javadoc>().configureEach { options.encoding = "UTF-8" }
withType<Test>().configureEach { defaultCharacterEncoding = "UTF-8" }
withType<Jar>().configureEach {
licenseFile?.let {
from(it) {
rename { original -> "${original}_${archiveBaseName.get()}" }
}
}
}
processResources {
val resourceMap = mapOf(
"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)

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")
}

// not sure about this, so this is useless exclusive
//publishing {
// repositories {
// maven {
// name = "signalumMaven"
// url = "https://maven.thesignalumproject.net/releases"
// credentials(PasswordCredentials)
// authentication {
// basic(BasicAuthentication)
// }
// }
// }
//
// publications {
// maven(MavenPublication) {
// groupId = project.mod_group
// artifactId = project.mod_name
// version = project.mod_version
// from components.java
// }
// }
//}

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")
}
}
}
34 changes: 16 additions & 18 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
org.gradle.jvmargs=-Xmx2G
org.gradle.parallel = true
org.gradle.daemon = true
fabric.loom.multiProjectOptimisation=true

# BTA
bta_version=7.3_03
bta_channel=release

# Loader
loader_version=0.15.6-bta.7

# Other Mods
mod_menu_version=3.0.0
halplibe_version=5.2.4

# Mod
mod_version=1.1.0-7.3_03
##########################################################################
# Standard Properties
org.gradle.jvmargs = -Xmx2G
org.gradle.warning.mode = all
# This currently has to be set to false because the "Minecraft Client" and "Minecraft Server" configurations generated
# by IntelliJ aren't currently compatible with the configuration cache. If you use the runClient and runServer Gradle
# tasks instead, then this can (and should) be set to true.
org.gradle.configuration-cache = false
##########################################################################
# Mod Properties
mod_version=1.1.2
mod_group=useless
mod_name=moonsteel
##########################################################################
# Plugin Dependency
# Check this on https://plugins.gradle.org/plugin/org.gradle.toolchains.foojay-resolver-convention/
foojay_resolver_version = 1.0.0
##########################################################################
13 changes: 13 additions & 0 deletions gradle/gradle-daemon-jvm.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#This file is generated by updateDaemonJvm
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/46949723aaa20c7b64d7ecfed7207034/redirect
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/d6690dfd71c4c91e08577437b5b2beb0/redirect
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/df211d3c3eefdc408b462041881bc575/redirect
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/b41931cf1e70bc8e08d7dd19c343ef00/redirect
toolchainUrl.WINDOWS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/3cd7045fca9a72cd9bc7d14a385e594c/redirect
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/552c7bffe0370c66410a51c55985b511/redirect
toolchainVendor=ADOPTIUM
toolchainVersion=21
62 changes: 62 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[versions]
##########################################################################
# Plugins
# Check this on https://github.com/FabricMC/fabric-loom/releases/latest/
loom = "1.15-SNAPSHOT"
##########################################################################
# Java Configuration
# The Java version the JDK will be for compiling and running code.
java = "17"
# The Java version the JDK will be for running Gradle.
gradleJava = "21"
##########################################################################EEE
# Mod Dependencies
# Check this on https://downloads.betterthanadventure.net/bta-client/
bta = "8.0.1"
# Options are release, prerelease, nightly, and misc.
btaChannel = "release"
# Check this on https://maven.thesignalumproject.net/#/infrastructure/net/fabricmc/fabric-loader/
loader = "0.18.4-bta.11"
# Check this on https://github.com/Turnip-Labs/ModMenu/releases/latest/
modMenu = "5.0.2"
# Check this on https://github.com/Turnip-Labs/bta-halplibe/releases/latest/
halplibe = "6.2.0+8.0.1"
# Check this on https://github.com/Better-than-Adventure/legacy-lwjgl3/releases/latest/
legacyLwjgl = "1.0.6"
##########################################################################
# Dependencies
# Check this on https://central.sonatype.com/artifact/org.slf4j/slf4j-api/
slf4jApi = "2.0.17"
# This should match the version used by the current BTA release.
lwjgl = "3.3.3"
joml = "1.10.8" # Note: BTA uses 1.10.7, patch 8 removes the kotlin stdlib dependency
jomlPrimitivess = "1.10.0"
commandly = "1.1.6+8.0.1"
paxels = "1.5.0+8.0.1"
btabackpacks = "1.2.0-8.0"
##########################################################################

[libraries]
btabackpacks = { group = "maven.modrinth", name = "better-with-backpacks", version.ref = "btabackpacks" }
loader = { group = "net.fabricmc", name = "fabric-loader", version.ref = "loader" }
halplibe = { group = "turniplabs", name = "halplibe", version.ref = "halplibe" }
modMenu = { group = "turniplabs", name = "modmenu-bta", version.ref = "modMenu" }
legacyLwjgl = { group = "com.github.Better-than-Adventure", name = "legacy-lwjgl3", version.ref = "legacyLwjgl" }
slf4jApi = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4jApi" }
commandly = { group = "maven.modrinth", name = "commandly", version.ref = "commandly" }
paxels = { group = "maven.modrinth", name = "paxels-bta", version.ref = "paxels" }
# https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar
clientJar = { group = "objects", name = "client", version = "43db9b498cb67058d2e12d394e6507722e71bb45" }
joml = { group = "org.joml", name = "joml", version.ref = "joml" }
joml-primitives = { group = "org.joml", name = "joml-primitives", version.ref = "jomlPrimitivess" }
lwjgl = { group = "org.lwjgl", name = "lwjgl", version.ref = "lwjgl"}
lwjgl-glfw = { group = "org.lwjgl", name = "lwjgl-glfw", version.ref = "lwjgl"}
lwjgl-openal = { group = "org.lwjgl", name = "lwjgl-openal", version.ref = "lwjgl"}
lwjgl-opengl = { group = "org.lwjgl", name = "lwjgl-opengl", version.ref = "lwjgl"}
lwjgl-stb = { group = "org.lwjgl", name = "lwjgl-stb", version.ref = "lwjgl"}

[bundles]
btaLwjgl = [ "lwjgl", "lwjgl-glfw", "lwjgl-openal", "lwjgl-opengl", "lwjgl-stb", "legacyLwjgl" ]

[plugins]
loom = { id = "net.fabricmc.fabric-loom", version.ref = "loom" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 4 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Check this on https://gradle.org/releases/
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading