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

Add an artifact that downloads GraalVM and Native Image #100

Open
lazar-mitrovic opened this issue Jul 9, 2021 · 20 comments
Open

Add an artifact that downloads GraalVM and Native Image #100

lazar-mitrovic opened this issue Jul 9, 2021 · 20 comments
Assignees
Labels
discussion enhancement New feature or request

Comments

@lazar-mitrovic
Copy link
Collaborator

It can be a bit tricky for the end users to download and configure GraalVM. We can automate this process by providing an artifact that downloads and configures GraalVM and Native Image.

This artifact would be invoked by both Gradle and Maven plugins and would be configurable trough them (by specifying version, distribution, and/or even the URL) using extensions and configuration options.

Note that Windows support for this might be a bit harder (but certainly doable).

@lazar-mitrovic lazar-mitrovic added enhancement New feature or request discussion labels Jul 9, 2021
@lazar-mitrovic lazar-mitrovic changed the title Add a artifact that downloads GraalVM and Native Image Add an artifact that downloads GraalVM and Native Image Jul 9, 2021
@graemerocher
Copy link
Collaborator

Gradle already supports the notion of tool chains which this should support imo

@melix
Copy link
Collaborator

melix commented Jul 12, 2021

I totally agree that we should provide a more build-tool friendly API to fetch a GraalVM build with native image preinstalled. Gradle's toolchain mechanism is two fold:

  1. it can identify JDK installations in "well-known" places: from $PATH, from OS specific paths (/usr/lib/..) or from common tools which are able to install JDKs by themselves (e.g SDKMan!).
  2. if no suitable JDK is found, it tries to download a compatible version from AdoptOpenJDKhttps://docs.gradle.org/current/userguide/toolchains.html#sec:provisioning

For both, there is a problem with GraalVM:

In 1., the problem is that even if you identify a GraalVM toolchain, there's no guarantee that the native-image tool would be installed. There should be a way to get a GraalVM SDK with the native image tool preinstalled.

For 2., the automatic provisioning is optional in Gradle. It uses the AdoptOpenJDK API to do this, but Gradle can be configured to use a different base URL for the download service. It means that GraalVM could provide an AdoptOpenJDK compatible API service to supply JDKs. It should be relatively easy to do so. Note that the API itself has nothing specific to Adopt. It can be used by any other vendor. However, again, what would be downloaded would have to come with native-image preinstalled to be build tool friendly.

@melix
Copy link
Collaborator

melix commented Aug 13, 2021

Related: gradle/gradle#18028

@sbrannen
Copy link
Collaborator

@lazar-mitrovic
Copy link
Collaborator Author

Related Gradle Roadmap entry: gradle/build-tool-roadmap#29

@sschuberth
Copy link

It can be a bit tricky for the end users to download and configure GraalVM. We can automate this process by providing an artifact that downloads and configures GraalVM and Native Image.

Agreed. For Gradle, that's basically the only reason why we're using https://github.com/palantir/gradle-graal in https://github.com/oss-review-toolkit/ort rather than the Gradle plugin from this repo. I'm really hoping for gradle/gradle#18028 to land soon (it's scheduled for Gradle 7.6 currently) to address the matter generically in Gradle itself.

@frank-dspeed
Copy link

what is the problem here i simply use

  1. download graalvm-ce and extract
  2. install native-image installs it or returns true if installed
$GRAALVM/bin/gu install native-image

so ensure installed is not a problem ??

@cvmocanu
Copy link

what is the problem here i simply use

  1. download graalvm-ce and extract
  2. install native-image installs it or returns true if installed
$GRAALVM/bin/gu install native-image

so ensure installed is not a problem ??

@frank-dspeed, let me re-phrase your question: "What is the point of Gradle toolchain auto provisioning?".
And the answer is: convenience - you checkout a git project and it just works. No need to point people to a readme file with step-by-step instructions. It just works.
That is also why we use the Gradle wrapper instead of asking everyone to install Gradle.

@cvmocanu
Copy link

BTW, the lack of auto-provisioning is why I'm also using the https://github.com/palantir/gradle-graal plugin instead of this one.

Slightly off topic: kudos to the GraalVM team (and the team behind this plugin)! It's very nice to be able to build a statically linked native Java executable.

@frank-dspeed
Copy link

@cvmocanu do i understand you correct your using nativ image gradle and graal with stock JDK?

@cvmocanu
Copy link

