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

Added support for argument file provided... #201

Closed
wants to merge 2 commits into from

Conversation

pivotal-david-osullivan
Copy link
Contributor

by Spring Boot for native builds

Summary

As discussed in spring-projects/spring-boot#31782 & #196, Spring Boot will generate an argument file containing the --exclude-config arguments necessary for a jar to be converted to a native-image executable.

This PR adds support for passing this argfile to the native-image binary using the @argfile format that is supported in the same way as with the java command.

Use Cases

Currently any --exclude-config args necessary to successfully build from a jar must be manually specified via BP_NATIVE_IMAGE_BUILD_ARGUMENTS - this change allows these args to be consumed directly from the jar itself.

Checklist

  • I have viewed, signed, and submitted the Contributor License Agreement.
  • I have linked issue(s) that this PR should close using keywords or the Github UI (See docs)
  • I have added an integration test, if necessary.
  • I have reviewed the styleguide for guidance on my code quality.
  • I'm happy with the commit history on this PR (I have rebased/squashed as needed).

@pivotal-david-osullivan pivotal-david-osullivan requested a review from a team October 19, 2022 13:04
@pivotal-david-osullivan pivotal-david-osullivan added semver:minor A change requiring a minor version bump type:enhancement A general enhancement labels Oct 19, 2022
README.md Outdated Show resolved Hide resolved
native/arguments.go Outdated Show resolved Hide resolved
@dmikusa
Copy link
Contributor

dmikusa commented Oct 20, 2022

How does this differ from BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE? We added BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE for Quarkus support which does something similar, when it builds it generates a file full of native-image arguments that need to be included in the build command. My worry here is that we have two similar but different features which is confusing for users.

Also, what exactly is an @argfile. I'm not familiar with that. How is native-image handling that argument?

The BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE option in the buildpack basically just reads a file, the contents of which are then appended to the arguments list passed to native-image. So the file is just a single line of arguments that will be used by native-image.

@philwebb
Copy link

How does this differ from BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE

The main difference is that we want a way to provide arguments as something that's packaged inside the jar and applied by convention. As I understand it, the BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE is an environment variable that the user would still need to configure. We're looking for a way to remove any custom configuration that the user needs to remember.

Also, what exactly is an @argfile. I'm not familiar with that. How is native-image handling that argument?

They're a standard adopted by java command line tools. Some documentation is available here.

There's also a brief comment about them if you run native-image --help:

GraalVM Native Image (https://www.graalvm.org/native-image/)

This tool can ahead-of-time compile Java code to native executables.

...

where options include:

    @argument files       one or more argument files containing options

@pivotal-david-osullivan
Copy link
Contributor Author

Closing in favour of #204

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:minor A change requiring a minor version bump type:enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants