6b9f22
From 46ad87218f0be4a4b7e292a1c8b5d5dbce48ae63 Mon Sep 17 00:00:00 2001
6b9f22
From: Mikolaj Izdebski <mizdebsk@redhat.com>
6b9f22
Date: Fri, 16 Mar 2018 11:10:35 +0100
6b9f22
Subject: [PATCH] Fix configuration of aliased plugins
6b9f22
6b9f22
Normally Maven tries to look up plugin configuration using plugin
6b9f22
coordinates taken from plugin descriptor.  This works with pure Maven
6b9f22
as plugin descriptor always matches <plugin> reference in POM.
6b9f22
However in XMvn they can differ when plugin artifact is resolved
6b9f22
throug artifact alias, so XMvn should force use of coordinates
6b9f22
specified in <plugin> in POM.
6b9f22
---
6b9f22
 .../aether/XMvnMojoExecutionConfigurator.java      | 51 ++++++++++++++++++++++
6b9f22
 1 file changed, 51 insertions(+)
6b9f22
 create mode 100644 xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionConfigurator.java
6b9f22
6b9f22
diff --git a/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionConfigurator.java b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionConfigurator.java
6b9f22
new file mode 100644
6b9f22
index 00000000..72e38b37
6b9f22
--- /dev/null
6b9f22
+++ b/xmvn-connector-aether/src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionConfigurator.java
6b9f22
@@ -0,0 +1,51 @@
6b9f22
+/*-
6b9f22
+ * Copyright (c) 2018 Red Hat, Inc.
6b9f22
+ *
6b9f22
+ * Licensed under the Apache License, Version 2.0 (the "License");
6b9f22
+ * you may not use this file except in compliance with the License.
6b9f22
+ * You may obtain a copy of the License at
6b9f22
+ *
6b9f22
+ *     http://www.apache.org/licenses/LICENSE-2.0
6b9f22
+ *
6b9f22
+ * Unless required by applicable law or agreed to in writing, software
6b9f22
+ * distributed under the License is distributed on an "AS IS" BASIS,
6b9f22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6b9f22
+ * See the License for the specific language governing permissions and
6b9f22
+ * limitations under the License.
6b9f22
+ */
6b9f22
+package org.fedoraproject.xmvn.connector.aether;
6b9f22
+
6b9f22
+import org.apache.maven.lifecycle.MojoExecutionConfigurator;
6b9f22
+import org.apache.maven.lifecycle.internal.DefaultMojoExecutionConfigurator;
6b9f22
+import org.apache.maven.plugin.MojoExecution;
6b9f22
+import org.apache.maven.plugin.descriptor.PluginDescriptor;
6b9f22
+import org.apache.maven.project.MavenProject;
6b9f22
+import org.codehaus.plexus.component.annotations.Component;
6b9f22
+
6b9f22
+/**
6b9f22
+ * @author Mikolaj Izdebski
6b9f22
+ */
6b9f22
+@Component( role = MojoExecutionConfigurator.class )
6b9f22
+public class XMvnMojoExecutionConfigurator
6b9f22
+    extends DefaultMojoExecutionConfigurator
6b9f22
+{
6b9f22
+    @Override
6b9f22
+    public void configure( MavenProject project, MojoExecution execution, boolean allowPluginLevelConfig )
6b9f22
+    {
6b9f22
+        PluginDescriptor originalPluginDescriptor = execution.getMojoDescriptor().getPluginDescriptor();
6b9f22
+
6b9f22
+        PluginDescriptor aliasedPluginDescriptor = originalPluginDescriptor.clone();
6b9f22
+        aliasedPluginDescriptor.setGroupId( execution.getPlugin().getGroupId() );
6b9f22
+        aliasedPluginDescriptor.setArtifactId( execution.getPlugin().getArtifactId() );
6b9f22
+
6b9f22
+        try
6b9f22
+        {
6b9f22
+            execution.getMojoDescriptor().setPluginDescriptor( aliasedPluginDescriptor );
6b9f22
+            super.configure( project, execution, allowPluginLevelConfig );
6b9f22
+        }
6b9f22
+        finally
6b9f22
+        {
6b9f22
+            execution.getMojoDescriptor().setPluginDescriptor( originalPluginDescriptor );
6b9f22
+        }
6b9f22
+    }
6b9f22
+}
6b9f22
-- 
6b9f22
2.14.3
6b9f22