Improve gradle

Mostly taken from Quilt's template mod.

- No longer JIJs FAPI
- Update gradle wrapper
This commit is contained in:
tibs 2022-06-07 20:58:31 -04:00
parent 4a949172c0
commit e7ce0084ca
Signed by untrusted user who does not match committer: tibs
GPG key ID: 047833989F50F88F
6 changed files with 52 additions and 54 deletions

View file

@ -1,50 +1,33 @@
plugins { plugins {
id 'fabric-loom' version '0.11.+' alias(libs.plugins.fabric.loom)
id 'io.github.juuxel.loom-quiltflower' version '1.6.0' alias(libs.plugins.loom.quiltflower)
id 'org.quiltmc.quilt-mappings-on-loom' version '4.0.0' alias(libs.plugins.qmol)
id 'org.ajoberstar.grgit' version '5.0.0' alias(libs.plugins.grgit)
} }
sourceCompatibility = '17'
targetCompatibility = '17'
archivesBaseName = project.archives_base_name archivesBaseName = project.archives_base_name
version = "${project.mod_version}+${getMetadata()}" version = "${project.mod_version}+${getMetadata()}"
group = project.maven_group group = project.maven_group
repositories { repositories {
maven { maven {
name = "Modrinth" name = 'Modrinth'
url = "https://api.modrinth.com/maven" url = 'https://api.modrinth.com/maven'
content { content {
includeGroup "maven.modrinth" includeGroup 'maven.modrinth'
} }
} }
} }
var apiModules = [
"fabric-api-base",
"fabric-networking-api-v1",
"fabric-object-builder-api-v1",
"fabric-registry-sync-v0"
]
dependencies { dependencies {
// To change the versions see the gradle.properties file minecraft libs.minecraft
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.layered { mappings loom.layered {
it.mappings("net.fabricmc:yarn:${project.minecraft_version}+build.${project.yarn_mappings}:v2") addLayer quiltMappings.mappings("org.quiltmc:quilt-mappings:${libs.versions.quilt.mappings.get()}:v2")
it.addLayer(quiltMappings.mappings("org.quiltmc:quilt-mappings:${project.minecraft_version}+build.${project.quilt_mappings}:v2"))
} }
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation libs.fabric.loader
// Fabric API modImplementation libs.fabric.api
apiModules.forEach { modCompileOnly libs.sodium
include modImplementation(fabricApi.module(it, project.fabric_version))
}
// Sodium
modCompileOnly "maven.modrinth:sodium:${project.sodium_version}"
} }
processResources { processResources {
@ -58,9 +41,15 @@ processResources {
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
it.options.encoding = 'UTF-8' it.options.encoding = 'UTF-8'
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
} }
java { java {
// Still required by IDEs such as Eclipse and Visual Studio Code
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withSourcesJar() withSourcesJar()
} }
@ -71,13 +60,13 @@ jar {
} }
def getMetadata() { def getMetadata() {
def build_id = System.getenv("GITHUB_RUN_NUMBER") def build_id = System.getenv('GITHUB_RUN_NUMBER')
def workflow_id = System.getenv("GITHUB_WORKFLOW") def workflow_id = System.getenv('GITHUB_WORKFLOW')
def metadata = project.minecraft_version def metadata = libs.versions.minecraft.get()
// Release builds only // Release builds only
if (workflow_id == "build-release") { if (workflow_id == 'build-release') {
return metadata return metadata
} }
@ -89,7 +78,7 @@ def getMetadata() {
// Flag the build if the build tree is not clean // Flag the build if the build tree is not clean
if (!grgit.status().clean) { if (!grgit.status().clean) {
id += "-dirty" id += '-dirty'
} }
metadata += "-${id}" metadata += "-${id}"

View file

@ -1,18 +1,10 @@
# Done to increase the memory available to gradle. # Gradle Properties
org.gradle.jvmargs = -Xmx1G org.gradle.jvmargs = -Xmx1G
org.gradle.parallel = true
# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.18.2
quilt_mappings=22
yarn_mappings=2
loader_version=0.13.3
fabric_version=0.50.0+1.18.2
# Mod Properties # Mod Properties
mod_version=1.0.2 mod_version=1.0.3
maven_group=me.tibinonest.mods maven_group=me.tibinonest.mods
archives_base_name=cauldron-dyeing archives_base_name=cauldron-dyeing
# Dependencies # Dependencies are managed at gradle/libs.versions.toml
sodium_version=mc1.18.2-0.4.1

21
gradle/libs.versions.toml Normal file
View file

@ -0,0 +1,21 @@
[versions]
minecraft = "1.18.2"
quilt_mappings = "1.18.2+build.24"
fabric_loader = "0.14.6"
fabric_api = "0.55.1+1.18.2"
sodium = "mc1.18.2-0.4.1"
[libraries]
minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" }
quilt_mappings = { module = "org.quiltmc:quilt-mappings", version.ref = "quilt_mappings" }
fabric_loader = { module = "net.fabricmc:fabric-loader", version.ref = "fabric_loader" }
fabric_api = { module = "net.fabricmc.fabric-api:fabric-api", version.ref = "fabric_api" }
sodium = { module = "maven.modrinth:sodium", version.ref = "sodium" }
[plugins]
fabric_loom = { id = "fabric-loom", version = "0.12.+" }
loom_quiltflower = { id = "io.github.juuxel.loom-quiltflower", version = "1.7.+" }
qmol = { id = "org.quiltmc.quilt-mappings-on-loom", version = "4.2.0" }
grgit = { id = "org.ajoberstar.grgit", version = "5.0.0" }

Binary file not shown.

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View file

@ -1,17 +1,13 @@
pluginManagement { pluginManagement {
repositories { repositories {
maven { maven {
name 'Quilt' name = 'Quilt'
url 'https://maven.quiltmc.org/repository/release' url = 'https://maven.quiltmc.org/repository/release'
} }
maven { maven {
name = 'Fabric' name = 'Fabric'
url = 'https://maven.fabricmc.net/' url = 'https://maven.fabricmc.net/'
} }
maven {
name = 'Cotton'
url = 'https://server.bbkr.space/artifactory/libs-release/'
}
gradlePluginPortal() gradlePluginPortal()
} }
} }