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

Introduce disableToolchainDetection DSL property and fix toolchain handling in BaseNativeImageOptions #183

Closed
sdeleuze opened this issue Dec 18, 2021 · 3 comments · Fixed by #184
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@sdeleuze
Copy link
Collaborator

Unless I miss something, based on my tests with Liberica NIK only installed (but apply likely to GraalVM EE as well) and no GraalVM CE installation present locally (not easy because native-build-tools requires it to be built), even when applying disableToolchainDetection = true to BuildNativeImageTask implemented as part of #165 I get the following error:

> Task :nativeCompile FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':nativeCompile'.
> Error while evaluating property 'options.javaLauncher' of task ':nativeCompile'
   > Failed to query the value of property 'javaLauncher'.
      > No compatible toolchains found for request filter: {languageVersion=11, vendor=matching('GraalVM'), implementation=vendor-specific} (auto-detect true, auto-download true)

After a deeper analysis, I found that toolchain relate code in BaseNativeImageOptions need to be executed conditionally as well.

As a consequence, I propose to introduce disableToolchainDetection at DSL level (since it will be a popular option at least on Spring side for a while) to be able to just configure:

graalvmNative {
    disableToolchainDetection = true
}

And to apply it on both BaseNativeImageOptions and BuildNativeImageTask to be effective.

Be careful, to test you need to temporarily remove GraalVM CE from what is recognized by Gradle toolchain, for my tests I used Liberica NIK (available on SDKMAN) but GraalVM EE can also probably be used.

This issue is critical for Spring Native as it prevents Gradle users to use Liberica NIK which is now our default GraalVM distribution.

@sdeleuze sdeleuze added the bug Something isn't working label Dec 18, 2021
@sdeleuze sdeleuze added this to the 0.9.9 milestone Dec 18, 2021
@sdeleuze sdeleuze added the enhancement New feature or request label Dec 18, 2021
@sdeleuze sdeleuze changed the title Introduce disableToolchainDetection DSL property fix toolchain handling in BaseNativeImageOptions Introduce disableToolchainDetection DSL property and fix toolchain handling in BaseNativeImageOptions Dec 18, 2021
@melix
Copy link
Collaborator

melix commented Dec 20, 2021

I'm going to take a look, but the code you pointed at does the right thing: it's a convention so it doesn't mean that it will be used.

@sdeleuze
Copy link
Collaborator Author

I think it is used one way or another since when I remove it, #165 works as expected.

@melix
Copy link
Collaborator

melix commented Dec 20, 2021

It is used internally by Gradle to snapshot inputs, but the plugin doesn't use it, which is why it's messy. I'm working on a fix.

melix added a commit that referenced this issue Dec 20, 2021
Disabling the toolchain detection by tasks wasn't sufficient,
because Gradle would use the nested `BaseImageOptions` as an input,
and even if the particular `JavaLauchner` input wasn't used if that
flag was disabled, it would still be used internally by Gradle to
snapshot inputs.

As a consequence, the fix only worked if Gradle actually detected
a GraalVM installation somewhere, even if it didn't use it!

To fix this, this commit introduces a top-level DSL method called
`disableToolchainDetection()` which effectively sets the toolchain
to `null` by convention. By making the toolchain optional and null
now Gradle wouldn't complain anymore.

Fixes #183
melix added a commit that referenced this issue Dec 20, 2021
Disabling the toolchain detection by tasks wasn't sufficient,
because Gradle would use the nested `BaseImageOptions` as an input,
and even if the particular `JavaLauchner` input wasn't used if that
flag was disabled, it would still be used internally by Gradle to
snapshot inputs.

As a consequence, the fix only worked if Gradle actually detected
a GraalVM installation somewhere, even if it didn't use it!

To fix this, this commit introduces a top-level DSL method called
`disableToolchainDetection()` which effectively sets the toolchain
to `null` by convention. By making the toolchain optional and null
now Gradle wouldn't complain anymore.

Fixes #183
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants