-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Provide GraalVM metadata repository support with Buildpacks #31782
Comments
On the Gradle side, we may be able to use |
On the Maven Side, things aren't as easy to reuse I am afraid. We've discussed this and we think that extracting that capability in a dedicated goal of the Native Build Plugins would be a nice option. We don't want to redefine the attributes that this feature need in our own plugin and rather add an extra execution of an existing goal in our parent. For instance, the existing |
I've been thinking about this some more, and I'm starting to wonder if relying on capabilities of the native build tools' Gradle and Maven plugins is a good idea. If buildpacks are creating the native image, will the user have even configured/applied the native build tools plugin? For those that haven't, I think it would feel quite strange to have to apply/configure the plugin locally solely for the purpose of providing reachability metadata to the buildpack. I know it's more work on the buildpacks side, but it feels to me that if the buildpacks are creating the native image, they should be capable of retrieving and using the reachability metadata. We could provide GAV metadata to the buildpacks to facilitate retrieving the reachability metadata without requiring the user to configure anything. |
I think the right level of reuse is the graalvm-reachability-metadata dependency. Notice that if you feel
One of the main issue discussed with @dmikusa-pivotal during our last meeting related to implementing that at Buildpack level is that it will be hard to leverage I think any solution not based on |
100%. The big challenge is that we can't reuse any of their library code. The only path forward would be if that project were to release a CLI that we could call from the buildpack, either The second hurdle is that buildpacks have to account for two scenarios: 1.) building from source and 2.) building from precompiled assets. I think we could make building from source work (assuming we have the CLI to call) but I'm very skeptical that we could make the second scenario, building from a precompiled asset, work. There's just a lack of information since all we'd have is a JAR file, and we cannot assume it's a Spring Boot JAR. The buildpack has to work with any kind of JAR. This might seem like a weird use case, who's going to do half the build locally and then half with buildpacks, but that's exactly what the Spring Boot tools do, |
Can you expand on this? What type of information would this provide to buildpacks? Basically, just a full list of all the dependencies installed? In particular, for the case where |
My 2 cents: right now the NBT plugins (Maven & Gradle) download the metadata and invoke the native-image with it. When we add this logic into our plugins or into the buildpack, there's a third place where the repository logic is implemented. My take would be to talk to the GraalVM team if the metadata repository support could be implemented in native-image itself. We could then invoke the native-image tool like this:
and native-image would fetch the metadata needed for the given dependencies and build a native image with this. With this change the repository fetching could be removed from NBT maven and gradle plugins and we don't need to implement the repository fetching for every build tool out there. This doesn't solve the problem how exactly the dependencies get passed into the build pack, but maybe we could put it under What do you think? |
We have already discussed this possibility with the GraalVM team in the past which has been refused, no hope to see this happening short/middle term. |
That popped into my mind, too. Right now, the In terms of UX, what is the signal to apply AOT processing + native? |
+1, on Spring Native we have seen a higher than expected amount of users just using Buildpack support without Native Build Tools configured so that seems to be a strong use case. |
I also think it would help to get some clarity about the big picture to determine what will be "the signal" (Maven/Gradle build configuration and/or command line parameter) to build a native container (AOT transformations + native compilation + tiny container) versus a JVM based one in Spring Boot 3 GA via |
#32408 will update the Gradle plugin to provide reachability metadata in the Spring Boot fat jar when built with Gradle. We'll leave this issue open to decide what to do with Maven. |
We need to add support for the |
I've submitted a PR to add a Maven goal and a Gradle task to NBT. If |
Thanks for working on that @philwebb. I think the override support will need to be refined since as of GraalVM 22.2 it is not possible to use The only way that I am aware to make it work is to get the exclude info from related Gradle/Maven properties and append that to the The best way to validate it works is to build and run a WebFlux based application and see if that works on Buildpack since it is using Netty 4.1 where |
Oh great! I've no idea how we'd get the information out of the Gradle/Maven plugin about which modules need to be excluded. Perhaps for Maven we can stash something in a property that we can pick up later, but I think that might be considered bad practice. |
I've updated the NBT PR so that if there's an override flag when the metadata is copied an additional This is actually a better solution I think because it puts the pattern generation back in the hands of the thing that's packaging the fat jar. The problem we have is that once we have those set of patterns, we've got to somehow pass them to the buildpack. We could update the We have some prior art here with things like the Even better would be if we could get |
I can try to discuss that again with @olpaw and @vjovanov but I have little hope since last time I did I think the feedback was that limitation for no But conceptually, what we try to achieve here is that Buildpacks automatically recognize a @argFile and passes it to So maybe based on those Another solution would be to work with @pivotal-david-osullivan to directly generates the |
https://github.com/philwebb/spring-boot/tree/gh-31782 contains some prototype code that generates a |
See my related comment on paketo-buildpacks/native-image#196 (comment) where Buidpack team would like to know if it is possible to directly generate the argfile to be passed to the native image compiler via |
We've done all we can on our end. I'm going to close this one for now but we can reopen if the buildpack support PR isn't merged. |
(edit)
Splitting into sub-tasks:
External issues:
As discussed with @dmikusa-pivotal, @mhalbritter and @scottfrederick, we need to integrate GraalVM metadata repository in Buildpacks in addition to Native Build Tools current support (see #31687) in order to allow compiling Spring Boot application with third-party dependencies to a native executable. 2 implementations have been discussed.
Based on our discussions, integration at Spring Boot Maven and Gradle plugin AOT generation level is the recommended way to implement such integration because:
GraalVMReachabilityMetadataRepository
class maintained by GraalVM team.The alternative way is to have 2 distinct implementations : the one at NBT plugins level and another at Buildpacks level, but the lack of consistency, poorer DevXP, the fact that we would likely have to reimplement
graalvm-reachability-metadata
in Go and maintaining it seems to indicate this should not be the way to move forward.The text was updated successfully, but these errors were encountered: