Skip to content

Commit

Permalink
Cleanup the mod's Gradle boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
Protonull committed Dec 30, 2023
1 parent 97dc4d0 commit d9c06a5
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 122 deletions.
3 changes: 3 additions & 0 deletions mod/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ allprojects {
includeGroup "maven.modrinth"
}
}
maven {
url "https://www.jitpack.io"
}
}

tasks.withType(JavaCompile) {
Expand Down
41 changes: 13 additions & 28 deletions mod/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@ plugins {
id("net.kyori.blossom") version "1.3.1"
}

dependencies {
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
// Do NOT use other classes from fabric loader
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"

architectury {
injectInjectables = false
common(rootProject.enabled_platforms.split(","))
}

dependencies {
// Do NOT use other classes from fabric loader, we only use this fabric @Environment and mixin annotations!
modImplementation("net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}")

// https://modrinth.com/mod/voxelmap-updated/version/1.18.2-1.11.2 (1.11.2 fabric)
modCompileOnly "maven.modrinth:voxelmap-updated:SDVTG1wT"
// https://modrinth.com/mod/journeymap/version/1.18.2-5.9.7-fabric (5.9.7 fabric)
modCompileOnly "maven.modrinth:journeymap:5JbcGXLn"
// https://modrinth.com/mod/xaeros-minimap/version/23.6.2_Fabric_1.18.2 (23.6.2 fabric)
modCompileOnly "maven.modrinth:xaeros-minimap:Jwydpps9"
}
// VoxelMap 1.11.2 (https://modrinth.com/mod/voxelmap-updated/version/1.18.2-1.11.2)
modCompileOnlyApi("maven.modrinth:voxelmap-updated:SDVTG1wT")

architectury {
common(rootProject.enabled_platforms.split(","))
// JourneyMap API 1.9 (https://www.jitpack.io/#TeamJM/journeymap-api)
compileOnlyApi("com.github.TeamJM:journeymap-api:1.18.2_1.9-SNAPSHOT")
// JourneyMap 5.9.7 (https://modrinth.com/mod/journeymap/version/1.18.2-5.9.7-fabric)
modCompileOnlyApi("maven.modrinth:journeymap:5JbcGXLn")
}

tasks {
Expand All @@ -31,17 +30,3 @@ tasks {
)
}
}

publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = rootProject.archives_base_name
from components.java
}
}

// 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.
}
}
57 changes: 20 additions & 37 deletions mod/fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,29 @@ configurations {
}

dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
modImplementation("net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}")
modApi("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}")

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }



// https://modrinth.com/mod/voxelmap-updated/version/1.18.2-1.11.2 (1.11.2 fabric)
modCompileOnly "maven.modrinth:voxelmap-updated:SDVTG1wT"
// https://modrinth.com/mod/journeymap/version/1.18.2-5.9.7-fabric (5.9.7 fabric)
modCompileOnly "maven.modrinth:journeymap:5JbcGXLn"
// https://modrinth.com/mod/xaeros-minimap/version/23.6.2_Fabric_1.18.2 (23.6.2 fabric)
modCompileOnly "maven.modrinth:xaeros-minimap:Jwydpps9"



// https://modrinth.com/mod/modmenu/version/3.2.5 (3.2.5 fabric)
modCompileOnly "maven.modrinth:modmenu:nVxObSbX"
// ModMenu 3.2.5
modCompileOnly("maven.modrinth:modmenu:nVxObSbX") // https://modrinth.com/mod/modmenu/version/3.2.5
}

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

filesMatching("fabric.mod.json") {
expand "version": project.version
expand([
"mod_version": rootProject.mod_version,
"mod_description": rootProject.mod_description,
"mod_home_url": rootProject.mod_home_url,
"mod_source_url": rootProject.mod_source_url,
"mod_issues_url": rootProject.mod_issues_url,
"copyright_licence": rootProject.copyright_licence,

"minecraft_version": rootProject.minecraft_version,
"fabric_loader_version": rootProject.fabric_loader_version
])
}
}

Expand Down Expand Up @@ -72,30 +69,16 @@ components.java {
}
}

publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}

// 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.
}
}

