Skip to content

Commit

Permalink
Improve gradle
Browse files Browse the repository at this point in the history
Mostly taken from Quilt's template mod.

- No longer JIJs FAPI
- Update gradle wrapper
  • Loading branch information
TibiNonEst committed Jun 8, 2022
1 parent 6cb7a4a commit bd52a34
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 52 deletions.
56 changes: 23 additions & 33 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,49 +1,33 @@
plugins {
id 'fabric-loom' version '0.11.+'
id 'io.github.juuxel.loom-quiltflower' version '1.7.+'
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 {
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 {
Expand All @@ -57,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()
}

Expand All @@ -70,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
}

Expand All @@ -88,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}"
Expand Down
17 changes: 5 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.19
quilt_mappings=1
loader_version=0.14.6
fabric_version=0.55.2+1.19
# Gradle Properties
org.gradle.jvmargs = -Xmx1G
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.19-0.4.2
# Dependencies are managed at gradle/libs.versions.toml
21 changes: 21 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[versions]
minecraft = "1.19"
quilt_mappings = "1.19+build.1"
fabric_loader = "0.14.6"

fabric_api = "0.55.2+1.19"
sodium = "mc1.19-0.4.2"

[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 modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit bd52a34

Please sign in to comment.