PrisonTeam / Prison

The home of the Prison project, a Minecraft plugin to provide mining and ranking gameplay experience.
https://www.spigotmc.org/resources/prison.1223/
Other
127 stars 51 forks source link

Building with Java 21 doesn't work #261

Closed GogleSiteBank closed 4 months ago

GogleSiteBank commented 7 months ago

replicate: run gradlew, unsupported version

rbluer commented 5 months ago

This is not an issue of concern.

Prison is built to be backwards compatible with spigot 1.8.x and also support the latest spigot release 1.20.x and newer.

Therefore, prison is intended to be built with Java 1.8 to ensure that compatibility with spigot 1.8.x. Newer versions of Java are not supported since the backwards compatibility is a higher priority.

Jars that are generated with Java 1.8.x are always compatible with newer releases of java, such as Java 21.

Therefore, this is not an issue and it is not a bug.

rbluer commented 5 months ago

I'm sorry... are you a real person? From your name, it sounded like you were an automated bot?

If you are a person, I think I better understand your concerns.

Overall, prison is built with java 1.8, and must continue to do so.

But I'll have to take a look at gradle to see what the options are for running gradle's latest release, but the result must still be compatible with Java 1.8.

rbluer commented 5 months ago

I'm removed the tags 'invalid' and 'unsupported' from this issue.

The concern that I'm seeing with trying to build with java 17, which presents the same issues with using java 21, would be that the gradle configs are set for Java 8.

I'm going to explore using gradle's newer libs.versions.toml file support, which can set global versions for all sub-projects. This allows the changing of the versions in one location, instead of updating all sub-module settings. This won't solve the problem with Java 17 and 21 support, but I'm planning on performing the same config setup for the java version tool chains. At this point, many sub-project gradle config files will need to be altered to change the java versions.

I'll also explore to see if I can setup multiple tool chains to support the different versions of java too. This will then require the gradlew to be ran in a different way, but it may allow dynamic support for different java versions.

I'm not sue what the ETA is on this. I will try to address this as time permits since I'd like to get it resolved too.

I know this topic is rebuilding prison, using gradle with a newer version of Java, but the existing Java 1.8 jars should work if used to compile against when using java 17 or java 21.

Since java 1.8 is a currently support version of Java, the simple solution is to install the latest release of Java 1.8 and then gradle will be able to perform a build of prison, automatically using the discovered java 1.8

rbluer commented 5 months ago

I think actually, now that I think about it, the issue you're having really is all about gradle not being able to find a java 1.8 instance on your system.

The actual solution to your problem would be for you to install the latest Java JDK-1.8, since that will include all of the latest security patches.

If I get prison to successfully compile for java 17 and 21, the gradle configs will NOT be set to either 17 or 21. They will remain at 1.8. So ideally, if you want a 17 or 21 build, you would have to modify that to be added gradle/libs.versions.toml file.

rbluer commented 4 months ago

I'm closing this issue because it's not an issue with prison.

I've been doing more work with Gradle and realized that Gradle will run with your default version of Java, which is Java 21.

But since Prison must be built with Java 1.8, in the build script it specifies that 1.8 must be used, so Gradle will try to find an 1.8 instance on your system. If it finds it, it will use it.

If Gradle cannot find a Java 1.8 instance, then it will try to provision 1.8. The process can become rather complex, but there is a chain of command that gradle uses to find a suitable java version, and then will download it.

But things have changed in the newer versions of Gradle. Gradle will no longer auto-provision needed build environments, such as a JDK 1.8 environment. It will use what can be found locally, or for external sources that are defined within the build script, but it will automatically go out and pull resources anymore.

Prison does not specify any sources for Java 1.8 since that's a choice left up to those who are trying to build prison.

So, getting back to your original concern about prison is not able to be built with Java 21... that is correct. Gradle will run under Java 21, but it will have to use a local instance of Java 1.8. So the solution to your issue is that you need to install a latest release of java 1.8 an then gradle will be able to find it, and use it.