How to get target name in maven2 Mojo at runtime
1 answer
public static String getGoalName(PluginDescriptor pluginDescriptor, String mojoClassName) {
String goalName=null;
List<MojoDescriptor> mojoDescriptorList = pluginDescriptor.getMojos();
for (MojoDescriptor mojoDescriptor : mojoDescriptorList) {
if (mojoDescriptor.getImplementation().equals(mojoClassName)) {
goalName=mojoDescriptor.getGoal();
break;
}
}
return goalName;
}
Here, PluginDescriptor can be retrieved from pluginManager.getPluginDescriptorForPrefix ("prefix-for-your-plugin"). PluginManager is available as @component role = "org.apache.maven.plugin.PluginManager"
+1
Advait
source
to share