Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
207 changes: 131 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 '6.+'
}
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 = false
}

repositories {
Expand All @@ -47,67 +62,77 @@ 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 +144,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.2864
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.
3 changes: 1 addition & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Mon Sep 14 12:28:28 PDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
Loading