Skip to content

Commit

Permalink
Switch from VanillaGradle and NeoGradle to ModDevGradle plugin (#3739)
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n authored Sep 4, 2024
1 parent f5574f0 commit fdfa13e
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 78 deletions.
9 changes: 5 additions & 4 deletions Common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
java
id("org.spongepowered.gradle.vanilla")
id("net.neoforged.moddev")
`maven-publish`
}

// gradle.properties
val jUnitVersion: String by extra
val minecraftVersion: String by extra
val neoformTimestamp: String by extra
val modId: String by extra
val modJavaVersion: String by extra

Expand All @@ -27,9 +28,9 @@ dependencyProjects.forEach {
project.evaluationDependsOn(it.path)
}

minecraft {
version(minecraftVersion)
// no runs are configured for Common
neoForge {
neoFormVersion = "$minecraftVersion-$neoformTimestamp"
addModdingDependenciesTo(sourceSets.test.get())
}

sourceSets {
Expand Down
8 changes: 4 additions & 4 deletions CommonApi/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
plugins {
java
id("org.spongepowered.gradle.vanilla")
id("net.neoforged.moddev")
`maven-publish`
}


// gradle.properties
val minecraftVersion: String by extra
val neoformTimestamp: String by extra
val modId: String by extra
val modJavaVersion: String by extra

Expand All @@ -15,9 +16,8 @@ base {
archivesName.set(baseArchivesName)
}

minecraft {
version(minecraftVersion)
// no runs are configured for Common API
neoForge {
neoFormVersion = "$minecraftVersion-$neoformTimestamp"
}

sourceSets {
Expand Down
9 changes: 4 additions & 5 deletions Gui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
java
id("org.spongepowered.gradle.vanilla")
id("net.neoforged.moddev")
`maven-publish`
}

// gradle.properties
val jUnitVersion: String by extra
val minecraftVersion: String by extra
val neoformTimestamp: String by extra
val modId: String by extra
val modJavaVersion: String by extra


val baseArchivesName = "${modId}-${minecraftVersion}-gui"
base {
archivesName.set(baseArchivesName)
Expand All @@ -29,9 +29,8 @@ dependencyProjects.forEach {
project.evaluationDependsOn(it.path)
}

minecraft {
version(minecraftVersion)
// no runs are configured for Gui
neoForge {
neoFormVersion = "$minecraftVersion-$neoformTimestamp"
}

sourceSets {
Expand Down
8 changes: 4 additions & 4 deletions Library/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent

plugins {
java
id("org.spongepowered.gradle.vanilla")
id("net.neoforged.moddev")
`maven-publish`
}

// gradle.properties
val jUnitVersion: String by extra
val minecraftVersion: String by extra
val neoformTimestamp: String by extra
val modId: String by extra
val modJavaVersion: String by extra

Expand All @@ -28,9 +29,8 @@ dependencyProjects.forEach {
project.evaluationDependsOn(it.path)
}

minecraft {
version(minecraftVersion)
// no runs are configured for Library
neoForge {
neoFormVersion = "$minecraftVersion-$neoformTimestamp"
}

sourceSets {
Expand Down
83 changes: 38 additions & 45 deletions NeoForge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import net.darkhax.curseforgegradle.TaskPublishCurseForge
import net.neoforged.gradle.dsl.common.runs.run.Run
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import net.darkhax.curseforgegradle.Constants as CFG_Constants
Expand All @@ -11,7 +10,7 @@ plugins {
id("maven-publish")
id("net.darkhax.curseforgegradle") version("1.0.8")
id("com.modrinth.minotaur") version("2.+")
id("net.neoforged.gradle.userdev")
id("net.neoforged.moddev")
}

// gradle.properties
Expand Down Expand Up @@ -56,15 +55,13 @@ dependencyProjects.forEach {
}
project.evaluationDependsOn(":Changelog")

val notNeoTask = { it: Task -> !it.name.startsWith("neo") }

tasks.withType<JavaCompile>().matching(notNeoTask).configureEach {
tasks.withType<JavaCompile>().configureEach {
dependencyProjects.forEach {
source(it.sourceSets.main.get().allSource)
}
}

tasks.withType<ProcessResources>().matching(notNeoTask).configureEach {
tasks.withType<ProcessResources>().configureEach {
dependencyProjects.forEach {
from(it.sourceSets.main.get().resources)
}
Expand All @@ -78,11 +75,6 @@ java {
}

dependencies {
implementation(
group = "net.neoforged",
name = "neoforge",
version = neoforgeVersion
)
dependencyProjects.forEach {
implementation(it)
}
Expand All @@ -98,43 +90,44 @@ dependencies {
)
}

minecraft {
accessTransformers {
file("src/main/resources/META-INF/accesstransformer.cfg")
}
}
neoForge {
version = neoforgeVersion
// MDG already defaults to this, but override it for clarity.
setAccessTransformers("src/main/resources/META-INF/accesstransformer.cfg")

fun commonRunProperties(run: Run) {
for (dependencyProject in dependencyProjects) {
run.modSources.add(project.name, dependencyProject.sourceSets.main.get())
}
}
addModdingDependenciesTo(sourceSets.test.get())

runs {
create("client") {
configure("client")
systemProperty("forge.logging.console.level", "debug")
workingDirectory(file("run/client/Dev"))
commonRunProperties(this)
}
create("client_01") {
configure("client")
workingDirectory(file("run/client/Player01"))
programArguments("--username", "Player01")
commonRunProperties(this)
}
create("client_02") {
configure("client")
workingDirectory(file("run/client/Player02"))
programArguments("--username", "Player02")
commonRunProperties(this)
mods {
create("jei") {
sourceSet(sourceSets.main.get())
for (dependencyProject in dependencyProjects) {
sourceSet(dependencyProject.sourceSets.main.get())
}
}
}
create("server") {
configure("server")
systemProperty("forge.logging.console.level", "debug")
workingDirectory(file("run/server"))
programArguments("nogui")
commonRunProperties(this)

runs {
create("client") {
client()
systemProperty("forge.logging.console.level", "debug")
gameDirectory = file("run/client/Dev")
}
create("client_01") {
client()
gameDirectory = file("run/client/Player01")
programArguments.addAll("--username", "Player01")
}
create("client_02") {
client()
gameDirectory = file("run/client/Player02")
programArguments.addAll("--username", "Player02")
}
create("server") {
server()
systemProperty("forge.logging.console.level", "debug")
gameDirectory = file("run/server")
programArguments.addAll("nogui")
}
}
}

Expand Down
17 changes: 5 additions & 12 deletions NeoForgeApi/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("java")
id("maven-publish")
id("net.neoforged.gradle.userdev")
id("net.neoforged.moddev")
}

// gradle.properties
Expand Down Expand Up @@ -47,22 +47,15 @@ java {
}

dependencies {
implementation(
group = "net.neoforged",
name = "neoforge",
version = neoforgeVersion
)
dependencyProjects.forEach {
implementation(it)
}
}

minecraft {
accessTransformers {
// All minecraft configurations in the multi-project must be identical, including ATs,
// because of a ForgeGradle bug https://github.com/MinecraftForge/ForgeGradle/issues/844
file("../Forge/src/main/resources/META-INF/accesstransformer.cfg")
}
neoForge {
version = neoforgeVersion
// We don't need the AT, but this allows MDG to share the recompiled Minecraft artifacts with the NeoForge project.
setAccessTransformers("../NeoForge/src/main/resources/META-INF/accesstransformer.cfg")
}

val sourcesJar = tasks.named<Jar>("sourcesJar")
Expand Down
6 changes: 2 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ plugins {
id("com.dorongold.task-tree") version("2.1.0")
// https://maven.fabricmc.net/fabric-loom/fabric-loom.gradle.plugin/
id("fabric-loom") version("1.7.3") apply(false)
// https://projects.neoforged.net/neoforged/neogradle
id("net.neoforged.gradle.userdev") version("7.0.162") apply(false)
// https://repo.spongepowered.org/service/rest/repository/browse/maven-public/org/spongepowered/gradle/vanilla/org.spongepowered.gradle.vanilla.gradle.plugin/
id("org.spongepowered.gradle.vanilla") version("0.2.1-SNAPSHOT") apply(false)
// https://projects.neoforged.net/neoforged/moddevgradle
id("net.neoforged.moddev") version("2.0.26-beta") apply(false)
}
apply {
from("buildtools/ColoredOutput.gradle")
Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ githubUrl=https://github.com/mezz/JustEnoughItems
# Minecraft
minecraftVersion=1.21.1
minecraftVersionRange=[1.21, 1.21.1)
# https://projects.neoforged.net/neoforged/neoform
neoformTimestamp=20240808.144430

minecraftExtraCompatibleVersion=1.21

Expand Down

0 comments on commit fdfa13e

Please sign in to comment.