Skip to content

Commit e39c2eb

Browse files
committed
Clean up gradle building
1 parent 1a365f6 commit e39c2eb

File tree

4 files changed

+24
-77
lines changed

4 files changed

+24
-77
lines changed

build.gradle

Lines changed: 10 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,33 @@
11
plugins {
2+
id 'java'
23
id 'fabric-loom' version '1.5-SNAPSHOT'
3-
id 'maven-publish'
44
}
55

6-
sourceCompatibility = JavaVersion.VERSION_17
7-
targetCompatibility = JavaVersion.VERSION_17
8-
9-
archivesBaseName = project.archives_base_name
10-
version = project.mod_version
11-
group = project.maven_group
12-
136
dependencies {
14-
// To change the versions see the gradle.properties file
157
minecraft "com.mojang:minecraft:${project.minecraft_version}"
168
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
179
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
18-
include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:${project.mixinextras_version}")))
1910
}
2011

12+
version = "${project.mod_version}+${project.minecraft_version}"
13+
2114
processResources {
2215
inputs.property "version", project.version
2316

2417
filesMatching("fabric.mod.json") {
25-
expand "version": project.version
18+
expand "mod_version": project.version
2619
}
27-
}
2820

29-
tasks.withType(JavaCompile).configureEach {
30-
// ensure that the encoding is set to UTF-8, no matter what the system default is
31-
// this fixes some edge cases with special characters not displaying correctly
32-
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
33-
// If Javadoc is generated, this must be specified in that task too.
34-
it.options.encoding = "UTF-8"
35-
36-
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
37-
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
38-
// We'll use that if it's available, but otherwise we'll use the older option.
39-
def targetVersion = 17
40-
if (JavaVersion.current().isJava9Compatible()) {
41-
it.options.release = targetVersion
21+
filesMatching("*.mixins.json") {
22+
expand "java_version": project.java_version
4223
}
4324
}
4425

4526
java {
46-
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
47-
// if it is present.
48-
// If you remove this line, sources will not be generated.
49-
withSourcesJar()
27+
sourceCompatibility = JavaVersion.toVersion(project.java_version)
28+
targetCompatibility = JavaVersion.toVersion(project.java_version)
5029
}
5130

52-
jar {
53-
from("LICENSE") {
54-
rename { "${it}_${project.archivesBaseName}"}
55-
}
56-
}
57-
58-
// configure the maven publication
59-
publishing {
60-
publications {
61-
mavenJava(MavenPublication) {
62-
// add all the jars that should be included when publishing to maven
63-
artifact(remapJar) {
64-
builtBy remapJar
65-
}
66-
artifact(sourcesJar) {
67-
builtBy remapSourcesJar
68-
}
69-
}
70-
}
71-
72-
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
73-
repositories {
74-
// Add repositories to publish to here.
75-
// Notice: This block does NOT have the same function as the block in the top level.
76-
// The repositories here will be used for publishing your artifact, not for
77-
// retrieving dependencies.
78-
}
31+
tasks.withType(JavaCompile).configureEach {
32+
it.options.release = project.java_version.toInteger()
7933
}

gradle.properties

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
# Done to increase the memory available to gradle.
2-
org.gradle.jvmargs=-Xmx1G
1+
# Mod version
2+
mod_version=1.2.0
33

4-
# Fabric Properties
5-
# check these on https://fabricmc.net/develop
4+
# Minecraft/Java version
5+
# Also hardcoded in fabric.mod.json and *.mixin.json
66
minecraft_version=1.20
7+
java_version=17
8+
9+
# Fabric versions -- check these on https://fabricmc.net/develop
10+
# Also hardcoded in fabric.mod.json
711
yarn_mappings=1.20+build.1
812
loader_version=0.15.6
9-
10-
# Mod Properties
11-
mod_version = 1.2.0+1.20
12-
maven_group = se.icus.mag
13-
archives_base_name = statuseffecttimer
14-
15-
# Dependencies
16-
# Fabric api
17-
fabric_version=0.83.0+1.20
18-
mixinextras_version=0.2.2

src/main/resources/fabric.mod.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"schemaVersion": 1,
33
"id": "statuseffecttimer",
4-
"version": "${version}",
4+
"version": "${mod_version}",
55

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

2626
"depends": {
27-
"fabricloader": ">=0.7.4",
28-
"minecraft": "~1.20"
27+
"minecraft": "~1.20",
28+
"fabricloader": ">=0.15.6"
2929
}
3030
}

src/main/resources/statuseffecttimer.mixins.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
{
22
"required": true,
3-
"minVersion": "0.8",
4-
"package": "se.icus.mag.statuseffecttimer",
5-
"compatibilityLevel": "JAVA_8",
3+
"package": "se.icus.mag.statuseffecttimer.mixin",
4+
"compatibilityLevel": "JAVA_17",
65
"client": [
7-
"mixin.StatusEffectTimerMixin"
6+
"StatusEffectTimerMixin"
87
],
98
"injectors": {
109
"defaultRequire": 1

0 commit comments

Comments
 (0)