Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Gretty aware of Gradle Java Toolchain (v4.x) #308

Merged
merged 3 commits into from
Jul 10, 2024

Conversation

mr-serjey
Copy link

Gretty plugin run containers as a separate java process using the same java that is used by Gradle.

However since Gradle introduced Toolchains for JVM projects, the expectation is that Gretty plugin will also respect the java toolchain DSL and run containers using the specified JDK instead of one that used by Gradle.

Currently if java toolchain DSL is declared in a project, the classes compiled by the JDK specified there (e.g. v21), at the same time Gretty plugin uses Gradle JDK (e.g. v11), as result the container fails to start since JVM v11 can't load classes of java v21.

This PR purposes changes into Gretty plugin to respect java toolchain DSL:

  • add ServerConfig.jvmExecutable String (optional value)
  • StartBaseTask sets ServerConfig.jvmExecutable (if java toolchain DSL specified)
  • DefaultLauncher sets JavaExecSpec.executable for Gradles javaexec to start the right java version (if jvmExecutable set)
  • If no toolchain DSL specified the default JavaExecParams.executable is used (Gradle JVM)

With the following DSL the project going to use java 21 both to compile classes and to run them in container using Gretty plugin:

build.gradle
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(21)
    }
}

Related issue: #261

Complementary changed of tests:

  • added tests for Gradle Java Toolchain functionality
  • added extra matrix cases in ci.yml to cover Gradle Java Toolchain functionality (Java 11+17 and java 17+21)
  • added docker_integration_tests.sh that runs all tests inside docker similarly to ci.yml (helped a lot locally on Windows machine)
  • migrated groovy classes of test applications into java, to avoid groovy bytecode incompatibility on high java versions

NOTE: This PR is a forward-port of v3.x PR #306

@boris-petrov boris-petrov requested a review from f4lco June 21, 2024 17:01
@mr-serjey
Copy link
Author

Hi @boris-petrov and @f4lco, please share your plans regarding this PR, are there any timeline for review, merge, release?

@boris-petrov
Copy link
Member

@mr-serjey sorry, I'll merge and release next week.

@boris-petrov boris-petrov merged commit 51b56f0 into gretty-gradle-plugin:master Jul 10, 2024
7 checks passed
@boris-petrov
Copy link
Member

@mr-serjey thanks again for that! I'll release it the end of this week or beginning of next.

@boris-petrov
Copy link
Member

Released! Thanks @mr-serjey!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants