-
Notifications
You must be signed in to change notification settings - Fork 65
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
Exclude dependencies from native-image #612
Comments
Our usecase, as described in spring-projects/spring-boot#32853 is that we have the devtools on the runtime classpath. Native image automatically includes the whole runtime classpath in the native image (at least what's reachable). On Spring Boot startup, the We worked around that by adding an To fix that problem at the root, it would be nice to do something like this: <build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<excludeDependency> <!-- Or maybe just name the tag 'exclude'? -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</excludeDependency>
</configuration>
</plugin>
</plugins>
</build> and the |
Another option would be, like Stephane suggested, to add a key to the manifest (e.g. This approach would be more flexible, as this doesn't need a hard-coded list of dependencies. |
We hit similar issues I believe. Just out of interest.. does using |
The devtools should be on the classpath when developing the application on the JVM but not when building the native image. Usually, this is in the pom.xml with devtools: <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency> |
You can achieve that with |
It should be on the runtime classpath when developing the application (it does stuff when you run the application on the JVM, like reloading classes), but it should not be on the classpath when compiling the native image. I don't think this is possible with the
Who would provide this dependency? |
So That said, if you have control over the classpath of the app running in dev mode, you could choose to include dependencies in And this will also have the desired effect of not including such dependencies in the native image. |
While this could be made to work with |
Yes, in Intellij IDEA at least, |
Is your feature request related to a problem? Please describe.
Maven has a limited list of dependency scopes and it's not possible to create custom ones. As such, dependencies that are development only can end up on the classpath. This has caused issues in the past for things that need to build an executable based on a Maven project.
Spring Boot has had several issues such as spring-projects/spring-boot#13289 and implemented several features to allow dependencies to be excluded:
The Maven plugin for native build tools urrently works in two modes: it builds the classpath itself, or it lets you define it. It would be nice if we could configure it to be able to exclude certain dependencies that shouldn't be analyzed by native-image in the first place.
Describe the solution you'd like
A way to exclude a dependency. Either by providing the GAV in the plugin configuration or via a manifest entry. The latter looks less invasive and would work out of the box.
Describe alternatives you've considered
None as building the classpath ourselves isn't really practical with Maven. The plugin is configured in our maven parent and used in a wide range of contexts.
The text was updated successfully, but these errors were encountered: