Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b0c693c
Update Gradle wrapper to 5.6.4
SmylerMC Jul 19, 2026
f9d71be
Update to ForgeGradle 3
SmylerMC Jul 20, 2026
c3b3c4a
Explicitly tell FML to load the CC coremods
SmylerMC Jul 20, 2026
33cc0d5
Update Gradle wrapper to 6.8.1
SmylerMC Jul 20, 2026
0907837
Update ForgeGradle to v4
SmylerMC Jul 20, 2026
4540a96
build.gradle: temporarily remove shadow plugin
SmylerMC Jul 21, 2026
cc8a799
build.gradle: temporarily remove resource processing
SmylerMC Jul 21, 2026
6b037f7
gradlew: update to 8.14.5
SmylerMC Jul 21, 2026
373ef5d
build.gradle: update ForgeGradle to v6
SmylerMC Jul 21, 2026
6074f03
build.gradle: update JUnit to v5
SmylerMC Jul 21, 2026
86f9ad3
build.gradle: refactor ForegeGradle runs
SmylerMC Jul 21, 2026
93c76ef
gradle: move versions to gradle.properties
SmylerMC Jul 21, 2026
26bea0b
gradle: re-introduce resource processing
SmylerMC Jul 21, 2026
5c9b50a
gradle: align with modern Forge project templates
SmylerMC Jul 22, 2026
f370ce8
gradle: fix the mod not loading when running the game from gradle tasks
SmylerMC Jul 25, 2026
ef35678
gradle: add workaround for mixin platform compat shenigans
SmylerMC Jul 25, 2026
73544f5
wip: gradle: downgrade build chain
SmylerMC Jul 25, 2026
fdc9d1e
http: make client testable
SmylerMC Jul 25, 2026
7eed648
http: fix cache refreshes with Is-Modified-Since
SmylerMC Jul 26, 2026
0bed1c2
http: test and log retries for early-closed connections
SmylerMC Jul 26, 2026
4408acc
http: dumb http retry mechanism
SmylerMC Jul 26, 2026
e2cd570
http: fix field and metods visibilities in HTTP client
SmylerMC Jul 26, 2026
188065f
http: limit retries
SmylerMC Jul 26, 2026
e0001bc
http: add exponential backoff to retries
SmylerMC Jul 26, 2026
f00e69a
http: add jitter factor to retry delay
SmylerMC Jul 26, 2026
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
209 changes: 133 additions & 76 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,42 +1,57 @@
buildscript {
repositories {
maven {
name = "Gradle Plugins"
url = "https://plugins.gradle.org/m2/"
}
maven {
name = "Minecraft Forge"
url = "https://files.minecraftforge.net/maven"
}
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
classpath "com.github.jengelman.gradle.plugins:shadow:4.0.0"
}
plugins {
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'net.minecraftforge.gradle' version '5.1.74'
}
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "maven-publish"

version = "1.1.0." + ('git rev-list --count HEAD'.execute().text.trim()) + "-1.12.2"
version = "${mod_version_base}." + ('git rev-list --count HEAD'.execute().text.trim()) + "-${minecraft_version}"
group = "net.buildtheearth"
archivesBaseName = "terraplusplus"

compileJava {
sourceCompatibility = targetCompatibility = "1.8"
base {
archivesName = mod_id
}

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

println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}"
minecraft {
version = "1.12.2-14.23.5.2847"
runDir = "run"
mappings channel: mapping_channel, version: mapping_version

runs {
configureEach {
workingDirectory project.file('run')

// Log4J log level for stdout
property 'forge.logging.console.level', 'debug'

// FML debugging info dumps (comma-separated list)
// - "SCAN": For mods scan.
// - "REGISTRIES": For firing of registry events.
// - "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'SCAN'

// Handle coremods:
// - instruct FML to load the CC and CWG coremods as it doesn't know how to find them in the ForgeGradle 3+ dev environment
// - instruct Mixin to not use obfuscated names in the deobfuscated dev environment
property 'fml.coreMods.load', 'io.github.opencubicchunks.cubicchunks.core.asm.coremod.CubicChunksCoreMod,io.github.opencubicchunks.cubicchunks.cubicgen.asm.coremod.CubicGenCoreMod'
property 'mixin.env.disableRefMap', 'true'
}

client { }

mappings = "stable_39"
makeObfSourceJar = false
server {
args 'nogui'
}
}
}

configurations {
shade
compile.extendsFrom shade
// RetroGradle compatibility options for Minecraft < 1.13 support on ForgeGradle 3+.
// All enabled by default since FG detects Minecraft 1.12.2.
legacy {
// Doesn't play well with ForgeGradle 6 and the latest Forge version in runClient/runServer
// (adds the jar to the classpath instead of the compiled classes, but doesn't generate the JAR...).
// Things work well when it is disabled.
fixClasspath = true
}

repositories {
Expand All @@ -47,67 +62,79 @@ repositories {
}

dependencies {
//We have to use this as deobfProvided even though there's a :dev version of the artifact because otherwise mixin
//prevents the mod from loading when running in a dev environment.
deobfProvided ("io.github.opencubicchunks:cubicchunks:1.12.2-0.0.1282.0-SNAPSHOT") {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"

implementation "org.projectlombok:lombok:${lombok_version}"
annotationProcessor "org.projectlombok:lombok:${lombok_version}"

// We have to explicitly deobfuscate this instead of using the :dev version of the artifact because otherwise mixin
// prevents the mod from loading when running in a dev environment.
implementation fg.deobf("io.github.opencubicchunks:cubicchunks:${cubicchunks_version}") {
transitive = false
}

provided ("io.github.opencubicchunks:cubicworldgen:1.12.2-0.0.206.0-SNAPSHOT:dev") {
implementation("io.github.opencubicchunks:cubicworldgen:${cubicworldgen_version}:dev") {
transitive = false
}

shade "org.apache.commons:commons-imaging:1.0.0-alpha5"

shade "com.fasterxml.jackson.core:jackson-databind:2.11.2"

shade("net.daporkchop.lib:binary:0.5.7-SNAPSHOT") {
implementation "org.apache.commons:commons-imaging:${apache_commons_imaging_version}"
implementation "com.fasterxml.jackson.core:jackson-databind:${jackson_version}"
implementation("net.daporkchop.lib:binary:${porklib_version}") {
exclude group: "io.netty"
}

testCompile "junit:junit:4.12"

compile "org.projectlombok:lombok:1.18.16"
annotationProcessor "org.projectlombok:lombok:1.18.16"
testImplementation(platform("org.junit:junit-bom:${junit_version}"))
testImplementation('org.junit.jupiter:junit-jupiter')
testRuntimeOnly('org.junit.platform:junit-platform-launcher')
}

processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version

// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
eclipse {
synchronizationTasks 'genEclipseRuns'
}

// replace version and mcversion
expand 'version': project.version, 'mcversion': project.minecraft.version
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}

// copy everything else except the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [
minecraft_version: minecraft_version,
mod_id: mod_id,
mod_name: mod_name,
mod_url: mod_url,
mod_version: project.version,
]
inputs.properties replaceProperties

filesMatching(['mcmod.info', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
}
}

shadowJar {
classifier = null
configurations = [project.configurations.shade]

exclude 'module-info.class'
tasks.named('jar', Jar).configure {
manifest {
attributes([
'Specification-Title' : mod_id,
'Specification-Version' : project.version,
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
])
}
}
build.dependsOn shadowJar

reobf { //reobfuscate the shaded JAR
shadowJar {}
/*
sourceSets.each '{
def dir = layout.buildDirectory.dir("sourcesSets/$it.name")
it.output.resourcesDir = dir
it.java.destinationDirectory = dir
}
*/

//relocate all shaded dependencies
task relocateShadowJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = "net.buildtheearth.terraplusplus.dep"
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
shadowJar.dependsOn relocateShadowJar

publishing {
publications {
Expand All @@ -119,12 +146,42 @@ publishing {
from components.java

artifacts.clear()
artifact(shadowJar) {
classifier = ""
}
artifact sourceJar {
classifier "sources"
}
}
}
}

tasks.register('forgeGradleMixinCacheCompatibilityHack') {
group 'FG compatibility hacks'
description 'Renames the ForgeGradle v3+ deobfuscated dependency cache to the name used by ForgeGradle v2 and symlinks the modern name, so that MixinPlatformAgentFMLLegacy properly qualifies those dependencies.'

doLast {
def fgCacheDir = file("${gradle.gradleUserHomeDir}/caches/forge_gradle")
def oldDir = file("${fgCacheDir}/deobf_dependencies")
def newDir = file("${fgCacheDir}/deobfedDeps")

if (!oldDir.exists() || !oldDir.isDirectory()) {
println "ForgeGradle 3+ deobfuscated dependency cache not found at: ${oldDir}"
return
}
println "Found ForgeGradle 3+ deobfuscated dependency cache at at: ${oldDir}"

if (newDir.exists()) {
println "ForgeGradle 2 deobfuscated dependency already exists at: ${oldDir}, nothing to do"
return
}
println "Will move cache to ForgeGradle 2 location at: ${newDir}"

try {
oldDir.renameTo(newDir)
java.nio.file.Files.createSymbolicLink(oldDir.toPath(), newDir.toPath())
println "Hacky workaround for MixinPlatformAgentFMLLegacy installed"
} catch (Exception e) {
throw new GradleException("Failed to create required symlink", e)
}
}
}
afterEvaluate {
tasks.named('prepareRuns') {
dependsOn forgeGradleMixinCacheCompatibilityHack
}
}
26 changes: 26 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,29 @@ org.gradle.jvmargs=-Xmx3G

# workaround: https://www.abrarsyed.com/ForgeGradleVersion.json doesn't have a valid SSL certificate any more
net.minecraftforge.gradle.disableUpdateChecker=true

# Platform versions (Minecraft, Minecraft Forge & obfuscation mappings)
minecraft_version=1.12.2
forge_version=14.23.5.2855
mapping_channel=stable
mapping_version=39-1.12

# Build time dependencies
lombok_version=1.18.16

# Mod dependency versions (CubicChunks & CubicWorldGen)
cubicchunks_version=1.12.2-0.0.1282.0-SNAPSHOT
cubicworldgen_version=1.12.2-0.0.206.0-SNAPSHOT

# Library dependencies
apache_commons_imaging_version=1.0.0-alpha5
jackson_version=2.11.2
porklib_version=0.5.7-SNAPSHOT

# Test dependency versions
junit_version=5.14.4

mod_id=terraplusplus
mod_name=TerraPlusPlus
mod_version_base=1.1.0
mod_url=https://buildtheearth.net
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Sep 14 12:28:28 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
Loading