-
Notifications
You must be signed in to change notification settings - Fork 64
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 ability to pass build arguments via command line #631
Comments
In general this isn't such a good idea. Arguments passed by command line are by nature undocumented, opaque. Imagine build reproducibility: everything should be found in the build files, or it means that only god knows what was used to produce an artifact. |
I agree. That's what we have the bundle feature for (https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/Bundles.md). If you want a self-contained file that allows you to replay a NI build, this should be your first choice. BTW, the above is already possible even without adding support for |
Hello. My use case is that if I want to customize the build process of the same application, such as for benchmarking, when I need an instrumented version, a plain Native Image version, and a Native Image version with all optimizations, this is what I have to do at the moment: <profiles>
<profile>
<id>instrumented</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<imageName>demo-instrumented</imageName>
<buildArgs>
<buildArg>--pgo-instrument</buildArg>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>optimized</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<imageName>demo-optimized</imageName>
<buildArgs>
<buildArg>--gc=G1</buildArg>
<buildArg>--pgo=${project.basedir}/default.iprof</buildArg>
<buildArg>-march=native</buildArg>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>monitored</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<configuration>
<imageName>demo-monitored</imageName>
<buildArgs>
<buildArg>--pgo=${project.basedir}/default.iprof</buildArg>
<buildArg>-march=native</buildArg>
<buildArg>--enable-monitoring=heapdump,jfr,jvmstat</buildArg>
</buildArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile> The same applies if I need to add SBOM, |
That's correct. Nonetheless, the discoverability of this env var is relatively poor. In the context of the NBTs, we either need to document this more, or provide the ability to inject args via an user property. I would be in favor of a dedicated user property, for example |
Adding support for something like |
And I was not suggesting that. ;) I think providing users with different ways to achieve the same is not always bad, at least they can choose what they want to use. |
From the meeting, we want to support this flag and the flag would add flags to the existing |
Is your feature request related to a problem? Please describe.
As @alina-yur suggested: Right now there is no way to pass build args to builds that are invoked via Maven, such as for Spring apps. Currently this can only be done via Maven profiles, writing which is a lot of overhead for passing arguments
Describe the solution you'd like
We need to provide a way to do something like
mvn -Pnative native:compile -DbuildArg=<...>
, so that arguments can be passed via command line. This should also support passing several arguments, andalso the argument-o
for specifying the image name.The text was updated successfully, but these errors were encountered: