beryx / badass-jlink-plugin

Create a custom runtime image of your modular application
https://badass-jlink-plugin.beryx.org
Apache License 2.0
386 stars 27 forks source link

update asm for Java 19 support #220

Closed xzel23 closed 1 year ago

xzel23 commented 2 years ago

fixes #219

ice1000 commented 2 years ago

Thanks!

xzel23 commented 2 years ago

Ah, so it seems it's not just updating the ASM. The plugin builds, tests pass, but it still didn't work with JDK 19. So I tried to update the dependencies and make everything work with JDK 19 and Gradle 7.3+. I think Groovy and I will never be real close friends. I could not make the changes in a way that maintains compatibility with Gradle versions 4, 5, 6. That might not be acceptable for @siordache.

Java 19 needs Gradle 7.3+, and I am no expert on this, but it seems that Gradle 7+ uses Groovy 3. So I have updated all plugins dependencies to current versions. I replaced the assembler with the one supplied by gradle. I think the original author decided to use an external asm to support newer JDK independent from older Gradle versions. However I could not get it to work and I really need a working plugin for JDK 19 and Gradle 7.3+ ASAP, so I took this route.

I also removed all @CompileStatic annotations from the plugin code as that seemed to solve some problems. It might not have been necessary, as I could only get the plugin to work in Gradle 7.3+.

I had to add a dependency for JUnit4 compatibility ("@Rule" etc) and had to add "useJUnitPlatform()" in the build file because tests were not found.

I have not yet tested the plugin with projects other than the supplied test projects. I will do ASAP and if it works, I might publish a Gradle7+ only version with other Gradle coordinates that might work for you.

I don't know if/when the original plugin will be updated, but this really seems to be much more complicated than I thought at first, so I think it might take some time. If the changes I made help in the process, I will be glad.

CodeDead commented 2 years ago

This looks like a pretty good change @xzel23 !

It seems like Gradle 7.6 will be the first version to support JDK 19: https://github.com/gradle/gradle/issues/20372

So Gradle 7.6+ will be needed in order to support JDK 19.

ice1000 commented 2 years ago

@CodeDead no, gradle can run on jdk 17 and build a project using another jdk which is jdk 19.

Gradle 7.6 will add support for running gradle on JDK 19, which is not needed.

xzel23 commented 2 years ago

@CodeDead You can run Gradle on Java 17 and compile using Java 19 if you use the toolchain support like this:

    java {
        toolchain { languageVersion.set(JavaLanguageVersion.of(19)) }
    }
CodeDead commented 2 years ago

@ice1000 & @xzel23 yes, but isn't this quite difficult to achieve with automated builds like GitHub Actions, Jenkins and the likes since you will need dual JDK's installed in your base image to achieve this? Just a note, that might be helpful for some struggling to get automated builds done.

ice1000 commented 2 years ago

@ice1000 & @xzel23 yes, but isn't this quite difficult to achieve with automated builds like GitHub Actions, Jenkins and the likes since you will need dual JDK's installed in your base image to achieve this? Just a note, that might be helpful for some struggling to get automated builds done.

One probably encounter the problem before realizing that badass jlink doesn't work with 19 lol

xzel23 commented 2 years ago

@CodeDead Gradle will automatically download the correct JDK for the build if it isn't installed on the system.

markusheiden commented 2 years ago

@xzel23 For automated builds Gradle would then automatically download and install some JDK for each build step of each build? Or is the downloaded JDK somehow cacheable?

octylFractal commented 2 years ago

See https://docs.gradle.org/current/userguide/toolchains.html#sec:provisioning

markusheiden commented 2 years ago

Thanks for the fast answer, that helped me make it work. One thing that is not mentioned there: Downloaded JDKs are cached in .gradle/jdks/. If adding that directory to the CI cache, JDK re-downloads can be avoided by subsequent build steps and builds.

Siedlerchr commented 1 year ago

Gradle's new version 7.6 now supports jdk19 as well

ice1000 commented 1 year ago

It's a shame that this PR is not receiving developers' input. We have a smol library that modifies the java bytecode's java major version so that badass jlink still thinks it's Java 17 (along with two more changes -- from java.lang.MatchException to java.lang.RuntimeException and the time stamp, to prevent breaking incremental compilation).

ice1000 commented 1 year ago

Ohh! That's great! I take it all back. Nice job!!

siordache commented 1 year ago

Thanks for the PR, @xzel23! Release 2.26.0 is out. Starting with this version, the plugin requires Gradle 7.0 or newer.

As you all noticed, I didn't have much time lately for this plugin. It would be great if some of you could help co-maintain it. I created an issue to keep track of this matter.

ice1000 commented 1 year ago

Thanks for the PR, @xzel23! Release 2.26.0 is out. Starting with this version, the plugin requires Gradle 7.0 or newer.

As you all noticed, I didn't have much time lately for this plugin. It would be great if some of you could help co-maintain it. I created an issue to keep track of this matter.

That's very sweet! 🆒🆒🆒

bxqgit commented 1 year ago

Finally! 🙄

xzel23 commented 1 year ago

@bxqgit I think we should be grateful and not post such comments. Providing and maintaining open source software can be a time consuming and tedious task, and it is most of the time unpaid. We all have our day jobs that we rely on to make a living. If you are unsatisfied with the progress, you can actively help by submitting your own PRs, or even step up and become a co-maintainer as @siordache recently asked for someone who could help out with this plugin. Or you could review PRs, and report or fix problems. Just replying "finally" is not motivating for the maintainer.

Don't get me wrong, I can understand your feeling. But blaming the maintainer is not the right thing to do.