-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix configuration of aliased plugins
Normally Maven tries to look up plugin configuration using plugin coordinates taken from plugin descriptor. This works with pure Maven as plugin descriptor always matches <plugin> reference in POM. However in XMvn they can differ when plugin artifact is resolved throug artifact alias, so XMvn should force use of coordinates specified in <plugin> in POM.
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
.../src/main/java/org/fedoraproject/xmvn/connector/aether/XMvnMojoExecutionConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/*- | ||
* Copyright (c) 2018 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.fedoraproject.xmvn.connector.aether; | ||
|
||
import org.apache.maven.lifecycle.MojoExecutionConfigurator; | ||
import org.apache.maven.lifecycle.internal.DefaultMojoExecutionConfigurator; | ||
import org.apache.maven.plugin.MojoExecution; | ||
import org.apache.maven.plugin.descriptor.PluginDescriptor; | ||
import org.apache.maven.project.MavenProject; | ||
import org.codehaus.plexus.component.annotations.Component; | ||
|
||
/** | ||
* @author Mikolaj Izdebski | ||
*/ | ||
@Component( role = MojoExecutionConfigurator.class ) | ||
public class XMvnMojoExecutionConfigurator | ||
extends DefaultMojoExecutionConfigurator | ||
{ | ||
@Override | ||
public void configure( MavenProject project, MojoExecution execution, boolean allowPluginLevelConfig ) | ||
{ | ||
PluginDescriptor originalPluginDescriptor = execution.getMojoDescriptor().getPluginDescriptor(); | ||
|
||
PluginDescriptor aliasedPluginDescriptor = originalPluginDescriptor.clone(); | ||
aliasedPluginDescriptor.setGroupId( execution.getPlugin().getGroupId() ); | ||
aliasedPluginDescriptor.setArtifactId( execution.getPlugin().getArtifactId() ); | ||
|
||
try | ||
{ | ||
execution.getMojoDescriptor().setPluginDescriptor( aliasedPluginDescriptor ); | ||
super.configure( project, execution, allowPluginLevelConfig ); | ||
} | ||
finally | ||
{ | ||
execution.getMojoDescriptor().setPluginDescriptor( originalPluginDescriptor ); | ||
} | ||
} | ||
} |