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

View file

@ -1,18 +1,10 @@
# Done to increase the memory available to gradle.
# Gradle Properties
org.gradle.jvmargs = -Xmx1G
# 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
org.gradle.parallel = true
# Mod Properties
mod_version=1.0.2
mod_version=1.0.3
maven_group=me.tibinonest.mods
archives_base_name=cauldron-dyeing
# Dependencies
sodium_version=mc1.18.2-0.4.1
# Dependencies are managed at gradle/libs.versions.toml

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
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
zipStorePath=wrapper/dists

View file

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