Skip to content

Commit

Permalink
build: switch to ModDevGradle
Browse files Browse the repository at this point in the history
  • Loading branch information
bconlon1 committed Nov 10, 2024
1 parent 317a162 commit 438c5ba
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 27 deletions.
71 changes: 47 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version "${neogradle_version}"
id 'net.neoforged.moddev' version "${moddevgradle_version}"
id 'com.matthewprenger.cursegradle' version '[1.4,1.5)'
id 'com.modrinth.minotaur' version '[2,3)'
}
Expand All @@ -21,51 +21,72 @@ base {

java.toolchain.languageVersion = JavaLanguageVersion.of(21)

runs {
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
systemProperty 'forge.logging.console.level', 'debug'
neoForge {
version = project.neo_version

modSource project.sourceSets.main
}
runs {
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
logLevel = org.slf4j.event.Level.DEBUG
}

client {
systemProperty 'forge.enabledGameTestNamespaces', mod_id
}
client {
client()
systemProperty 'forge.enabledGameTestNamespaces', mod_id
}

server {
systemProperty 'forge.enabledGameTestNamespaces', mod_id
programArgument '--nogui'
}
server {
server()
systemProperty 'forge.enabledGameTestNamespaces', mod_id
programArgument '--nogui'
}

gameTestServer {
type = "gameTestServer"
systemProperty 'neoforge.enabledGameTestNamespaces', mod_id
}

gameTestServer {
systemProperty 'neoforge.enabledGameTestNamespaces', mod_id
data {
data()
programArguments.addAll '--mod', mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath(), '--existing', file('src/generated/resources/').getAbsolutePath()
}
}

data {
programArguments.addAll '--mod', mod_id, '--all', '--output', file('src/generated/resources/').getAbsolutePath(), '--existing', file('src/main/resources/').getAbsolutePath(), '--existing', file('src/generated/resources/').getAbsolutePath()
mods {
"${mod_id}" {
sourceSet(sourceSets.main)
}
}
}

sourceSets.main.resources {
srcDir 'src/generated/resources'
}

processResources {
exclude '.cache/'
}

configurations {
runtimeClasspath.extendsFrom localRuntime
}

dependencies {
implementation "net.neoforged:neoforge:${project.neo_version}"

}

repositories {
maven { url = "https://maven.blamejared.com" }
}

tasks.withType(ProcessResources).configureEach {
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
var replaceProperties = [
mod_id : mod_id,
mod_name : mod_name,
mod_version : mod_version,
mod_license : mod_license,
mod_url : mod_url,
mod_update : mod_update,
mod_tracker : mod_tracker,
mod_credits : mod_credits,
mod_authors : mod_authors,
Expand All @@ -77,14 +98,16 @@ tasks.withType(ProcessResources).configureEach {
loader_version_range : loader_version_range
]
inputs.properties replaceProperties

filesMatching(['META-INF/neoforge.mods.toml']) {
expand replaceProperties
}
expand replaceProperties
from "src/main/templates"
into "build/generated/sources/modMetadata"
}
sourceSets.main.resources.srcDir generateModMetadata
neoForge.ideSyncTask generateModMetadata

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
options.compilerArgs << "-Xmaxerrs" << "9000"
}

tasks.register('sourceJar', Jar) {
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod_name=Cumulus
mod_version=1.1.0
mod_license=LGPL-3.0
mod_url=https://modrinth.com/mod/cumulus
mod_update=https://github.com/The-Aether-Team/Cumulus/raw/1.21.1-develop/update.json
mod_tracker=https://github.com/The-Aether-Team/Cumulus/issues
mod_credits=The Aether Team; kingbdogz, for the original Main Menu API that this is inspired by
mod_authors=bconlon
Expand All @@ -22,7 +23,7 @@ mod_description=A library for custom menu registration.
minecraft_version=1.21.1
minecraft_version_range=[1.21.1,1.21.2)

neogradle_version=7.0.145
moddevgradle_version=2.0.42-beta

neo_version=21.1.47
neo_version_range=[21.1.47,)
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion update.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"1.20.1-recommended": "1.20.1-1.0.0-neoforge",
"1.20.2-recommended": "1.20.2-1.0.1-neoforge",
"1.20.4-recommended": "1.20.4-1.0.1-neoforge",
"1.21-recommended": "1.21-1.0.4-neoforge"
"1.21.1-recommended": "1.21.1-1.1.0-neoforge"
}
}

0 comments on commit 438c5ba

Please sign in to comment.