Skip to content

Commit

Permalink
feat: Improved Gradle configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Norbiros committed Jul 8, 2024
1 parent 0ee6733 commit 4c14c79
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 115 deletions.
60 changes: 50 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
plugins {
id "java"
id "com.github.johnrengelman.shadow" version "8.1.1" apply false

id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
}

architectury {
minecraft = rootProject.minecraft_version
}

subprojects {
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "dev.architectury.loom"

configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentFabric.extendsFrom common
}

processResources {
def resourceTargets = [
"fabric.mod.json",
"META-INF/neoforge.mods.toml",
]

def replaceProperties = [
version : mod_version,
fabric_minecraft_version_range : fabric_minecraft_version_range,
neo_version_range : neo_minecraft_version_range,
fabric_loader_version : fabric_loader_version,
cloth_config_version : cloth_config_version,
modmenu_version : modmenu_version,
]

inputs.properties replaceProperties
filesMatching(resourceTargets) {
expand replaceProperties
}
}


loom {
silentMojangMappingsLicense()
}
Expand All @@ -23,8 +57,15 @@ subprojects {
}
}

repositories {
maven { url "https://maven.neoforged.net/releases/" }
shadowJar {
exclude "architectury.common.json"

configurations = [project.configurations.shadowCommon]
archiveClassifier.set("dev-shadow")
}

jar {
archiveClassifier.set("dev")
}
}

Expand All @@ -33,18 +74,17 @@ allprojects {
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"

archivesBaseName = rootProject.archives_base_name
base.archivesName = rootProject.mod_id
version = rootProject.mod_version
group = rootProject.maven_group

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
// Architectury, Cloth Config
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/"}
// ModMenu
maven { url "https://maven.terraformersmc.com/" }
// NeoForge
maven { url "https://maven.neoforged.net/releases/" }
}

tasks.withType(JavaCompile) {
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies {
publishing {
publications {
mavenCommon(MavenPublication) {
artifactId = rootProject.archives_base_name
artifactId = rootProject.mod_id
from components.java
}
}
Expand Down
36 changes: 1 addition & 35 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,8 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}

architectury {
platformSetupLoomIde()
fabric()
}

configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentFabric.extendsFrom common
}

dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.fabric_loader_version}"

Expand All @@ -27,29 +15,12 @@ dependencies {
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
}

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

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

shadowJar {
configurations = [project.configurations.shadowCommon]
archiveClassifier.set("dev-shadow")
}

remapJar {
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set("fabric")
}

jar {
archiveClassifier.set("dev")
}

sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
Expand All @@ -65,13 +36,8 @@ components.java {
publishing {
publications {
mavenFabric(MavenPublication) {
artifactId = rootProject.archives_base_name + "-fabric"
artifactId = rootProject.mod_id + "-fabric"
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.
}
}
9 changes: 5 additions & 4 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": "emojitype",
"version": "${version}",
"name": "Emoji Type",
"description": "A mod that lets you type minecraft emojis easier!",
"description": "A mod that lets you type Minecraft emojis easier!",
"license": "GPL-3.0",
"icon": "logo.png",
"authors": [
Expand Down Expand Up @@ -33,10 +33,11 @@
],

"depends": {
"fabricloader": ">=0.14.21",
"minecraft": ">=1.20"
"fabricloader": "~${fabric_loader_version}",
"minecraft": "${fabric_minecraft_version_range}"
},
"suggests": {
"cloth-config2" : ">=10.0.0"
"cloth-config2" : "~${cloth_config_version}",
"modmenu": "~${modmenu_version}"
}
}
23 changes: 14 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
org.gradle.jvmargs=-Xmx2G

# https://linkie.shedaniel.me/dependencies

archives_base_name=emoji-type
mod_version=2.2.5+1.21
mod_id=emoji-type
mod_version=2.2.5-1.21
maven_group=dev.norbiros
minecraft_version = 1.21

minecraft_version=1.21
minecraft_version_range=1.21
# Find versions in Linkie:
# https://linkie.shedaniel.me/dependencies

# Loader specific
fabric_minecraft_version_range=1.21
fabric_loader_version=0.15.11
yarn_mappings=1.21+build.2
neoforge_version=21.0.30-beta
yarn_mappings=1.21+build.8

neo_minecraft_version_range=[21, 22)
neoforge_version=21.0.76-beta
neoforge_yarn_mappings_patch=1.21+build.4

# Architectury
enabled_platforms=fabric,neoforge
architectury_version=13.0.1
architectury_version=13.0.3

# Mods versions
cloth_config_version=15.0.127
modmenu_version=11.0.1
39 changes: 2 additions & 37 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,53 +1,23 @@
plugins {
id "com.github.johnrengelman.shadow" version "7.1.2"
}

architectury {
platformSetupLoomIde()
neoForge()
}

configurations {
common
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
compileClasspath.extendsFrom common
runtimeClasspath.extendsFrom common
developmentNeoForge.extendsFrom common
}

dependencies {
neoForge "net.neoforged:neoforge:${rootProject.neoforge_version}"
neoForge "net.neoforged:neoforge:${project.neoforge_version}"

implementation "me.shedaniel.cloth:cloth-config-neoforge:${project.cloth_config_version}"

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

processResources {
filesMatching("META-INF/neoforge.mods.toml") {
expand "version": project.version
}
}

shadowJar {
exclude "fabric.mod.json"
exclude "architectury.common.json"

configurations = [project.configurations.shadowCommon]
archiveClassifier.set("dev-shadow")
}

remapJar {
inputFile.set shadowJar.archiveFile
dependsOn shadowJar
archiveClassifier.set("neoforge")
}

jar {
archiveClassifier.set("dev")
}

sourcesJar {
def commonSources = project(":common").sourcesJar
dependsOn commonSources
Expand All @@ -63,13 +33,8 @@ components.java {
publishing {
publications {
mavenNeoForge(MavenPublication) {
artifactId = rootProject.archives_base_name + "-neoforge"
artifactId = rootProject.mod_id + "-neoforge"
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.
}
}
40 changes: 21 additions & 19 deletions neoforge/src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,33 @@ loaderVersion = "[1,)"
license = "GPL-3.0"
issueTrackerURL = "https://github.com/Norbiros/emojitype/issues"
displayURL = "https://modrinth.com/mod/emoji-type"
#updateJSONURL="https://api.modrinth.com/updates/emoji-type/forge_updates.json"
updateJSONURL="https://api.modrinth.com/updates/emoji-type/forge_updates.json?neoforge=only"
logoFile = "logo.png"
logoBlur = false
authors = "Cyborgcabbage,Norbiros"

[[mods]]
modId = "emojitype"
version = "${version}"
displayName = "Emoji Type"
description='''
A mod that lets you type minecraft emojis easier!
'''
credits="Thanks to cyborgcabbage for original mod!"
modId = "emojitype"
version = "${version}"
displayName = "Emoji Type"
description='''
A mod that lets you type minecraft emojis easier!
'''
credits="Thanks to cyborgcabbage for original mod!"

[[mixins]]
config = "emojitype-common.mixins.json"
config = "emojitype-common.mixins.json"

[[dependencies.emojitype]]
modId = "neoforge"
type = "required"
versionRange = "[20.6,)"
ordering = "NONE"
side = "BOTH"
modId = "neoforge"
type = "required"
versionRange = "${neo_version_range}"
ordering = "NONE"
side = "BOTH"

[[dependencies.emojitype]]
modId = "cloth_config"
type = "optional"
versionRange = "[14.0.0,)"
ordering = "AFTER"
side = "BOTH"
modId = "cloth_config"
type = "optional"
versionRange = "[${cloth_config_version},)"
ordering = "AFTER"
side = "BOTH"

0 comments on commit 4c14c79

Please sign in to comment.