mirror of https://github.com/apache/maven.git
o fix for testitMNG4091_InvalidDescriptor(org.apache.maven.it.MavenITmng4091BadPluginDescriptorTest)
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@777230 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6fe1debb60
commit
a06ce9250d
|
@ -46,6 +46,7 @@ import org.apache.maven.lifecycle.mapping.LifecycleMapping;
|
|||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.apache.maven.plugin.CycleDetectedInPluginGraphException;
|
||||
import org.apache.maven.plugin.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.MojoExecution;
|
||||
import org.apache.maven.plugin.MojoNotFoundException;
|
||||
import org.apache.maven.plugin.PluginDescriptorParsingException;
|
||||
|
@ -216,14 +217,14 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 1. Find the lifecycle given the phase (default lifecycle when given install)
|
||||
// 2. Find the lifecycle mapping that corresponds to the project packaging (jar lifecycle mapping given the jar packaging)
|
||||
// 3. Find the mojos associated with the lifecycle given the project packaging (jar lifecycle mapping for the default lifecycle)
|
||||
// 4. Bind those mojos found in the lifecycle mapping for the packaging to the lifecycle
|
||||
// 5. Bind mojos specified in the project itself to the lifecycle
|
||||
public List<MojoExecution> calculateBuildPlan( MavenSession session, String... tasks )
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException
|
||||
{
|
||||
MavenProject project = session.getCurrentProject();
|
||||
|
||||
|
@ -414,8 +415,7 @@ public class DefaultLifecycleExecutor
|
|||
}
|
||||
|
||||
private void populateMojoExecutionConfiguration( MavenProject project, MojoExecution mojoExecution )
|
||||
{
|
||||
|
||||
{
|
||||
String g = mojoExecution.getGroupId();
|
||||
|
||||
String a = mojoExecution.getArtifactId();
|
||||
|
@ -472,7 +472,7 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
// org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process
|
||||
MojoDescriptor getMojoDescriptor( String task, MavenSession session )
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException
|
||||
{
|
||||
MavenProject project = session.getCurrentProject();
|
||||
|
||||
|
@ -692,20 +692,26 @@ public class DefaultLifecycleExecutor
|
|||
plugin.getExecutions().add( execution );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void populateDefaultConfigurationForPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws LifecycleExecutionException
|
||||
{
|
||||
for( PluginExecution pluginExecution : plugin.getExecutions() )
|
||||
{
|
||||
for( String goal : pluginExecution.getGoals() )
|
||||
{
|
||||
Xpp3Dom dom = getDefaultPluginConfiguration( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion(), goal, localRepository, remoteRepositories );
|
||||
pluginExecution.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) pluginExecution.getConfiguration(), dom, Boolean.TRUE ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void populateDefaultConfigurationForPlugins( Collection<Plugin> plugins, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws LifecycleExecutionException
|
||||
{
|
||||
for( Plugin p : plugins )
|
||||
for( Plugin plugin : plugins )
|
||||
{
|
||||
for( PluginExecution e : p.getExecutions() )
|
||||
{
|
||||
for( String goal : e.getGoals() )
|
||||
{
|
||||
Xpp3Dom dom = getDefaultPluginConfiguration( p.getGroupId(), p.getArtifactId(), p.getVersion(), goal, localRepository, remoteRepositories );
|
||||
e.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) e.getConfiguration(), dom, Boolean.TRUE ) );
|
||||
}
|
||||
}
|
||||
populateDefaultConfigurationForPlugin( plugin, localRepository, remoteRepositories );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -735,6 +741,10 @@ public class DefaultLifecycleExecutor
|
|||
throw new LifecycleExecutionException( "Error getting default plugin information: ", e );
|
||||
}
|
||||
catch ( MojoNotFoundException e )
|
||||
{
|
||||
throw new LifecycleExecutionException( "Error getting default plugin information: ", e );
|
||||
}
|
||||
catch ( InvalidPluginDescriptorException e )
|
||||
{
|
||||
throw new LifecycleExecutionException( "Error getting default plugin information: ", e );
|
||||
}
|
||||
|
|
|
@ -27,15 +27,12 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
|||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.CycleDetectedInPluginGraphException;
|
||||
import org.apache.maven.plugin.InvalidPluginDescriptorException;
|
||||
import org.apache.maven.plugin.MojoExecution;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.plugin.MojoNotFoundException;
|
||||
import org.apache.maven.plugin.PluginDescriptorParsingException;
|
||||
import org.apache.maven.plugin.PluginNotFoundException;
|
||||
import org.apache.maven.plugin.PluginResolutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
/**
|
||||
* @author Jason van Zyl
|
||||
|
@ -50,10 +47,11 @@ public interface LifecycleExecutor
|
|||
* @param phase
|
||||
* @param session
|
||||
* @return
|
||||
* @throws InvalidPluginDescriptorException
|
||||
* @throws LifecycleExecutionException
|
||||
*/
|
||||
List<MojoExecution> calculateBuildPlan( MavenSession session, String... tasks )
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException;
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException;
|
||||
|
||||
// For a given project packaging find all the plugins that are bound to any registered
|
||||
// lifecycles. The project builder needs to now what default plugin information needs to be
|
||||
|
|
|
@ -127,12 +127,13 @@ public class DefaultPluginManager
|
|||
* @return PluginDescriptor The component descriptor for the Maven plugin.
|
||||
* @throws PluginNotFoundException The plugin could not be found in any repositories.
|
||||
* @throws PluginResolutionException The plugin could be found but could not be resolved.
|
||||
* @throws InvalidPluginDescriptorException
|
||||
* @throws PlexusConfigurationException A discovered component descriptor cannot be read, or or can't be parsed correctly. Shouldn't
|
||||
* happen but if someone has made a descriptor by hand it's possible.
|
||||
* @throws CycleDetectedInComponentGraphException A cycle has been detected in the component graph for a plugin that has been dynamically loaded.
|
||||
*/
|
||||
public PluginDescriptor loadPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, InvalidPluginDescriptorException
|
||||
{
|
||||
PluginDescriptor pluginDescriptor = getPluginDescriptor( plugin );
|
||||
|
||||
|
@ -197,10 +198,18 @@ public class DefaultPluginManager
|
|||
// Not going to happen
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String pluginKey = constructPluginKey( plugin );
|
||||
|
||||
// Check the internal consistent of a plugin descriptor when it is discovered. Most of the time the plugin descriptor is generated
|
||||
// by the maven-plugin-plugin, but if you happened to have created one by hand and it's incorrect this validator will report
|
||||
// the problem to the user.
|
||||
//
|
||||
MavenPluginValidator validator = new MavenPluginValidator( pluginArtifact );
|
||||
|
||||
try
|
||||
{
|
||||
container.discoverComponents( pluginRealm );
|
||||
container.discoverComponents( pluginRealm, validator );
|
||||
}
|
||||
catch ( PlexusConfigurationException e )
|
||||
{
|
||||
|
@ -211,7 +220,12 @@ public class DefaultPluginManager
|
|||
throw new CycleDetectedInPluginGraphException( plugin, e );
|
||||
}
|
||||
|
||||
pluginClassLoaderCache.put( constructPluginKey( plugin ), pluginRealm );
|
||||
if ( validator.hasErrors() )
|
||||
{
|
||||
throw new InvalidPluginDescriptorException( "Invalid Plugin Descriptor for " + pluginKey, validator.getErrors() );
|
||||
}
|
||||
|
||||
pluginClassLoaderCache.put( pluginKey, pluginRealm );
|
||||
|
||||
pluginDescriptor = getPluginDescriptor( plugin );
|
||||
pluginDescriptor.setArtifacts( new ArrayList<Artifact>( pluginArtifacts ) );
|
||||
|
@ -491,7 +505,7 @@ public class DefaultPluginManager
|
|||
}
|
||||
|
||||
public MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException
|
||||
{
|
||||
Plugin plugin = new Plugin();
|
||||
plugin.setGroupId( groupId );
|
||||
|
@ -502,7 +516,7 @@ public class DefaultPluginManager
|
|||
}
|
||||
|
||||
public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException
|
||||
{
|
||||
PluginDescriptor pluginDescriptor = loadPlugin( plugin, localRepository, remoteRepositories );
|
||||
|
||||
|
@ -614,6 +628,15 @@ public class DefaultPluginManager
|
|||
{
|
||||
PluginDescriptor pluginDescriptor = (PluginDescriptor) componentSetDescriptor;
|
||||
|
||||
MavenPluginValidator validator = (MavenPluginValidator) event.getData();
|
||||
|
||||
validator.validate( pluginDescriptor );
|
||||
|
||||
if ( validator.hasErrors() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String key = constructPluginKey( pluginDescriptor );
|
||||
|
||||
if ( !pluginsInProcess.contains( key ) )
|
||||
|
|
|
@ -46,13 +46,13 @@ public interface PluginManager
|
|||
// plugin configuration can't be parsed -- and this may be a result of client insertion of configuration
|
||||
// plugin component deps have a cycle -- this should be prevented for the most part but client code may inject an override component which itself has a cycle
|
||||
PluginDescriptor loadPlugin( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException;
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, InvalidPluginDescriptorException;
|
||||
|
||||
MojoDescriptor getMojoDescriptor( String groupId, String artifactId, String version, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException;
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException;
|
||||
|
||||
MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException;
|
||||
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, CycleDetectedInPluginGraphException, MojoNotFoundException, InvalidPluginDescriptorException;
|
||||
|
||||
// Why do we have a plugin execution exception as well?
|
||||
void executeMojo( MavenSession session, MojoExecution execution )
|
||||
|
|
Loading…
Reference in New Issue