Skip to content

Commit

Permalink
Migrate to libs.versions.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
Ampflower committed Feb 20, 2024
1 parent 0b57694 commit 917dfa6
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 32 deletions.
26 changes: 11 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@ import java.nio.charset.StandardCharsets
plugins {
java
`java-library`
id("fabric-loom")
id("com.diffplug.spotless")
id("com.modrinth.minotaur")
alias(libs.plugins.loom)
alias(libs.plugins.spotless)
alias(libs.plugins.minotaur)
`maven-publish`
}

val minecraftVersion: String by project
val minecraftRequired: String by project
val minecraftCompatible: String by project
val yarnMappings: String by project
val loaderVersion: String by project
val fabricApiVersion: String by project
val minecraftVersion = libs.versions.minecraft.version.get()
val minecraftCompatible = libs.versions.minecraft.compatible.get()
val fabricApiVersion = libs.versions.fabric.api.get()
val projectVersion: String by project
val modrinthId: String by project

Expand All @@ -24,7 +21,6 @@ val isRelease = System.getenv("BUILD_RELEASE").toBoolean()
val isActions = System.getenv("GITHUB_ACTIONS").toBoolean()
val baseVersion = "$projectVersion+mc.$minecraftVersion"

group = "gay.ampflower"
version = when {
isRelease -> baseVersion
isActions -> "$baseVersion-build.${System.getenv("GITHUB_RUN_NUMBER")}-commit.${System.getenv("GITHUB_SHA").substring(0, 7)}-branch.${System.getenv("GITHUB_REF")?.substring(11)?.replace('/', '.') ?: "unknown"}"
Expand All @@ -41,11 +37,12 @@ repositories {
}

dependencies {
minecraft("com.mojang", "minecraft", minecraftVersion)
mappings("net.fabricmc", "yarn", yarnMappings, classifier = "v2")
modImplementation("net.fabricmc", "fabric-loader", loaderVersion)
minecraft(libs.minecraft)
mappings(variantOf(libs.yarn) { classifier("v2") })
modImplementation(libs.bundles.fabric)
include(modImplementation(fabricApi.module("fabric-lifecycle-events-v1", fabricApiVersion))!!)
include(modImplementation(fabricApi.module("fabric-api-base", fabricApiVersion))!!)
compileOnly(libs.bundles.compile)
}
spotless {
java {
Expand All @@ -65,8 +62,7 @@ tasks {
val map = mapOf(
"version" to project.version,
"project_version" to projectVersion,
"loader_version" to loaderVersion,
"minecraft_required" to minecraftRequired
"minecraft_required" to libs.versions.minecraft.required.get()
)
inputs.properties(map)

Expand Down
13 changes: 1 addition & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,7 @@
projectVersion=0.2.2
modrinthId=jsiDlnm9

# Minecraft
minecraftVersion=1.19.3
minecraftRequired=1.19.3
minecraftCompatible=1.19.3
yarnMappings=1.19.3+build.2
loaderVersion=0.14.11
fabricApiVersion=0.68.1+1.19.3

# Plugins
systemProp.loomVersion=1.5.+
systemProp.spotlessVersion=6.25.+
systemProp.minotaurVersion=2.+
group=gay.ampflower.mod

# Gradle Extras
org.gradle.jvmargs=-Xmx1G
38 changes: 38 additions & 0 deletions libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[versions]
# Minecraft
minecraft-version = "1.19.3"
minecraft-required = ">=1.19.3"
minecraft-compatible = "1.19.3,1.19.4,1.20,1.20.1,1.20.2"

yarn = "1.19.3+build.2"

# Fabric
fabric-loader = "0.15.+"
fabric-api = "0.68.1+1.19.3"

# Libraries
annotations = "23.+"

# Plugins
loom = "1.5.+"
spotless = "6.25.+"
minotaur = "2.+"

[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft-version" }
yarn = { module = "net.fabricmc:yarn", version.ref = "yarn" }

fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" }
fabric-api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric-api" }

annotations = { module = "org.jetbrains:annotations", version.ref = "annotations" }

[bundles]
fabric = ["fabric-loader"]

compile = ["annotations"]

[plugins]
loom = { id = "fabric-loom", version.ref = "loom" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
minotaur = { id = "com.modrinth.minotaur", version.ref = "minotaur" }
12 changes: 7 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ pluginManagement {
}
gradlePluginPortal()
}
plugins {
id("fabric-loom") version System.getProperty("loomVersion")!!
id("com.diffplug.spotless") version System.getProperty("spotlessVersion")!!
id("com.modrinth.minotaur") version System.getProperty("minotaurVersion")!!
}
}

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("libs.versions.toml"))
}
}
}

0 comments on commit 917dfa6

Please sign in to comment.