Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
PluginUtils simply invokes Class.forName(String) to load a mojo class from the current project using its plugin class loader. However, as outlined in Guide to Maven Classloading, Maven plugins have no direct access to the classes of the current project.
Besides, wouldn't the maven-plugin-plugin's report goal need @execute phase="compile" in order to ensure the mojo classes are existent prior to try to load them?
Not sure about that but maybe it's worth to extend the mojo descriptor with a flag "report" such that this info could be retrieved without reflection in some far future but is derived by the goal extractors.
P.S: You don't need to instantiate a class just to do instanceof checking. To check for a report mojo simply do:
MavenReport.class.isAssignableFrom( clazz );