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

Quarkus #136

Merged
merged 3 commits into from
Feb 1, 2022
Merged

Quarkus #136

merged 3 commits into from
Feb 1, 2022

Conversation

dmikusa
Copy link
Contributor

@dmikusa dmikusa commented Jan 29, 2022

Summary

This PR has two components:

  1. It allows you to build from a JAR file. To build from a JAR, there are two requirements. First, your build artifacts must not be an exploded JAR directory. Second, you must set BP_NATIVE_IMAGE_BUILT_ARTIFACT and instruct the native-image buildpack what JAR file to build. For Quarkus builds with ./mvnw -Dquarkus.package.type=native-sources, this would be BP_MAVEN_BUILT_ARTIFACT="target/native-sources".

    You can build your source code locally and build an image with the target/native-sources directory, or you can build using the Maven buildpack and set BP_MAVEN_BUILT_ARTIFACT="target/native-sources".

  2. It adds $BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE which allows you to specify arguments to native-image from a file. This is handy with Quarkus which generates native-image.args, so you can set BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE="native-sources/native-image.args" and the buildpack will automatically load arguments from that file. It will pass through all arguments except the -jar <file>. The buildpack overrides -jar because it needs to ensure that the path is correct.

Use Cases

Support building from a JAR file, in particular for building Quarkus based apps.

Resolves #109

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).

Daniel Mikusa added 2 commits January 28, 2022 16:26
Prior to this PR, native-image builds would happen with the assumption that the contents of the `/workspace` directory was an exploded JAR file. The buildpack would configure options to build from that location. Recently, buildpacks have gained the capability to build and persist multiple files. This results in the `/workspace` directory not meeting the previous expectation on structure.

This PR continues to support building from an exploded JAR file, but also supports building from a JAR file. This requires the user to specify a pattern (Glob match) or file name which points to the JAR file that should the target for the native-image build. When this is set, the buildpack will adjust the build arguments to build from the JAR file.

The `$BP_NATIVE_IMAGE_BUILT_ARTIFACT` argument is what controls this behavior. If the `/workspace` directory does not contain an exploded JAR structure, it must have `META-INF/MANIFEST.MF`, then we'll look for files that match the pattern set in `$BP_NATIVE_IMAGE_BUILT_ARTIFACT` and attempt to build from the JAR file at that location.

Signed-off-by: Daniel Mikusa <[email protected]>
Previously, you could set arguments through the `$BP_NATIVE_IMAGE_BUILD_ARGUMENTS` env variable, but this is a static set of arguments.. You may now set `$BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE` and point to a file that contains arguments, which is handy if your build system generates a file containing arguments to pass to `native-image`.

Arguments are now applied in this order:

1. Baseline arguments set by the buildpack
2. If set, arguments from the file `$BP_NATIVE_IMAGE_BUILD_ARGUMENTS_FILE`
3. If any, arguments from `$BP_NATIVE_IMAGE_BUILD_ARGUMENTS`
4. Either arguments required to build from a JAR file or arguments required to build from an exploded JAR directory

Arguments from later steps override arguments from lower steps.

Signed-off-by: Daniel Mikusa <[email protected]>
@dmikusa dmikusa added semver:minor A change requiring a minor version bump type:enhancement A general enhancement labels Jan 29, 2022
@dmikusa dmikusa requested a review from a team January 29, 2022 21:28
@dmikusa dmikusa merged commit 00c4c31 into main Feb 1, 2022
@dmikusa dmikusa deleted the quarkus branch February 1, 2022 17:28
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.

Better support for Quarkus.
1 participant