mirror of https://github.com/apache/maven.git
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@750346 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8e7e771f81
commit
3efeef0d89
|
@ -151,9 +151,6 @@ public class DefaultPluginManager
|
|||
@Requirement
|
||||
private PluginManagerSupport pluginManagerSupport;
|
||||
|
||||
@Requirement
|
||||
private PluginRepository pluginRepository;
|
||||
|
||||
@Requirement
|
||||
private Logger logger;
|
||||
|
||||
|
|
|
@ -16,8 +16,9 @@ import java.util.Set;
|
|||
|
||||
@Component(role = PluginPrefixLoader.class)
|
||||
public class DefaultPluginPrefixLoader
|
||||
implements PluginPrefixLoader, LogEnabled
|
||||
implements PluginPrefixLoader
|
||||
{
|
||||
@Requirement
|
||||
private Logger logger;
|
||||
|
||||
@Requirement
|
||||
|
@ -41,9 +42,7 @@ public class DefaultPluginPrefixLoader
|
|||
* and try to resolve based on that.</li>
|
||||
* </ol>
|
||||
*/
|
||||
public Plugin findPluginForPrefix( String prefix,
|
||||
MavenProject project,
|
||||
MavenSession session )
|
||||
public Plugin findPluginForPrefix( String prefix, MavenProject project, MavenSession session )
|
||||
throws PluginLoaderException
|
||||
{
|
||||
Set descriptors = pluginCollector.getPluginDescriptorsForPrefix( prefix );
|
||||
|
@ -60,8 +59,7 @@ public class DefaultPluginPrefixLoader
|
|||
PluginDescriptor pd = (PluginDescriptor) it.next();
|
||||
|
||||
Plugin projectPlugin = (Plugin) projectPluginMap.get( pd.getPluginLookupKey() );
|
||||
if ( ( projectPlugin != null ) && ( projectPlugin.getVersion() != null )
|
||||
&& projectPlugin.getVersion().equals( pd.getVersion() ) )
|
||||
if ( ( projectPlugin != null ) && ( projectPlugin.getVersion() != null ) && projectPlugin.getVersion().equals( pd.getVersion() ) )
|
||||
{
|
||||
pluginDescriptor = pd;
|
||||
break;
|
||||
|
@ -89,9 +87,7 @@ public class DefaultPluginPrefixLoader
|
|||
plugin = new Plugin();
|
||||
plugin.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( prefix ) );
|
||||
|
||||
PluginDescriptor pluginDescriptor = pluginManagerSupport.loadIsolatedPluginDescriptor( plugin,
|
||||
project,
|
||||
session );
|
||||
PluginDescriptor pluginDescriptor = pluginManagerSupport.loadIsolatedPluginDescriptor( plugin, project, session );
|
||||
plugin = toPlugin( pluginDescriptor );
|
||||
}
|
||||
|
||||
|
@ -123,9 +119,7 @@ public class DefaultPluginPrefixLoader
|
|||
* Look for a plugin configured in the current project that has a prefix matching the one
|
||||
* specified. Return the {@link PluginDescriptor} if a match is found.
|
||||
*/
|
||||
private PluginDescriptor loadFromProjectForPrefixQuery( String prefix,
|
||||
MavenProject project,
|
||||
MavenSession session )
|
||||
private PluginDescriptor loadFromProjectForPrefixQuery( String prefix, MavenProject project, MavenSession session )
|
||||
throws PluginLoaderException
|
||||
{
|
||||
PluginDescriptor result = null;
|
||||
|
@ -152,15 +146,10 @@ public class DefaultPluginPrefixLoader
|
|||
* Look for a plugin in the pluginGroups specified in the settings.xml that has a prefix
|
||||
* matching the one specified. Return the {@link PluginDescriptor} if a match is found.
|
||||
*/
|
||||
private Plugin loadFromPrefixMapper( String prefix,
|
||||
MavenProject project,
|
||||
MavenSession session )
|
||||
private Plugin loadFromPrefixMapper( String prefix, MavenProject project, MavenSession session )
|
||||
throws PluginLoaderException
|
||||
{
|
||||
Plugin plugin = pluginMappingManager.getByPrefix( prefix,
|
||||
session.getPluginGroups(),
|
||||
project.getRemoteArtifactRepositories(),
|
||||
session.getLocalRepository() );
|
||||
Plugin plugin = pluginMappingManager.getByPrefix( prefix, session.getPluginGroups(), project.getRemoteArtifactRepositories(), session.getLocalRepository() );
|
||||
|
||||
if ( plugin != null )
|
||||
{
|
||||
|
@ -173,10 +162,4 @@ public class DefaultPluginPrefixLoader
|
|||
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public void enableLogging( Logger logger )
|
||||
{
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import java.util.List;
|
||||
import java.io.StringReader;
|
||||
|
||||
@Component( role = PluginRepository.class)
|
||||
public class DefaultPluginRepository implements PluginRepository
|
||||
{
|
||||
@Requirement
|
||||
protected MavenPluginCollector pluginCollector;
|
||||
|
||||
public Plugin findPluginById(String id, String mojoId) throws Exception
|
||||
{
|
||||
if(pluginCollector == null)
|
||||
{
|
||||
throw new IllegalArgumentException("pluginCollector: null");
|
||||
}
|
||||
|
||||
if(id == null)
|
||||
{
|
||||
throw new IllegalArgumentException("id: null");
|
||||
}
|
||||
|
||||
String[] token = id.split(":");
|
||||
if(token.length != 3)
|
||||
{
|
||||
throw new IllegalArgumentException("id: does not include complete id");
|
||||
}
|
||||
|
||||
Plugin plugin = new Plugin();
|
||||
plugin.setGroupId(token[0]);
|
||||
plugin.setArtifactId(token[1]);
|
||||
plugin.setVersion(token[2]);
|
||||
|
||||
PluginDescriptor descriptor = pluginCollector.getPluginDescriptor(plugin);
|
||||
if(descriptor == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
for(MojoDescriptor mojo : (List<MojoDescriptor>) descriptor.getMojos())
|
||||
{
|
||||
if(mojo.getId().equals(mojoId) && mojo.getMojoConfiguration() != null)
|
||||
{
|
||||
plugin.setConfiguration(Xpp3DomBuilder.build( new StringReader( mojo.getMojoConfiguration().toString() ) ));
|
||||
}
|
||||
}
|
||||
|
||||
return plugin;
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.codehaus.plexus.configuration.PlexusConfigurationException;
|
||||
|
||||
|
||||
public interface PluginRepository {
|
||||
|
||||
Plugin findPluginById(String pluginId, String mojoId) throws Exception;
|
||||
}
|
Loading…
Reference in New Issue