Add possibility to pass arguments before -cp command in native-maven-plugin
Opened this issue · 4 comments
We're trying to use -H:+UnlockExperimentalVMOptions
option in native-maven-plugin to get rid form native compilation warnings:
14 26.97 Warning: The option '-H:ReflectionConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-websocket/tomcat-reflection.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
14 26.97 Warning: The option '-H:ReflectionConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-el/tomcat-reflection.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
14 26.97 Warning: The option '-H:ResourceConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-core/tomcat-resource.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
14 26.97 Warning: The option '-H:ReflectionConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-core/tomcat-reflection.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
14 26.97 Warning: The option '-H:IncludeResources=rabbitmq-amqp-client.properties|version.properties' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
14 26.97 Warning: The option '-H:ResourceConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-el/tomcat-resource.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
14 26.97 Warning: The option '-H:ResourceConfigurationResources=META-INF/native-image/org.apache.tomcat.embed/tomcat-embed-websocket/tomcat-resource.json' is experimental and must be enabled via '-H:+UnlockExperimentalVMOptions' in the future.
It works only when -H:+UnlockExperimentalVMOptions
option is before -cp
command.
Please add a possibility to pass arguments before -cp
command in native-maven-plugin.
@maximkovalenko-h thank you for reporting. We will discuss this at our next meeting to find a solution.
In the meanwhile, have you opened a ticket for org.apache.tomcat
to fix this in their jars? ResourceConfigurationResources
should not even be used already for a long while.
Hello @vjovanov, thank you.
Yes, we reported it to Tomcat team.
https://bz.apache.org/bugzilla/show_bug.cgi?id=69465
While I agree that in this instance the right solution is to fix the tomcat artifacts to not use deprecated options anymore, the request to allow to control the place where -cp ...
gets emitted in the native image command is valid.
The right way to provide that for maven is to use the maven exec plugin for inspiration.
See https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html
I.e. we could also introduce <classpath/>
and <modulepath/>
to be allowed in our <buildArgs>
.
If found, we would expand it and suppress our implicit adding of -cp ...
(-p ...
respectively).
We discussed this in the meeting and the conclusion is that investing effort in this feature for this single malicious case is not worth the effort. In this case, the mechanism worked as the ticket is reported and it will eventually get fixed.
If we make it easy to bypass these warnings, the real issue will never be fixed and we will be stuck with the original problem.
The workaround for this issue would be to use an environment variable: NATIVE_IMAGE_OPTIONS=-H:+UnlockExperimentalVMOptions
before executing this build.
maximkovalenko-hc please let us know if this did the trick.