spark

spark

26M Downloads

Build for Java 15

TilBlechschmidt opened this issue ยท 5 comments

commented

Hi there,
I am running a modded server (FTB OceanBlock, MC 1.16.5) and would like to profile some performance issues (see OceanBlock Issue #211).

However, spark seems to be compiled with Java 16. The modded server only runs up to Java 15 and crashes when attempting to start it with Java 16. Running spark on v15 throws this exception:

net.minecraftforge.fml.LoadingFailedException: Loading errors encountered: [
	spark has class loading errors
?7java.lang.UnsupportedClassVersionError: me/lucko/spark/forge/ForgeSparkMod has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 59.0
]

I've looked around but could not find older versions of spark to use ๐Ÿ˜ข

Spark Version: Forge
Java Versions: OpenJDK 8, 15, 16

commented

I attempted to build the project on my own, however, due to the lack of documentation and my limited gradle knowledge, I did eventually get stuck.

git clone https://github.com/lucko/spark
cd spark

Then I had to change the include block in the settings.gradle to this because fabric apparently requires Java 16:

include (
        'spark-api',
        'spark-common',
        // 'spark-bukkit',
        // 'spark-bungeecord',
        // 'spark-velocity',
        // 'spark-velocity4',
        // 'spark-sponge',
        // 'spark-sponge8',
        'spark-forge',
        // 'spark-forge1122',
        // 'spark-fabric',
        // 'spark-nukkit',
        // 'spark-waterdog',
        // 'spark-universal'
)

Then, to get it to compile with Java 8, the following lines in spark-forge/build.gradle had to be changed:

java {
    toolchain {
        // override, compile targeting J16
        languageVersion = JavaLanguageVersion.of(8) // <- this is set to 8 instead of 16
    }
}

Finally, the project could be built in Docker using the following commands:

docker run --rm -it -v $(pwd):/spark gradle:jdk8 /bin/bash
cd /spark
./gradlew clean build

Or rather, it couldn't. Gradle failed with the following error:

> Configure project :spark-forge
WARNING: This project is configured to use the official obfuscation mappings provided by Mojang. These mapping fall under their associated license, you should be fully aware of this license. For the latest license text, refer below, or the reference copy here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md, You can hide this warning by running the `hideOfficialWarningUntilChanged` task
WARNING: (c) 2020 Microsoft Corporation. These mappings are provided "as-is" and you bear the risk of using them. You may copy and use the mappings for development purposes, but you may not redistribute the mappings complete and unmodified. Microsoft makes no warranties, express or implied, with respect to the mappings provided here.  Use and modification of this document or the source code (in any form) of Minecraft: Java Edition is governed by the Minecraft End User License Agreement available at https://account.mojang.com/documents/minecraft_eula.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':spark-forge'.
> The java toolchain language version of 8 is below the required minimum of 16.
  You must have a line which looks like this in your buildscript:
      java.toolchain.languageVersion = JavaLanguageVersion.of(16)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 1s
commented

Using this workflow:

git clone https://github.com/lucko/spark
cd spark
git checkout a9a639c

docker run --rm -it -v $(pwd):/spark gradle:jdk8 /bin/bash
cd /spark
gradle clean build

I had to make these changes to the repo for it to work:

diff --git a/build.gradle b/build.gradle
index 88afbd6..89fc531 100644
--- a/build.gradle
+++ b/build.gradle
@@ -18,7 +18,7 @@ subprojects {
     }
 
     compileJava {
-        options.compilerArgs.addAll(['--release', '8'])
+        // options.compilerArgs.addAll(['--release', '8'])
     }
 
     tasks.withType(JavaCompile) {
diff --git a/settings.gradle b/settings.gradle
index b47da02..cf55474 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -13,15 +13,15 @@ rootProject.name = 'spark'
 include (
         'spark-api',
         'spark-common',
-        'spark-bukkit',
-        'spark-bungeecord',
-        'spark-velocity',
-        'spark-velocity2',
-        'spark-sponge',
-        'spark-sponge8',
+        // 'spark-bukkit',
+        // 'spark-bungeecord',
+        // 'spark-velocity',
+        // 'spark-velocity2',
+        // 'spark-sponge',
+        // 'spark-sponge8',
         'spark-forge',
-        'spark-forge1122',
-        'spark-fabric',
-        'spark-nukkit',
-        'spark-universal'
+        // 'spark-forge1122',
+        // 'spark-fabric',
+        // 'spark-nukkit',
+        // 'spark-universal'
 )

While the build succeeded, it is a version from the beginning of the year. Especially for other people to use, it would be neat to have this available as a pre-compiled latest version to download. Considering that FTB modpacks mostly run on Java 8 and can't run Java 16+, it might be nice to have ๐Ÿ™‚

For future reference, here is the compiled JAR which works with FTB OceanBlock running on Java 8.
spark-forge.jar.zip

commented

@Raidobw2 made me aware that a 1.16.5 compatible version is available on CurseForge (thanks!). My bad for not checking there. Regardless, it might be worthwhile to include that reference on the downloads page ๐Ÿ™‚

(Even though the OG issue has been resolved, I'll leave this ticket open for you to see and maybe add a reference to CurseForge or something to your site)

commented

The version of spark in the Git repository targets Minecraft 1.17, which bumped the minimum Java version to 16. :)

It is intended that Java 16+ is required for these versions of spark to run.

commented

And yes, you're correct in saying the 1.6.0 Forge release of spark supports down to Java 8 - if you need a release that far back, then just download from there: https://www.curseforge.com/minecraft/mc-mods/spark/files/3337641