Skip to content

Commit

Permalink
Clean up gradle building
Browse files Browse the repository at this point in the history
  • Loading branch information
magicus committed Jan 20, 2024
1 parent 1a365f6 commit e39c2eb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 77 deletions.
66 changes: 10 additions & 56 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,79 +1,33 @@
plugins {
id 'java'
id 'fabric-loom' version '1.5-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${project.mixinextras_version}")))
}

version = "${project.mod_version}+${project.minecraft_version}"

processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
expand "mod_version": project.version
}
}

tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 17
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
filesMatching("*.mixins.json") {
expand "java_version": project.java_version
}
}

java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
sourceCompatibility = JavaVersion.toVersion(project.java_version)
targetCompatibility = JavaVersion.toVersion(project.java_version)
}

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
tasks.withType(JavaCompile).configureEach {
it.options.release = project.java_version.toInteger()
}
22 changes: 8 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Mod version
mod_version=1.2.0

# Fabric Properties
# check these on https://fabricmc.net/develop
# Minecraft/Java version
# Also hardcoded in fabric.mod.json and *.mixin.json
minecraft_version=1.20
java_version=17

# Fabric versions -- check these on https://fabricmc.net/develop
# Also hardcoded in fabric.mod.json
yarn_mappings=1.20+build.1
loader_version=0.15.6

# Mod Properties
mod_version = 1.2.0+1.20
maven_group = se.icus.mag
archives_base_name = statuseffecttimer

# Dependencies
# Fabric api
fabric_version=0.83.0+1.20
mixinextras_version=0.2.2
6 changes: 3 additions & 3 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "statuseffecttimer",
"version": "${version}",
"version": "${mod_version}",

"name": "Status Effect Timer",
"description": "Overlay a timer on the Vanilla status effect HUD icons",
Expand All @@ -24,7 +24,7 @@
],

"depends": {
"fabricloader": ">=0.7.4",
"minecraft": "~1.20"
"minecraft": "~1.20",
"fabricloader": ">=0.15.6"
}
}
7 changes: 3 additions & 4 deletions src/main/resources/statuseffecttimer.mixins.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"required": true,
"minVersion": "0.8",
"package": "se.icus.mag.statuseffecttimer",
"compatibilityLevel": "JAVA_8",
"package": "se.icus.mag.statuseffecttimer.mixin",
"compatibilityLevel": "JAVA_17",
"client": [
"mixin.StatusEffectTimerMixin"
"StatusEffectTimerMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit e39c2eb

Please sign in to comment.