Skip to content

Commit 51b8e9a

Browse files
Big-Iron-CheemsWide-Cat
authored andcommitted
Migrate to Gradle Version Catalog
1 parent e4856c0 commit 51b8e9a

File tree

7 files changed

+62
-26
lines changed

7 files changed

+62
-26
lines changed

README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,23 @@ A template to allow easy usage of the Meteor Addon API.
3535
To update this template to a newer Minecraft version, follow these steps:
3636

3737
1. Ensure a Meteor Client snapshot is available for the new Minecraft version.
38-
2. Update `gradle.properties`:
39-
- Set `minecraft_version`, `yarn_mappings` and `loader_version` to the new version.
40-
- Update any additional dependencies accordingly.
38+
2. Update `gradle/libs.versions.toml` (the versions catalog):
39+
- Set the version entries to the new versions. Common keys to update are:
40+
- `versions.minecraft` - Minecraft version
41+
- `versions.yarn-mappings` - Yarn mappings
42+
- `versions.fabric-loader` - Fabric loader version
43+
- `versions.meteor` - Meteor Client snapshot version
44+
- If your addon depends on other libraries listed under the `[libraries]` section, update their versions there as
45+
needed.
46+
- After editing, refresh Gradle dependencies and rebuild your project in the IDE.
4147
3. Update Loom:
42-
- Change the `loom_version` in `build.gradle.kts` to the latest version compatible with the new Minecraft version.
48+
- Change the `loom` version in `gradle/libs.versions.toml` (the `versions.loom` entry) to the latest version
49+
compatible with the new Minecraft version.
4350
4. Update the Gradle wrapper:
44-
- You can find the latest Gradle version [here](https://gradle.org/releases/).
45-
- Run the `./gradlew wrapper --gradle-version <version>; ./gradlew wrapper` command to update the wrapper script.
51+
- Run the wrapper update command for your platform. Examples:
52+
- Unix / macOS / Windows (Powershell): `./gradlew wrapper --gradle-version <version> && ./gradlew wrapper`
53+
- Windows (cmd.exe): `gradlew.bat wrapper --gradle-version <version> && gradlew.bat wrapper`
54+
- This updates and regenerates the Gradle Wrapper scripts (`gradlew`, `gradlew.bat`, etc.) for the specified version.
4655
5. Update your source code:
4756
- Adjust for Minecraft or Yarn mapping changes: method names, imports, mixins, etc.
4857
- Check for Meteor Client API changes that may affect your addon by comparing against the
@@ -60,6 +69,7 @@ To update this template to a newer Minecraft version, follow these steps:
6069
│ │── dev_build.yml
6170
│ ╰── pull_request.yml
6271
│── gradle
72+
│ │── libs.versions.toml
6373
│ ╰── wrapper
6474
│ │── gradle-wrapper.jar
6575
│ ╰── gradle-wrapper.properties
@@ -97,8 +107,10 @@ This is the default project structure. Each folder/file has a specific purpose.
97107
Here is a brief explanation of the ones you might need to modify:
98108

99109
- `.github/workflows`: Contains the GitHub Actions configuration files.
100-
- `gradle`: Contains the Gradle wrapper files.
101-
Edit the `gradle.properties` file to change the version of the Gradle wrapper.
110+
- `gradle`: Contains the Gradle wrapper files and the versions catalog.
111+
- `libs.versions.toml`: Defines version numbers for Minecraft, Loom, Meteor, and other dependencies.
112+
- `wrapper`: Contains the Gradle wrapper executable files.
113+
To update the Gradle wrapper executable itself, run the wrapper update command (examples are shown above).
102114
- `src/main/java/com/example/addon`: Contains the main class of the addon.
103115
Here you can register your custom commands, modules, and HUDs.
104116
Edit the `getPackage` method to reflect the package of your addon.
@@ -115,8 +127,9 @@ Here is a brief explanation of the ones you might need to modify:
115127
- `build.gradle.kts`: Contains the Gradle build script.
116128
You can manage the dependencies of the addon here.
117129
Remember to keep the `fabric-loom` version up-to-date.
118-
- `gradle.properties`: Contains the properties of the Gradle build.
119-
These will be used by the build script.
130+
- `gradle.properties`: Contains additional build properties used by the build script
131+
(for example `maven_group` and `archives_base_name`).
132+
Dependency and platform version numbers are stored in `gradle/libs.versions.toml`.
120133
- `LICENSE`: Contains the license of the addon.
121134
You can edit this file to change the license of your addon.
122135
- `README.md`: Contains the documentation of the addon.

build.gradle.kts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
plugins {
2-
id("fabric-loom") version "1.11-SNAPSHOT"
2+
alias(libs.plugins.fabric.loom)
33
}
44

55
base {
66
archivesName = properties["archives_base_name"] as String
7-
version = properties["mod_version"] as String
7+
version = libs.versions.mod.version.get()
88
group = properties["maven_group"] as String
99
}
1010

@@ -21,19 +21,19 @@ repositories {
2121

2222
dependencies {
2323
// Fabric
24-
minecraft("com.mojang:minecraft:${properties["minecraft_version"] as String}")
25-
mappings("net.fabricmc:yarn:${properties["yarn_mappings"] as String}:v2")
26-
modImplementation("net.fabricmc:fabric-loader:${properties["loader_version"] as String}")
24+
minecraft(libs.minecraft)
25+
mappings(variantOf(libs.yarn) { classifier("v2") })
26+
modImplementation(libs.fabric.loader)
2727

2828
// Meteor
29-
modImplementation("meteordevelopment:meteor-client:${properties["minecraft_version"] as String}-SNAPSHOT")
29+
modImplementation(libs.meteor.client)
3030
}
3131

3232
tasks {
3333
processResources {
3434
val propertyMap = mapOf(
3535
"version" to project.version,
36-
"mc_version" to project.property("minecraft_version"),
36+
"mc_version" to libs.versions.minecraft.get()
3737
)
3838

3939
inputs.properties(propertyMap)

gradle.properties

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
org.gradle.jvmargs=-Xmx2G
22
org.gradle.configuration-cache=false
33

4-
# Fabric Properties (https://fabricmc.net/develop)
5-
minecraft_version=1.21.10
6-
yarn_mappings=1.21.10+build.2
7-
loader_version=0.17.3
8-
94
# Mod Properties
10-
mod_version=0.1.0
115
maven_group=com.example
126
archives_base_name=addon-template
13-
14-
# Dependencies

gradle/libs.versions.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[versions]
2+
mod-version = "0.1.0"
3+
4+
# Fabric (https://fabricmc.net/develop)
5+
minecraft = "1.21.10"
6+
yarn-mappings = "1.21.10+build.2"
7+
fabric-loader = "0.17.3"
8+
9+
# Loom (https://github.com/FabricMC/fabric-loom)
10+
loom = "1.12-SNAPSHOT"
11+
12+
# Meteor (https://github.com/MeteorDevelopment/meteor-client/)
13+
meteor = "1.21.10-SNAPSHOT"
14+
15+
# Mods
16+
17+
[libraries]
18+
# Fabric base
19+
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
20+
yarn = { module = "net.fabricmc:yarn", version.ref = "yarn-mappings" }
21+
fabric-loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric-loader" }
22+
23+
# Meteor client
24+
meteor-client = { module = "meteordevelopment:meteor-client", version.ref = "meteor" }
25+
26+
# Mods
27+
28+
[plugins]
29+
fabric-loom = { id = "fabric-loom", version.ref = "loom" }

gradle/wrapper/gradle-wrapper.jar

176 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ pluginManagement {
88
gradlePluginPortal()
99
}
1010
}
11+
12+
rootProject.name = "addon-template"

0 commit comments

Comments
 (0)