tasks.register('cleanJar', Delete) {
delete fileTree('../dist') {
tasks.register("cleanJar", Delete) {
delete fileTree("../dist") {
include "*-fabric.jar"
}
}

tasks.register('copyJar', Copy) {
tasks.register("copyJar", Copy) {
dependsOn cleanJar
from remapJar
into '../dist'
into "../dist"
}

build.dependsOn copyJar
copyJar.dependsOn cleanJar
1 change: 1 addition & 0 deletions mod/fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=fabric
29 changes: 16 additions & 13 deletions mod/fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{
"schemaVersion": 1,
"id": "map-sync",
"version": "${version}",
"name": "Map Sync",
"description": "Sync map data with others instantly.",
"id": "mapsync",
"version": "${mod_version}",
"name": "MapSync",
"description": "${mod_description}",
"authors": [
"Gjum"
"Gjum",
"Protonull"
],
"contact": {
"homepage": "https://github.com/Gjum/map-sync",
"sources": "https://github.com/Gjum/map-sync"
"homepage": "${mod_home_url}",
"sources": "${mod_source_url}",
"issues": "${mod_issues_url}"
},
"license": "GPL-3.0-only",
"icon": "assets/map-sync/icon.png",
"license": "${copyright_licence}",
"icon": "assets/mapsync/icon.png",
"environment": "client",
"entrypoints": {
"client": [
Expand All @@ -23,11 +25,12 @@
]
},
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"minecraft": "1.18.x"
"minecraft": "${minecraft_version}",
"fabricloader": ">=${fabric_loader_version}",
"fabric": "*"
},
"mixins": [
"mixin.map-sync.json"
"mapsync.common.mixins.json",
"mapsync.fabric.mixins.json"
]
}
14 changes: 14 additions & 0 deletions mod/fabric/src/main/resources/mapsync.fabric.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"required": true,
"minVersion": "0.8",
"package": "gjum.minecraft.mapsync.fabric.mixins",
"compatibilityLevel": "JAVA_17",
"mixins": [],
"client": [

],
"server": [],
"injectors": {
"defaultRequire": 1
}
}
50 changes: 18 additions & 32 deletions mod/forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ architectury {

loom {
forge {
mixinConfig "mixin.map-sync.json"
mixinConfig "mapsync.common.mixins.json", "mapsync.forge.mixins.json"
}
}

Expand All @@ -22,24 +22,24 @@ configurations {
}

dependencies {
forge "net.minecraftforge:forge:${rootProject.forge_version}"
forge("net.minecraftforge:forge:${rootProject.forge_version}")

common(project(path: ":common", configuration: "namedElements")) { transitive false }
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }



// https://modrinth.com/mod/journeymap/version/1.18.2-5.9.7-forge (5.9.7 forge)
modCompileOnly "maven.modrinth:journeymap:2G6aMzKY"
// https://modrinth.com/mod/xaeros-minimap/version/23.6.2_Forge_1.18.2 (23.6.2 forge)
modCompileOnly "maven.modrinth:xaeros-minimap:yFuICfIq"
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false }
}

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

filesMatching("META-INF/mods.toml") {
expand "version": project.version
expand([
"mod_issues_url": rootProject.mod_issues_url,
"copyright_licence": rootProject.copyright_licence,

"mod_version": rootProject.mod_version,
"mod_description": rootProject.mod_description,
"mod_home_url": rootProject.mod_home_url,

"minecraft_version": rootProject.minecraft_version
])
}
}

Expand Down Expand Up @@ -72,30 +72,16 @@ components.java {
}
}

publishing {
publications {
mavenForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-" + project.name
from components.java
}
}

// 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.
}
}

tasks.register('cleanJar', Delete) {
delete fileTree('../dist') {
tasks.register("cleanJar", Delete) {
delete fileTree("../dist") {
include "*-forge.jar"
}
}

tasks.register('copyJar', Copy) {
tasks.register("copyJar", Copy) {
dependsOn cleanJar
from remapJar
into '../dist'
into "../dist"
}

build.dependsOn copyJar
copyJar.dependsOn cleanJar
17 changes: 8 additions & 9 deletions mod/forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
modLoader = "javafml"
loaderVersion = "[40,)"
issueTrackerURL = "https://github.com/CivPlatform/map-sync/issues"
license = "GPL-3.0-only"
issueTrackerURL = "${mod_issues_url}"
license = "${copyright_licence}"

[[mods]]
modId = "mapsync"
version = "${version}"
displayName = "Map Sync"
authors = "Gjum"
description = '''
Sync map data with others instantly.
'''
version = "${mod_version}"
displayName = "MapSync"
description = "${mod_description}"
displayURL = "${mod_home_url}"
authors = "Gjum,Protonull"
#logoFile = ""

[[dependencies.mapsync]]
Expand All @@ -23,6 +22,6 @@ side = "CLIENT"
[[dependencies.mapsync]]
modId = "minecraft"
mandatory = true
versionRange = "[1.18.2,)"
versionRange = "[${minecraft_version},)"
ordering = "NONE"
side = "CLIENT"
14 changes: 14 additions & 0 deletions mod/forge/src/main/resources/mapsync.forge.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"required": true,
"minVersion": "0.8",
"package": "gjum.minecraft.mapsync.forge.mixins",
"compatibilityLevel": "JAVA_17",
"mixins": [],
"client": [

],
"server": [],
"injectors": {
"defaultRequire": 1
}
}
2 changes: 1 addition & 1 deletion mod/forge/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"description": "Map Sync",
"description": "MapSync",
"pack_format": 6
}
}
7 changes: 6 additions & 1 deletion mod/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
org.gradle.jvmargs=-Xmx2048M

archives_base_name=map-sync
archives_base_name=MapSync
maven_group=gjum.minecraft.mapsync
mod_version=2.0.1-1.18.2
mod_description=Share map data with your friends, live, privately.
copyright_licence=GPLv3
mod_home_url=https://github.com/Protonull/MapSync
mod_source_url=https://github.com/Protonull/MapSync
mod_issues_url=https://github.com/Protonull/MapSync/issues

minecraft_version=1.18.2
enabled_platforms=fabric,forge
Expand Down
2 changes: 1 addition & 1 deletion mod/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ include("common")
include("fabric")
include("forge")

rootProject.name = "map-sync"
rootProject.name = "MapSync"

0 comments on commit d9c06a5

Please sign in to comment.