Skip to content

Make environment variables set in the pom.xml of the native-maven-plugin be visible in the image builder#819

Merged
jormundur00 merged 1 commit intomasterfrom
jormundur00/gh-818
Jan 19, 2026
Merged

Make environment variables set in the pom.xml of the native-maven-plugin be visible in the image builder#819
jormundur00 merged 1 commit intomasterfrom
jormundur00/gh-818

Conversation

@jormundur00
Copy link
Member

In this PR, we make environment variables set in the pom.xml <environmentVariables> tag visible to the native image static analysis by providing them to the native-image builder using the -E<variable>=<value> flag (consistent with how systemProperties are currently handled).

Also in this PR, to avoid documentation mismatches and breaking older builds, we add aliases for both environmentVariables and systemPropertyVariables properties.

Current documentation and samples frequently use these names even though the plugin only recognized the field names environment and systemProperties. By using aliases, we ensure:

  • Consistency: The naming now matches the maven-surefire-plugin and maven-failsafe-plugin conventions.
  • Backwards Compatibility: Existing builds using the <environment> and <systemProperties> tags will continue to work without modification.

Alternatively we could just rename the fields to environmentVariables and systemPropertyVariables (and avoid aliases), but that could potentially break older builds that used the old tag names.

Fixes: #818

@jormundur00 jormundur00 requested a review from vjovanov January 19, 2026 10:09
@jormundur00 jormundur00 self-assigned this Jan 19, 2026
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jan 19, 2026
protected Map<String, String> environment;

@Parameter(property = "systemPropertyVariables")
@Parameter(alias = "systemPropertyVariables", property = "systemPropertyVariables")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this even documented? Why not just -D?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the documentation states that the <systemPropertyVariables> tag should be used to set system properties from the pom.xml. Internally, this tag gets mapped as if the user has been using -D from the command line:

if (systemProperties != null) {
    for (Map.Entry<String, String> entry : systemProperties.entrySet()) {
        cliArgs.add("-D" + entry.getKey() + "=" + entry.getValue());
    }
}

protected List<ExcludeConfigConfiguration> excludeConfig;

@Parameter(property = "environmentVariables")
@Parameter(alias = "environmentVariables", property = "environmentVariables")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need this for bundles?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tag represents a way to set env variables through the pom.xml (like it's done in the surefire/failsafe plugins), without having to provide them in the CLI or through other <buildArgs> -E<..>=<..> pom tags.

The alias was added to stay consistent with other plugins that use this feature (and our documentation) while not breaking older builds that used the <environment> tag.

@jormundur00 jormundur00 merged commit 9c5533a into master Jan 19, 2026
70 checks passed
@jormundur00 jormundur00 deleted the jormundur00/gh-818 branch January 19, 2026 12:52
mergify bot added a commit to robfrank/linklift that referenced this pull request Mar 10, 2026
…1.4 to 0.11.5 [skip ci]

Bumps [org.graalvm.buildtools:native-maven-plugin](https://github.com/graalvm/native-build-tools) from 0.11.4 to 0.11.5.
Release notes

*Sourced from [org.graalvm.buildtools:native-maven-plugin's releases](https://github.com/graalvm/native-build-tools/releases).*

> 0.11.5
> ------
>
> What's Changed
> --------------
>
> * Bump version to 0.11.5-SNAPSHOT by [`@​graalvmbot`](https://github.com/graalvmbot) in [graalvm/native-build-tools#817](https://redirect.github.com/graalvm/native-build-tools/pull/817)
> * Make environment variables set in the pom.xml of the native-maven-plugin be visible in the image builder by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#819](https://redirect.github.com/graalvm/native-build-tools/pull/819)
> * Add check if correct schemas are present in the reachability metadata repository provided to buildtools by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#821](https://redirect.github.com/graalvm/native-build-tools/pull/821)
> * Add fallback for jarless artifacts in the native-maven-plugin by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#824](https://redirect.github.com/graalvm/native-build-tools/pull/824)
> * Fix JUnit 6 not working correctly with JDK 21 by expanding the initialize-at-build-time-list by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#832](https://redirect.github.com/graalvm/native-build-tools/pull/832)
> * Remove the usage of the global metadata/index.json from the nbt plugins by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#829](https://redirect.github.com/graalvm/native-build-tools/pull/829)
> * Revert "Remove the usage of the global metadata/index.json from the nbt plugins" by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#836](https://redirect.github.com/graalvm/native-build-tools/pull/836)
> * Use JDK 21 Graal in the CI by [`@​jormundur00`](https://github.com/jormundur00) in [graalvm/native-build-tools#839](https://redirect.github.com/graalvm/native-build-tools/pull/839)
> * Support `-H:+CompatibilityMode` in build tools by [`@​vjovanov`](https://github.com/vjovanov) in [graalvm/native-build-tools#822](https://redirect.github.com/graalvm/native-build-tools/pull/822)
> * Update reachability metadata to 0.3.34 by [`@​graalvmbot`](https://github.com/graalvmbot) in [graalvm/native-build-tools#842](https://redirect.github.com/graalvm/native-build-tools/pull/842)
>
> **Full Changelog**: <graalvm/native-build-tools@0.11.4...0.11.5>


Commits

* [`ffd094d`](graalvm/native-build-tools@ffd094d) Release 0.11.5
* [`1d7c2f7`](graalvm/native-build-tools@1d7c2f7) Merge pull request [#842](https://redirect.github.com/graalvm/native-build-tools/issues/842) from graalvm/update-metadata-to-0.3.34
* [`ba1c2e8`](graalvm/native-build-tools@ba1c2e8) Update reachability metadata to 0.3.34
* [`790fa05`](graalvm/native-build-tools@790fa05) Merge pull request [#822](https://redirect.github.com/graalvm/native-build-tools/issues/822) from graalvm/vj/compatibility-mode
* [`0631241`](graalvm/native-build-tools@0631241) Implement Compatibility Mode detection
* [`1844654`](graalvm/native-build-tools@1844654) Use JDK 21 Graal in the CI ([#839](https://redirect.github.com/graalvm/native-build-tools/issues/839))
* [`6315677`](graalvm/native-build-tools@6315677) Revert "Remove the usage of the global metadata/index.json from the nbt plugi...
* [`fe065ce`](graalvm/native-build-tools@fe065ce) Remove the usage of the global metadata/index.json from the nbt plugins ([#829](https://redirect.github.com/graalvm/native-build-tools/issues/829))
* [`94b5b54`](graalvm/native-build-tools@94b5b54) Fix JUnit 6 not working correctly with JDK 21 by expanding the initialize-at-...
* [`086cfdf`](graalvm/native-build-tools@086cfdf) Add fallback for jarless artifacts in the native-maven-plugin ([#824](https://redirect.github.com/graalvm/native-build-tools/issues/824))
* Additional commits viewable in [compare view](graalvm/native-build-tools@0.11.4...0.11.5)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.graalvm.buildtools:native-maven-plugin&package-manager=maven&previous-version=0.11.4&new-version=0.11.5)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

native-maven-plugin does not provide environment variables to the image builder

2 participants