Get LMP info from Maven 3's plugin descriptor
@@ -53,6 +53,7 @@ import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.plugin.BuildPluginManager;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.tools.ant.taskdefs.Copy;
@@ -122,6 +123,12 @@ public class StartDebugMojoSupport extends BasicSupport {
@Parameter
protected List<String> jvmOptions;
+ /**
+ * The current plugin's descriptor. This is auto-filled by Maven 3.
+ */
+ @Parameter( defaultValue = "${plugin}", readonly = true )
+ private PluginDescriptor plugin;
+
private enum PropertyType {
BOOTSTRAP("liberty.bootstrap."),
ENV("liberty.env."),
@@ -202,14 +209,19 @@ public class StartDebugMojoSupport extends BasicSupport {
}
protected Plugin getLibertyPlugin() {
- Plugin plugin = project.getPlugin(LIBERTY_MAVEN_PLUGIN_GROUP_ID + ":" + LIBERTY_MAVEN_PLUGIN_ARTIFACT_ID);
- if (plugin == null) {
- plugin = getPluginFromPluginManagement(LIBERTY_MAVEN_PLUGIN_GROUP_ID, LIBERTY_MAVEN_PLUGIN_ARTIFACT_ID);
+ // Try getting the plugin from Maven 3's plugin descriptor
+ if (plugin != null && plugin.getPlugin() != null) {
+ return plugin.getPlugin();
}
- if (plugin == null) {
- plugin = plugin(LIBERTY_MAVEN_PLUGIN_GROUP_ID, LIBERTY_MAVEN_PLUGIN_ARTIFACT_ID, "LATEST");
+ // Otherwise fallback
+ Plugin fallbackPlugin = project.getPlugin(LIBERTY_MAVEN_PLUGIN_GROUP_ID + ":" + LIBERTY_MAVEN_PLUGIN_ARTIFACT_ID);
+ if (fallbackPlugin == null) {
+ fallbackPlugin = getPluginFromPluginManagement(LIBERTY_MAVEN_PLUGIN_GROUP_ID, LIBERTY_MAVEN_PLUGIN_ARTIFACT_ID);
}
- return plugin;
+ if (fallbackPlugin == null) {
+ fallbackPlugin = plugin(LIBERTY_MAVEN_PLUGIN_GROUP_ID, LIBERTY_MAVEN_PLUGIN_ARTIFACT_ID, "LATEST");
+ }
+ return fallbackPlugin;
}
protected Plugin getPluginFromPluginManagement(String groupId, String artifactId) {
