Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Gradle and modloader boilerplate #98

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 14 additions & 22 deletions mod/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,37 @@ plugins {
id("net.kyori.blossom") version "1.3.1"
}

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

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}"



// https://modrinth.com/mod/voxelmap-updated/version/1.18.2-1.11.2 (1.11.2 fabric)
modCompileOnly "maven.modrinth:voxelmap-updated:SDVTG1wT"
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"
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"
}

architectury {
common(rootProject.enabled_platforms.split(","))
modCompileOnly("maven.modrinth:xaeros-minimap:Jwydpps9")
}

tasks {
blossom {
replaceToken (
"%VERSION%",
project.version,
"src/main/java/gjum/minecraft/mapsync/common/MapSyncMod.java"
"%VERSION%",
project.version,
"src/main/java/gjum/minecraft/mapsync/common/MapSyncMod.java"
)
}
}

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.
processResources {
filesMatching("assets/mapsync/lang/en_us.json") {
expand(rootProject.properties)
}
}
4 changes: 0 additions & 4 deletions mod/common/src/main/resources/assets/map-sync/lang/en_us.json

This file was deleted.

4 changes: 4 additions & 0 deletions mod/common/src/main/resources/assets/mapsync/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"key.map-sync.openGui": "Open GUI",
"category.map-sync": "${mod_display_name}"
}
55 changes: 18 additions & 37 deletions mod/fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import groovy.json.JsonBuilder

plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}
Expand All @@ -16,32 +18,25 @@ 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"
modCompileOnly("maven.modrinth:modmenu:nVxObSbX")
}

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

filesMatching("fabric.mod.json") {
expand "version": project.version
expand(rootProject.properties)
filter {
(it as String).replace(
"\"%FABRIC_AUTHORS_ARRAY%\"",
new JsonBuilder((rootProject.properties["mod_authors"] as String).tokenize(",")).toString()
)
}
}
}

Expand All @@ -51,7 +46,7 @@ shadowJar {
}

remapJar {
input.set shadowJar.archiveFile
inputFile.set(shadowJar.archiveFile)
dependsOn shadowJar
classifier "fabric"
}
Expand All @@ -72,30 +67,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
30 changes: 15 additions & 15 deletions mod/fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
{
"schemaVersion": 1,
"id": "map-sync",
"version": "${version}",
"name": "Map Sync",
"description": "Sync map data with others instantly.",
"authors": [
"Gjum"
],
"id": "mapsync",
"version": "${mod_version}",
"name": "${mod_display_name}",
"description": "${mod_description}",
"authors": "%FABRIC_AUTHORS_ARRAY%",
"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 +22,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": [],
Gjum marked this conversation as resolved.
Show resolved Hide resolved
"injectors": {
"defaultRequire": 1
}
}
46 changes: 13 additions & 33 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,18 @@ 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(rootProject.properties)
}
filesMatching("pack.mcmeta") {
expand(rootProject.properties)
}
}

Expand All @@ -51,7 +45,7 @@ shadowJar {
}

remapJar {
input.set shadowJar.archiveFile
inputFile.set(shadowJar.archiveFile)
dependsOn shadowJar
classifier "forge"
}
Expand All @@ -72,30 +66,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
21 changes: 10 additions & 11 deletions mod/forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
modLoader = "javafml"
loaderVersion = "[40,)"
issueTrackerURL = "https://github.com/CivPlatform/map-sync/issues"
license = "GPL-3.0-only"
loaderVersion = "[${forge_major_version},)"
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 = "${mod_display_name}"
description = "${mod_description}"
displayURL = "${mod_home_url}"
authors = "${mod_authors}"
#logoFile = ""

[[dependencies.mapsync]]
modId = "forge"
mandatory = true
versionRange = "[40,)"
versionRange = "[${forge_major_version},)"
ordering = "NONE"
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": "${mod_display_name}",
"pack_format": 6
}
}
Loading
Loading