diff --git a/build.gradle b/build.gradle index cbb72bcb..baa22d7a 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { @@ -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 { @@ -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 + } +} diff --git a/gradle.properties b/gradle.properties index 4c72820a..e7d72ade 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 30d399d8..e708b1c0 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5f06eb19..b4138734 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/gradlew b/gradlew index f48d5d06..4f906e0c 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -66,6 +82,7 @@ esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then @@ -76,12 +93,14 @@ if [ -n "$JAVA_HOME" ] ; then fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else JAVACMD="java" which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi @@ -107,10 +126,11 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath @@ -136,19 +156,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -157,14 +177,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 8a0b282a..107acd32 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -8,20 +24,23 @@ @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -35,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -45,34 +64,14 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..93f1b806 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,13 @@ +pluginManagement { + repositories { + gradlePluginPortal() + maven { + name = 'MinecraftForge' + url = 'https://maven.minecraftforge.net/' + } + } +} + +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0' +} \ No newline at end of file diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 65ebba07..cb06e894 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,11 +1,11 @@ [ { - "modid": "terraplusplus", - "name": "TerraPlusPlus", + "modid": "${mod_id}", + "name": "${mod_name}", "description": "A feature-rich fork of Terra121 focusing on performance.", - "version": "${version}", - "mcversion": "${mcversion}", - "url": "https://buildtheearth.net", + "version": "${mod_version}", + "mcversion": "${minecraft_version}", + "url": "${mod_url}", "updateUrl": "", "authorList": [ "DaPorkchop_", diff --git a/src/test/java/net/buildtheearth/terraplusplus/util/OrderedRegistryTest.java b/src/test/java/net/buildtheearth/terraplusplus/util/OrderedRegistryTest.java index a6ce20b0..e8a642d9 100644 --- a/src/test/java/net/buildtheearth/terraplusplus/util/OrderedRegistryTest.java +++ b/src/test/java/net/buildtheearth/terraplusplus/util/OrderedRegistryTest.java @@ -1,12 +1,13 @@ package net.buildtheearth.terraplusplus.util; +import org.junit.jupiter.api.Test; + import static net.daporkchop.lib.common.util.PValidation.checkState; import java.util.Arrays; import java.util.Map; import java.util.stream.Collectors; -import org.junit.Test; /** * @author DaPorkchop_ diff --git a/src/test/java/net/buildtheearth/terraplusplus/util/geo/CoordinateParseUtilsTest.java b/src/test/java/net/buildtheearth/terraplusplus/util/geo/CoordinateParseUtilsTest.java index 116d348d..10146ba8 100644 --- a/src/test/java/net/buildtheearth/terraplusplus/util/geo/CoordinateParseUtilsTest.java +++ b/src/test/java/net/buildtheearth/terraplusplus/util/geo/CoordinateParseUtilsTest.java @@ -1,9 +1,9 @@ package net.buildtheearth.terraplusplus.util.geo; -import org.junit.Assert; -import org.junit.Test; -import static org.junit.Assert.*; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; /** * @author SmylerMC @@ -111,11 +111,11 @@ public void testInvalid() { private void testValidStringParsing(String string, double longitude, double latitude) { LatLng latLng = CoordinateParseUtils.parseVerbatimCoordinates(string); - Assert.assertNotNull(String.format("Failed to parse a valid coordinate string: %s", string), latLng); + assertNotNull(latLng, String.format("Failed to parse a valid coordinate string: %s", string)); final double lng = latLng.getLng(); final double lat = latLng.getLat(); - Assert.assertEquals("Parsed a wrong longitude value", longitude, lng, PRECISION); - Assert.assertEquals("Parsed a wrong latitude value", latitude, lat, PRECISION); + assertEquals(longitude, lng, PRECISION, "Parsed a wrong longitude value"); + assertEquals(latitude, lat, PRECISION, "Parsed a wrong latitude value"); } private void testInvalidStringParsing(String string) {