Skip to content

Add runtimeArgs support to native-maven-plugin #734

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

linghengqian
Copy link
Contributor

@linghengqian linghengqian commented May 31, 2025

@@ -204,6 +207,16 @@ private void configureEnvironment() {
systemProperties.put(child.getName(), child.getValue());
}
}
Xpp3Dom runtimeArguments = dom.getChild("runtimeArgs");
Copy link
Member

Choose a reason for hiding this comment

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

This would read the <runtimeArgs> configuration tag from the maven-surefire-plugin definition, which I don't think is what you want to do.

If what you want is Native Build Tool's <runtimeArgs>, then use the field annotated with @Parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • In fact, this logic does read parameters from native-maven-plugin, and the processing of maven-surefire-plugin is limited to the unit test file, which is a misunderstanding.
  • And I actually have no way to add unit tests for GraalVM CE For JDK 23 alone. Because as far as I know, spock does not have Junit annotations such as org.junit.jupiter.api.condition.DisabledForJreRange.

Copy link
Member

Choose a reason for hiding this comment

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

This logic does try to read the runtime args from maven-surefire-plugin, see line 185. The condition at line 211 will never be true.

What happens is that if you set <buildArgs> in native-build-tools, then runtimeArgs will be set by Maven, not by this logic.

Copy link
Contributor Author

@linghengqian linghengqian Jun 3, 2025

Choose a reason for hiding this comment

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

  • Wow, I just realized that I thought NBT needed to manually get properties from org.codehaus.plexus.util.xml.Xpp3Dom at this point, which I have removed in the latest commit.

@@ -204,6 +207,16 @@ private void configureEnvironment() {
systemProperties.put(child.getName(), child.getValue());
}
}
Xpp3Dom runtimeArguments = dom.getChild("runtimeArgs");
Copy link
Member

Choose a reason for hiding this comment

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

This logic does try to read the runtime args from maven-surefire-plugin, see line 185. The condition at line 211 will never be true.

What happens is that if you set <buildArgs> in native-build-tools, then runtimeArgs will be set by Maven, not by this logic.

@alvarosanchez
Copy link
Member

With regards to testing this with Spock, you can use @Requires({ jvm.java23Compatible }) but apart from this, is there any other runtime arg that you can test with?

@linghengqian
Copy link
Contributor Author

linghengqian commented Jun 3, 2025

is there any other runtime arg that you can test with?

  • I would say I have no idea. The GraalVM doc only mentions this one available runtime arg.

With regards to testing this with Spock, you can use @requires({ jvm.java23Compatible }) but apart from this,

  • I submitted a new commit to supplement the unit tests, but there is still an awkward problem. It seems that the gradle wrapper 7.4 used by the native-maven-plugin module does not support the JDK 23 runtime. I say this is awkward because I'm testing on Windows and can't set a session-level environment variable GRAALVM_HOME like Ubuntu can.

Copy link
Member

@alvarosanchez alvarosanchez left a comment

Choose a reason for hiding this comment

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

@dnestoro please help @linghengqian to write a test for this. The one added here is still skipped.

Other than that, this LGTM

@linghengqian thank you for your patience and collaboration!

@@ -5,6 +5,10 @@

This version introduces a breaking change: the plugin now requires Java 17 to run.

=== Maven plugin
Copy link
Member

Choose a reason for hiding this comment

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

@dnestoro will this go into 0.11.0? If not, please adjust it

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
2 participants