Ekryd / sortpom

Maven plugin that helps the user sort pom.xml.
https://github.com/Ekryd/sortpom/wiki/
BSD 3-Clause "New" or "Revised" License
334 stars 178 forks source link

Fix dynamic agent warning on JDK 21 #424

Closed Ekryd closed 4 months ago

Ekryd commented 5 months ago

How to get ahead of dynamic agent loading errors on JDK 22+ by addressing the warnings from JDK 21.

JDK 21 Mac

WARNING: A Java agent has been loaded dynamically (/Users/runner/.m2/repository/net/bytebuddy/byte-buddy-agent/1.14.12/byte-buddy-agent-1.14.12.jar)
WARNING: If a serviceability tool is in use, please run with -XX:+EnableDynamicAgentLoading to hide this warning
WARNING: If a serviceability tool is not in use, please run with -Djdk.instrument.traceUsage for more information
WARNING: Dynamic loading of agents will be disallowed by default in a future release

This is done by explicitly enabling jvm option EnableDynamicAgentLoading.

Also, Disables annotation processing in the maven-plugin since it is not needed for the plugin, it just causes warning messages.

Thanks @mches for the contribution!!

mches commented 5 months ago

Looks good. If you're determined enough, it's also possible to add an explicit agent argument and even disable dynamic agent loading, though one must be sure to consider IDE compatibility. For example, IntelliJ IDEA can adopt the argLine, for running tests without Maven, if it doesn't rely on other plugin executions, such as using dependency-maven-plugin to get the path to the agent JAR. I had success with that in one of my public repositories.

https://github.com/markitect-dev/markitect-liquibase/commit/7de0c1f7ee2d6ae2a15731e423cd297153ee1539