This commit is contained in:
Jason van Zyl 2009-03-05 07:11:59 +00:00
parent 8e7e771f81
commit 3efeef0d89
4 changed files with 8 additions and 95 deletions

View File

@ -151,9 +151,6 @@ public class DefaultPluginManager
@Requirement @Requirement
private PluginManagerSupport pluginManagerSupport; private PluginManagerSupport pluginManagerSupport;
@Requirement
private PluginRepository pluginRepository;
@Requirement @Requirement
private Logger logger; private Logger logger;

View File

@ -16,8 +16,9 @@ import java.util.Set;
@Component(role = PluginPrefixLoader.class) @Component(role = PluginPrefixLoader.class)
public class DefaultPluginPrefixLoader public class DefaultPluginPrefixLoader
implements PluginPrefixLoader, LogEnabled implements PluginPrefixLoader
{ {
@Requirement
private Logger logger; private Logger logger;
@Requirement @Requirement
@ -41,9 +42,7 @@ public class DefaultPluginPrefixLoader
* and try to resolve based on that.</li> * and try to resolve based on that.</li>
* </ol> * </ol>
*/ */
public Plugin findPluginForPrefix( String prefix, public Plugin findPluginForPrefix( String prefix, MavenProject project, MavenSession session )
MavenProject project,
MavenSession session )
throws PluginLoaderException throws PluginLoaderException
{ {
Set descriptors = pluginCollector.getPluginDescriptorsForPrefix( prefix ); Set descriptors = pluginCollector.getPluginDescriptorsForPrefix( prefix );
@ -60,8 +59,7 @@ public class DefaultPluginPrefixLoader
PluginDescriptor pd = (PluginDescriptor) it.next(); PluginDescriptor pd = (PluginDescriptor) it.next();
Plugin projectPlugin = (Plugin) projectPluginMap.get( pd.getPluginLookupKey() ); Plugin projectPlugin = (Plugin) projectPluginMap.get( pd.getPluginLookupKey() );
if ( ( projectPlugin != null ) && ( projectPlugin.getVersion() != null ) if ( ( projectPlugin != null ) && ( projectPlugin.getVersion() != null ) && projectPlugin.getVersion().equals( pd.getVersion() ) )
&& projectPlugin.getVersion().equals( pd.getVersion() ) )
{ {
pluginDescriptor = pd; pluginDescriptor = pd;
break; break;
@ -89,9 +87,7 @@ public class DefaultPluginPrefixLoader
plugin = new Plugin(); plugin = new Plugin();
plugin.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( prefix ) ); plugin.setArtifactId( PluginDescriptor.getDefaultPluginArtifactId( prefix ) );
PluginDescriptor pluginDescriptor = pluginManagerSupport.loadIsolatedPluginDescriptor( plugin, PluginDescriptor pluginDescriptor = pluginManagerSupport.loadIsolatedPluginDescriptor( plugin, project, session );
project,
session );
plugin = toPlugin( pluginDescriptor ); 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 * 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. * specified. Return the {@link PluginDescriptor} if a match is found.
*/ */
private PluginDescriptor loadFromProjectForPrefixQuery( String prefix, private PluginDescriptor loadFromProjectForPrefixQuery( String prefix, MavenProject project, MavenSession session )
MavenProject project,
MavenSession session )
throws PluginLoaderException throws PluginLoaderException
{ {
PluginDescriptor result = null; 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 * 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. * matching the one specified. Return the {@link PluginDescriptor} if a match is found.
*/ */
private Plugin loadFromPrefixMapper( String prefix, private Plugin loadFromPrefixMapper( String prefix, MavenProject project, MavenSession session )
MavenProject project,
MavenSession session )
throws PluginLoaderException throws PluginLoaderException
{ {
Plugin plugin = pluginMappingManager.getByPrefix( prefix, Plugin plugin = pluginMappingManager.getByPrefix( prefix, session.getPluginGroups(), project.getRemoteArtifactRepositories(), session.getLocalRepository() );
session.getPluginGroups(),
project.getRemoteArtifactRepositories(),
session.getLocalRepository() );
if ( plugin != null ) if ( plugin != null )
{ {
@ -173,10 +162,4 @@ public class DefaultPluginPrefixLoader
return plugin; return plugin;
} }
public void enableLogging( Logger logger )
{
this.logger = logger;
}
} }

View File

@ -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;
}
}

View File

@ -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;
}