@frank-dspeed: I'm using the https://github.com/palantir/gradle-graal Gradle plugin. The plugin adds a nativeImage task which compiles to native binaries.
I assume the Java source->bytecode compilation is done with a stock JDK, but I'm not sure if the plugin changes the Java compiler configuration or not.

As others said, that plugin does auto-provisioning (it downloads the specified version of GraalVM community to ~/.gradle/caches/com.palantir.graal/<version>, if it's not already downloaded locally). This is really convenient.

@cvmocanu
Copy link

I would love to use the official plugin (this one) though, instead of the palantir one.

sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Aug 22, 2022
See [1]. Once [2] is resolved the official Gradle plugin should be used
instead of the current Palantir plugin [3] to benefit from automatic
download of reachability-metadata [4].

[1]: https://github.com/oracle/graalvm-reachability-metadata/blob/master/metadata/ch.qos.logback/logback-classic/1.2.11/reflect-config.json
[2]: graalvm/native-build-tools#100
[3]: https://github.com/palantir/gradle-graal
[4]: https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html#metadata-support

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Aug 22, 2022
See [1]. Once [2] is resolved the official Gradle plugin should be used
instead of the current Palantir plugin [3] to benefit from automatic
download of reachability-metadata [4].

Note that still more work is required to make the native-image build
succeed.

[1]: https://github.com/oracle/graalvm-reachability-metadata/blob/master/metadata/ch.qos.logback/logback-classic/1.2.11/reflect-config.json
[2]: graalvm/native-build-tools#100
[3]: https://github.com/palantir/gradle-graal
[4]: https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html#metadata-support

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Aug 23, 2022
See [1]. Once [2] is resolved the official Gradle plugin should be used
instead of the current Palantir plugin [3] to benefit from automatic
download of reachability-metadata [4].

Note that still more work is required to make the native-image build
succeed.

[1]: https://github.com/oracle/graalvm-reachability-metadata/blob/master/metadata/ch.qos.logback/logback-classic/1.2.11/reflect-config.json
[2]: graalvm/native-build-tools#100
[3]: https://github.com/palantir/gradle-graal
[4]: https://graalvm.github.io/native-build-tools/latest/gradle-plugin.html#metadata-support

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
@sschuberth
Copy link

Just wondering, could the work on this topic for the Gradle plugin already start now that Gradle 7.6 RC1 added support for Java Toolchain downloads from arbitrary repositories, despite gradle/gradle#18028 not being merged yet?

@frank-dspeed
Copy link

i guess this gets solved as most of the graalvm parts get moved now to stock openjdk

@sschuberth
Copy link

i guess this gets solved as most of the graalvm parts get moved now to stock openjdk

I'm not sure whether it's worth waiting for that to happen in a new JDK release. Releasing a new plugin version that's able to bootstrap GraalVM with native image support now seems to be the much lower hanging fruit.

@frank-dspeed
Copy link

frank-dspeed commented Nov 23, 2022

@sschuberth that was exactly what i did want to say 👍🏻 simply create a bash script and call it a day much faster written then java or use kotlin and not bash.

@sschuberth
Copy link

simply create a bash script and call it a day much faster written then java or use kotlin and not bash.

That, however, is not what I wanted to say 😉 : Adding a few lines of Kotlin / Java code to implement a toolchain resolver plugin is quicker than waiting for a new JDK release, and much more generic / self-contained than requiring developers to run an external script.

@frank-dspeed
Copy link

frank-dspeed commented Nov 23, 2022

@sschuberth i make it even more generic i am working on a https://google.github.io/blockly-samples/plugins/block-dynamic-connection/test/ graalvm build tool ok it is not related to graalvm but it can build graalvm and that is in my view the most generic as it runs generic in my browser and is able to execute it directly else where or save it to a local file.

i simply connect my input processing and output blocks click run and call it a day and even get debug output if needed and so on. As also can edit on the fly if needed.

@fniephaus fniephaus self-assigned this Oct 16, 2023
@fniephaus
Copy link
Member

GraalVM has become more easily accessible in the last couple of months (e.g., SDKMAN!, GitHub Actions, script-friendly download URLs). It is also integrated in the Foojay API, which can be used by Gradle's toolchain detection.

Given this issue hasn't been updated for more than a year, I'm going to close it for now. In case you still see a problem or potentials for improvement, please speak up :)

@cvmocanu
Copy link

This should really be reopened. None of the variants listed allow for automatic management of the GraalVM SDK, or insures that all developers use same version for a particular project.

@fniephaus fniephaus reopened this Oct 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants