Skip to content

Commit

Permalink
create 1.21.1 branch and update to use MDG instead of vanilla gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticdrew committed Oct 8, 2024
1 parent bbf6bba commit d9dccdf
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 51 deletions.
12 changes: 11 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id "org.jetbrains.gradle.plugin.idea-ext" version "1.1.7"
id 'net.neoforged.moddev' version '1.0.11' apply false
}


subprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
Expand Down Expand Up @@ -54,6 +56,14 @@ subprojects {
it.options.getRelease().set(21)
}

tasks.withType(Javadoc).configureEach {
source(project(":common").sourceSets.main.allJava)
}

tasks.named("sourcesJar", Jar) {
from(project(":common").sourceSets.main.allSource)
}

// Disables Gradle's custom module metadata from being published to maven. The
// metadata includes mapped dependencies which are not reasonably consumable by
// other mod developers.
Expand Down
32 changes: 20 additions & 12 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
plugins {
id 'idea'
id 'java'
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
id 'net.neoforged.moddev'
id 'maven-publish'
}

version = "${project.version}-${project.minecraft_version}"
group = project.group_id
archivesBaseName = "${project.base_name}" + "-common"

minecraft {
version(minecraft_version)
runs {
if (project.hasProperty('common_runs_enabled') ? project.findProperty('common_runs_enabled').toBoolean() : true) {
test {
useJUnitPlatform()
}

server(project.hasProperty('common_server_run_name') ? project.findProperty('common_server_run_name') : 'vanilla_server') {
workingDirectory(this.file("run"))
}
client(project.hasProperty('common_client_run_name') ? project.findProperty('common_client_run_name') : 'vanilla_client') {
workingDirectory(this.file("run"))
}
}
neoForge {
neoFormVersion = neo_form_version
// Automatically enable AccessTransformers if the file exists
// While this location can be changed, it is recommended for
// common and neoforge to share an accesstransformer file
// and this location is hardcoded in FML
// https://github.com/neoforged/FancyModLoader/blob/a952595eaaddd571fbc53f43847680b00894e0c1/loader/src/main/java/net/neoforged/fml/loading/moddiscovery/ModFile.java#L118
def at = file('src/main/resources/META-INF/accesstransformer.cfg')
if (at.exists()) {
accessTransformers.add(at.absolutePath)
}
addModdingDependenciesTo(sourceSets["test"])
parchment {
minecraftVersion = mappings_mc_version
mappingsVersion = mappings_date
}
}

Expand Down
19 changes: 14 additions & 5 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_api_version}"

compileOnly group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.1'

Expand Down Expand Up @@ -83,7 +83,7 @@ task processDocs(type: Copy) {
expand 'version': project.version,
'date': getDate(),
'mcversion': project.minecraft_version,
'loaderversion': project.fabric_version,
'loaderversion': project.fabric_api_version,
'loadername': "Fabric"
}
into "$project.buildDir/doc"
Expand All @@ -98,8 +98,17 @@ processResources {
}
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
source(project(":common").sourceSets.main.allSource)
options.encoding = "UTF-8"
}

tasks.withType(Javadoc).configureEach {
source(project(":common").sourceSets.main.allJava)
}

tasks.named("sourcesJar", Jar) {
from(project(":common").sourceSets.main.allSource)
}

publishing {
Expand Down Expand Up @@ -141,7 +150,7 @@ task publishCurseForge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge)
mainFile.releaseType = release_type
mainFile.addModLoader("Fabric", "Quilt")
mainFile.addJavaVersion("Java 21")
mainFile.addGameVersion("${project.minecraft_version}","1.21.1")
mainFile.addGameVersion("${project.minecraft_version}")
mainFile.changelogType = "html"
mainFile.changelog = file("$project.buildDir/doc/changelog.html")
}
Expand All @@ -156,7 +165,7 @@ modrinth {
versionName = "${archivesBaseName}-${version}"
versionType = release_type
uploadFile = remapJar
gameVersions = ["${project.minecraft_version}","1.21.1"]
gameVersions = ["${project.minecraft_version}"]
loaders = ["fabric", "quilt"]
changelog = file("$project.buildDir/doc/changelog.html").exists() ? file("$project.buildDir/doc/changelog.html").text : null
}
14 changes: 11 additions & 3 deletions forge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,18 @@ dependencies {
compileOnly project(":common")
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
source(project(":common").sourceSets.main.allSource)
options.encoding = "UTF-8"
}

tasks.withType(Javadoc).configureEach {
source(project(":common").sourceSets.main.allJava)
}

tasks.named("sourcesJar", Jar) {
from(project(":common").sourceSets.main.allSource)
}
processResources {
from project(":common").sourceSets.main.resources
}
Expand Down Expand Up @@ -182,7 +190,7 @@ task publishCurseForge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge)
mainFile.releaseType = release_type
mainFile.addModLoader("Forge")
mainFile.addJavaVersion("Java 21")
mainFile.addGameVersion("${project.minecraft_version}","1.21.1")
mainFile.addGameVersion("${project.minecraft_version}")
mainFile.changelogType = "html"
mainFile.changelog = file("$project.buildDir/doc/changelog.html")
}
Expand All @@ -196,7 +204,7 @@ modrinth {
versionName = "${archivesBaseName}-${version}"
versionType = release_type
uploadFile = jar
gameVersions = ["${project.minecraft_version}","1.21.1"]
gameVersions = ["${project.minecraft_version}"]
loaders = ["forge"]
changelog = file("$project.buildDir/doc/changelog.html").exists() ? file("$project.buildDir/doc/changelog.html").text : null
}
Expand Down
15 changes: 10 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@ group_id=mysticdrew
curseforge_project_id=806044
modrinth_project_id=HIuqnQpi

mappings_mc_version=1.21
mappings_date=2024.07.28

# Common
minecraft_version=1.21
minecraft_version=1.21.1

# Forge
forge_version=51.0.0
forge_version=52.0.16

#neoforge
neoforge_version=21.0.0-beta
neoforge_version=21.1.65
# https://projects.neoforged.net/neoforged/neoform
neo_form_version=1.21.1-20240808.144430

# Fabric
fabric_version=0.100.1+1.21
fabric_loader_version=0.15.11
fabric_api_version=0.105.0+1.21.1
fabric_loader_version=0.16.5

# Mod options
mod_name=Common Networking
Expand Down
68 changes: 43 additions & 25 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ plugins {
id 'idea'
id 'java'
id 'maven-publish'
id 'net.neoforged.gradle.userdev' version '[7.0.145]'
id 'net.neoforged.moddev'
id 'net.darkhax.curseforgegradle' version '1.+'
}

Expand All @@ -36,43 +36,61 @@ tasks.withType(GenerateModuleMetadata) {
enabled = false
}

runs {
configureEach {
systemProperty 'forge.logging.markers', 'REGISTRIES'
systemProperty 'mixin.debug.export', 'true'
systemProperty 'forge.logging.console.level', 'info'
systemProperty 'journeymap.map_testing', 'true'
// ideaModule "${rootProject.name}.${project.name}.main"
modSource project.sourceSets.main
neoForge {
version = neoforge_version
// Automatically enable neoforge AccessTransformers if the file exists
def at = project(':common').file('src/main/resources/META-INF/accesstransformer.cfg')
if (at.exists()) {
accessTransformers.add(at.absolutePath)
}

client {
workingDirectory project.file('run/client')
// taskName 'Client'
addModdingDependenciesTo(sourceSets["test"])
parchment {
minecraftVersion = mappings_mc_version
mappingsVersion = mappings_date
}

server {
workingDirectory project.file('run/server')
// taskName 'Server'
runs {
configureEach {
// systemProperty('neoforge.enabledGameTestNamespaces', mod_id)
ideName = "NeoForge ${it.name.capitalize()} (${project.path})" // Unify the run config names with fabric
jvmArgument("-Dmixin.debug.export=true")
}
client {
client()
gameDirectory = project.file('run/client')
}
server {
server()
gameDirectory = project.file("run/server")
}
}
mods {
"${mod_id}" {
sourceSet sourceSets.main
}
}
}


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

dependencies {
implementation "net.neoforged:neoforge:${project.neoforge_version}"
compileOnly project(":common")
}

//tasks.withType(JavaCompile).matching {name != "neoforge"}.configureEach {
// source(project(":common").sourceSets.main.allSource)
//}

tasks.named('compileJava', JavaCompile).configure {
tasks.withType(JavaCompile).configureEach {
source(project(":common").sourceSets.main.allSource)
options.encoding = "UTF-8"
}

tasks.withType(Javadoc).configureEach {
source(project(":common").sourceSets.main.allJava)
}

tasks.named("sourcesJar", Jar) {
from(project(":common").sourceSets.main.allSource)
}


processResources {
from project(":common").sourceSets.main.resources
}
Expand Down Expand Up @@ -151,7 +169,7 @@ task publishCurseForge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge)
mainFile.releaseType = release_type
mainFile.addModLoader("NeoForge")
mainFile.addJavaVersion("Java 21")
mainFile.addGameVersion("${project.minecraft_version}","1.21.1")
mainFile.addGameVersion("${project.minecraft_version}")
mainFile.changelogType = "html"
mainFile.changelog = file("$project.buildDir/doc/changelog.html")
}
Expand All @@ -165,7 +183,7 @@ modrinth {
versionName = "${archivesBaseName}-${version}"
versionType = release_type
uploadFile = jar
gameVersions = ["${project.minecraft_version}","1.21.1"]
gameVersions = ["${project.minecraft_version}"]
loaders = ["neoforge"]
changelog = file("$project.buildDir/doc/changelog.html").exists() ? file("$project.buildDir/doc/changelog.html").text : null
}
Expand Down

0 comments on commit d9dccdf

Please sign in to comment.