mirror of https://github.com/apache/maven.git
PR: MNG-122
exception clean up phase 2 git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@320675 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5de6418c69
commit
1901992586
|
@ -32,6 +32,7 @@ import org.apache.maven.artifact.resolver.filter.TypeArtifactFilter;
|
||||||
import org.apache.maven.model.Dependency;
|
import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.model.Repository;
|
import org.apache.maven.model.Repository;
|
||||||
import org.apache.maven.project.MavenProjectBuilder;
|
import org.apache.maven.project.MavenProjectBuilder;
|
||||||
|
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
|
@ -172,6 +173,10 @@ public class DependenciesTask
|
||||||
// TODO: improve handling
|
// TODO: improve handling
|
||||||
throw new BuildException( "Unable to locate artifact", e );
|
throw new BuildException( "Unable to locate artifact", e );
|
||||||
}
|
}
|
||||||
|
catch ( InvalidDependencyVersionException e )
|
||||||
|
{
|
||||||
|
throw new BuildException( e.getMessage(), e );
|
||||||
|
}
|
||||||
|
|
||||||
if ( pathId != null && getProject().getReference( pathId ) != null )
|
if ( pathId != null && getProject().getReference( pathId ) != null )
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ package org.apache.maven;
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class BuildFailureException
|
public class BuildFailureException
|
||||||
extends Throwable
|
extends Exception
|
||||||
{
|
{
|
||||||
public BuildFailureException( String message )
|
public BuildFailureException( String message )
|
||||||
{
|
{
|
||||||
|
|
|
@ -196,6 +196,10 @@ public class DefaultMaven
|
||||||
{
|
{
|
||||||
return dispatchErrorResponse( dispatcher, event, request.getBaseDirectory(), e );
|
return dispatchErrorResponse( dispatcher, event, request.getBaseDirectory(), e );
|
||||||
}
|
}
|
||||||
|
catch ( BuildFailureException e )
|
||||||
|
{
|
||||||
|
return dispatchErrorResponse( dispatcher, event, request.getBaseDirectory(), e );
|
||||||
|
}
|
||||||
|
|
||||||
ReactorManager rm;
|
ReactorManager rm;
|
||||||
try
|
try
|
||||||
|
@ -409,7 +413,7 @@ public class DefaultMaven
|
||||||
private List collectProjects( List files, ArtifactRepository localRepository, boolean recursive, Settings settings,
|
private List collectProjects( List files, ArtifactRepository localRepository, boolean recursive, Settings settings,
|
||||||
ProfileManager globalProfileManager, boolean isRoot )
|
ProfileManager globalProfileManager, boolean isRoot )
|
||||||
throws ArtifactResolutionException, ProjectBuildingException, ProfileActivationException,
|
throws ArtifactResolutionException, ProjectBuildingException, ProfileActivationException,
|
||||||
MavenExecutionException
|
MavenExecutionException, BuildFailureException
|
||||||
{
|
{
|
||||||
List projects = new ArrayList( files.size() );
|
List projects = new ArrayList( files.size() );
|
||||||
|
|
||||||
|
@ -435,17 +439,10 @@ public class DefaultMaven
|
||||||
if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null )
|
if ( project.getPrerequisites() != null && project.getPrerequisites().getMaven() != null )
|
||||||
{
|
{
|
||||||
DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() );
|
DefaultArtifactVersion version = new DefaultArtifactVersion( project.getPrerequisites().getMaven() );
|
||||||
try
|
if ( runtimeInformation.getApplicationVersion().compareTo( version ) < 0 )
|
||||||
{
|
{
|
||||||
if ( runtimeInformation.getApplicationVersion().compareTo( version ) < 0 )
|
throw new BuildFailureException( "Unable to build project '" + project.getFile() +
|
||||||
{
|
"; it requires Maven version " + version.toString() );
|
||||||
throw new ProjectBuildingException( project.getId(), "Unable to build project '" +
|
|
||||||
project.getFile() + "; it requires Maven version " + version.toString() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new MavenExecutionException( "Unable to get Maven application version", e );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,12 @@ package org.apache.maven.execution;
|
||||||
|
|
||||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||||
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||||
|
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,30 +33,41 @@ import java.util.Properties;
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class DefaultRuntimeInformation
|
public class DefaultRuntimeInformation
|
||||||
implements RuntimeInformation
|
implements RuntimeInformation, Initializable
|
||||||
{
|
{
|
||||||
private ArtifactVersion applicationVersion;
|
private ArtifactVersion applicationVersion;
|
||||||
|
|
||||||
public ArtifactVersion getApplicationVersion()
|
public ArtifactVersion getApplicationVersion()
|
||||||
throws IOException
|
|
||||||
{
|
{
|
||||||
if ( applicationVersion == null )
|
|
||||||
{
|
|
||||||
InputStream resourceAsStream = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Properties properties = new Properties();
|
|
||||||
resourceAsStream = getClass().getClassLoader().getResourceAsStream(
|
|
||||||
"META-INF/maven/org.apache.maven/maven-core/pom.properties" );
|
|
||||||
properties.load( resourceAsStream );
|
|
||||||
|
|
||||||
applicationVersion = new DefaultArtifactVersion( properties.getProperty( "version" ) );
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
IOUtil.close( resourceAsStream );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return applicationVersion;
|
return applicationVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initialize()
|
||||||
|
throws InitializationException
|
||||||
|
{
|
||||||
|
InputStream resourceAsStream = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Properties properties = new Properties();
|
||||||
|
resourceAsStream = getClass().getClassLoader().getResourceAsStream(
|
||||||
|
"META-INF/maven/org.apache.maven/maven-core/pom.properties" );
|
||||||
|
properties.load( resourceAsStream );
|
||||||
|
|
||||||
|
String property = properties.getProperty( "version" );
|
||||||
|
if ( property == null )
|
||||||
|
{
|
||||||
|
throw new InitializationException( "maven-core properties did not include the version" );
|
||||||
|
}
|
||||||
|
|
||||||
|
applicationVersion = new DefaultArtifactVersion( property );
|
||||||
|
}
|
||||||
|
catch ( IOException e )
|
||||||
|
{
|
||||||
|
throw new InitializationException( "Unable to read properties file from maven-core", e );
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IOUtil.close( resourceAsStream );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ package org.apache.maven.execution;
|
||||||
|
|
||||||
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
import org.apache.maven.artifact.versioning.ArtifactVersion;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes runtime information about the application.
|
* Describes runtime information about the application.
|
||||||
*
|
*
|
||||||
|
@ -28,6 +26,5 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public interface RuntimeInformation
|
public interface RuntimeInformation
|
||||||
{
|
{
|
||||||
ArtifactVersion getApplicationVersion()
|
ArtifactVersion getApplicationVersion();
|
||||||
throws IOException;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,11 @@ import org.apache.maven.model.ReportPlugin;
|
||||||
import org.apache.maven.model.ReportSet;
|
import org.apache.maven.model.ReportSet;
|
||||||
import org.apache.maven.monitor.event.EventDispatcher;
|
import org.apache.maven.monitor.event.EventDispatcher;
|
||||||
import org.apache.maven.monitor.event.MavenEvents;
|
import org.apache.maven.monitor.event.MavenEvents;
|
||||||
|
import org.apache.maven.plugin.InvalidPluginException;
|
||||||
import org.apache.maven.plugin.MojoExecution;
|
import org.apache.maven.plugin.MojoExecution;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
|
import org.apache.maven.plugin.PluginConfigurationException;
|
||||||
import org.apache.maven.plugin.PluginManager;
|
import org.apache.maven.plugin.PluginManager;
|
||||||
import org.apache.maven.plugin.PluginManagerException;
|
import org.apache.maven.plugin.PluginManagerException;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
|
@ -46,6 +48,7 @@ import org.apache.maven.plugin.lifecycle.Execution;
|
||||||
import org.apache.maven.plugin.lifecycle.Phase;
|
import org.apache.maven.plugin.lifecycle.Phase;
|
||||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||||
import org.apache.maven.reporting.MavenReport;
|
import org.apache.maven.reporting.MavenReport;
|
||||||
import org.apache.maven.settings.Settings;
|
import org.apache.maven.settings.Settings;
|
||||||
import org.codehaus.plexus.PlexusContainerException;
|
import org.codehaus.plexus.PlexusContainerException;
|
||||||
|
@ -368,6 +371,13 @@ public class DefaultLifecycleExecutor
|
||||||
// TODO: should be dispatchFailure?
|
// TODO: should be dispatchFailure?
|
||||||
dispatcher.dispatchError( event, target, e );
|
dispatcher.dispatchError( event, target, e );
|
||||||
|
|
||||||
|
handleExecutionFailure( rm, project, e, task, buildStartTime );
|
||||||
|
}
|
||||||
|
catch ( InvalidDependencyVersionException e )
|
||||||
|
{
|
||||||
|
// TODO: should be dispatchFailure?
|
||||||
|
dispatcher.dispatchError( event, target, e );
|
||||||
|
|
||||||
handleExecutionFailure( rm, project, e, task, buildStartTime );
|
handleExecutionFailure( rm, project, e, task, buildStartTime );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -516,7 +526,7 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
private void executeGoal( String task, MavenSession session, MavenProject project, MavenExecutionResponse response )
|
private void executeGoal( String task, MavenSession session, MavenProject project, MavenExecutionResponse response )
|
||||||
throws LifecycleExecutionException, ArtifactNotFoundException, MojoExecutionException,
|
throws LifecycleExecutionException, ArtifactNotFoundException, MojoExecutionException,
|
||||||
ArtifactResolutionException, MojoFailureException
|
ArtifactResolutionException, MojoFailureException, InvalidDependencyVersionException
|
||||||
{
|
{
|
||||||
if ( getPhaseToLifecycleMap().containsKey( task ) )
|
if ( getPhaseToLifecycleMap().containsKey( task ) )
|
||||||
{
|
{
|
||||||
|
@ -535,7 +545,7 @@ public class DefaultLifecycleExecutor
|
||||||
private void executeGoalWithLifecycle( String task, MavenSession session, Map lifecycleMappings,
|
private void executeGoalWithLifecycle( String task, MavenSession session, Map lifecycleMappings,
|
||||||
MavenProject project, MavenExecutionResponse response, Lifecycle lifecycle )
|
MavenProject project, MavenExecutionResponse response, Lifecycle lifecycle )
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
|
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
|
||||||
ArtifactNotFoundException
|
ArtifactNotFoundException, InvalidDependencyVersionException
|
||||||
{
|
{
|
||||||
List goals = processGoalChain( task, lifecycleMappings, lifecycle );
|
List goals = processGoalChain( task, lifecycleMappings, lifecycle );
|
||||||
|
|
||||||
|
@ -552,7 +562,7 @@ public class DefaultLifecycleExecutor
|
||||||
private void executeStandaloneGoal( String task, MavenSession session, MavenProject project,
|
private void executeStandaloneGoal( String task, MavenSession session, MavenProject project,
|
||||||
MavenExecutionResponse response )
|
MavenExecutionResponse response )
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
|
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
|
||||||
ArtifactNotFoundException
|
ArtifactNotFoundException, InvalidDependencyVersionException
|
||||||
{
|
{
|
||||||
// guaranteed to come from the CLI and not be part of a phase
|
// guaranteed to come from the CLI and not be part of a phase
|
||||||
MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project, task, true );
|
MojoDescriptor mojoDescriptor = getMojoDescriptor( task, session, project, task, true );
|
||||||
|
@ -561,7 +571,7 @@ public class DefaultLifecycleExecutor
|
||||||
|
|
||||||
private void executeGoals( List goals, MavenSession session, MavenProject project, MavenExecutionResponse response )
|
private void executeGoals( List goals, MavenSession session, MavenProject project, MavenExecutionResponse response )
|
||||||
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException, MojoFailureException,
|
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException, MojoFailureException,
|
||||||
ArtifactNotFoundException
|
ArtifactNotFoundException, InvalidDependencyVersionException
|
||||||
{
|
{
|
||||||
for ( Iterator i = goals.iterator(); i.hasNext(); )
|
for ( Iterator i = goals.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -598,8 +608,8 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
catch ( PluginManagerException e )
|
catch ( PluginManagerException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException(
|
throw new LifecycleExecutionException( "Internal error in the plugin manager executing goal '" +
|
||||||
"Internal error in the plugin manager executing goal '" + mojoDescriptor.getId(), e );
|
mojoDescriptor.getId() + "': " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -724,6 +734,11 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( PluginManagerException e )
|
catch ( PluginManagerException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException(
|
||||||
|
"Error getting reports from the plugin '" + reportPlugin.getKey() + "': " + e.getMessage(), e );
|
||||||
|
}
|
||||||
|
catch ( PluginConfigurationException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException(
|
throw new LifecycleExecutionException(
|
||||||
"Error getting reports from the plugin '" + reportPlugin.getKey() + "'", e );
|
"Error getting reports from the plugin '" + reportPlugin.getKey() + "'", e );
|
||||||
|
@ -736,7 +751,7 @@ public class DefaultLifecycleExecutor
|
||||||
private void forkLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project,
|
private void forkLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project,
|
||||||
MavenExecutionResponse response )
|
MavenExecutionResponse response )
|
||||||
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException, MojoFailureException,
|
throws LifecycleExecutionException, MojoExecutionException, ArtifactResolutionException, MojoFailureException,
|
||||||
ArtifactNotFoundException
|
ArtifactNotFoundException, InvalidDependencyVersionException
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
||||||
getLogger().info( "Preparing " + pluginDescriptor.getGoalPrefix() + ":" + mojoDescriptor.getGoal() );
|
getLogger().info( "Preparing " + pluginDescriptor.getGoalPrefix() + ":" + mojoDescriptor.getGoal() );
|
||||||
|
@ -767,7 +782,7 @@ public class DefaultLifecycleExecutor
|
||||||
private void forkProjectLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project,
|
private void forkProjectLifecycle( MojoDescriptor mojoDescriptor, MavenSession session, MavenProject project,
|
||||||
MavenExecutionResponse response )
|
MavenExecutionResponse response )
|
||||||
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
|
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
|
||||||
ArtifactNotFoundException
|
ArtifactNotFoundException, InvalidDependencyVersionException
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
||||||
|
|
||||||
|
@ -1015,7 +1030,9 @@ public class DefaultLifecycleExecutor
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException, LifecycleExecutionException
|
throws ArtifactResolutionException, ArtifactNotFoundException, LifecycleExecutionException
|
||||||
{
|
{
|
||||||
for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
|
Object pluginComponent = null;
|
||||||
|
|
||||||
|
for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext() && pluginComponent == null; )
|
||||||
{
|
{
|
||||||
Plugin plugin = (Plugin) i.next();
|
Plugin plugin = (Plugin) i.next();
|
||||||
|
|
||||||
|
@ -1026,7 +1043,7 @@ public class DefaultLifecycleExecutor
|
||||||
// TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly
|
// TODO: if moved to the plugin manager we already have the descriptor from above and so do can lookup the container directly
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return pluginManager.getPluginComponent( plugin, role, roleHint );
|
pluginComponent = pluginManager.getPluginComponent( plugin, role, roleHint );
|
||||||
}
|
}
|
||||||
catch ( ComponentLookupException e )
|
catch ( ComponentLookupException e )
|
||||||
{
|
{
|
||||||
|
@ -1035,11 +1052,11 @@ public class DefaultLifecycleExecutor
|
||||||
catch ( PluginManagerException e )
|
catch ( PluginManagerException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException(
|
throw new LifecycleExecutionException(
|
||||||
"Error getting extensions from the plugin '" + plugin.getKey() + "'", e );
|
"Error getting extensions from the plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return pluginComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1070,7 +1087,8 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
catch ( PluginManagerException e )
|
catch ( PluginManagerException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Error looking up available components from a plugin", e );
|
throw new LifecycleExecutionException( "Error looking up available components from plugin '" +
|
||||||
|
plugin.getKey() + "': " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
// shudder...
|
// shudder...
|
||||||
|
@ -1140,7 +1158,8 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
catch ( PluginManagerException e )
|
catch ( PluginManagerException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
|
throw new LifecycleExecutionException(
|
||||||
|
"Internal error in the plugin manager getting plugin '" + plugin.getKey() + "': " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
catch ( PluginVersionResolutionException e )
|
catch ( PluginVersionResolutionException e )
|
||||||
{
|
{
|
||||||
|
@ -1150,6 +1169,10 @@ public class DefaultLifecycleExecutor
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
||||||
}
|
}
|
||||||
|
catch ( InvalidPluginException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
||||||
|
}
|
||||||
return pluginDescriptor;
|
return pluginDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1163,7 +1186,8 @@ public class DefaultLifecycleExecutor
|
||||||
}
|
}
|
||||||
catch ( PluginManagerException e )
|
catch ( PluginManagerException e )
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Internal error in the plugin manager", e );
|
throw new LifecycleExecutionException(
|
||||||
|
"Internal error in the plugin manager getting report '" + plugin.getKey() + "': " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
catch ( PluginVersionResolutionException e )
|
catch ( PluginVersionResolutionException e )
|
||||||
{
|
{
|
||||||
|
@ -1173,6 +1197,10 @@ public class DefaultLifecycleExecutor
|
||||||
{
|
{
|
||||||
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
||||||
}
|
}
|
||||||
|
catch ( InvalidPluginException e )
|
||||||
|
{
|
||||||
|
throw new LifecycleExecutionException( "Error resolving plugin version", e );
|
||||||
|
}
|
||||||
return pluginDescriptor;
|
return pluginDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1293,15 +1321,7 @@ public class DefaultLifecycleExecutor
|
||||||
// 2. look in the repository via search groups
|
// 2. look in the repository via search groups
|
||||||
if ( pluginDescriptor == null )
|
if ( pluginDescriptor == null )
|
||||||
{
|
{
|
||||||
try
|
plugin = pluginManager.getPluginDefinitionForPrefix( prefix, session, project );
|
||||||
{
|
|
||||||
plugin = pluginManager.getPluginDefinitionForPrefix( prefix, session, project );
|
|
||||||
}
|
|
||||||
catch ( PluginManagerException e )
|
|
||||||
{
|
|
||||||
throw new LifecycleExecutionException(
|
|
||||||
"Cannot resolve plugin-prefix: \'" + prefix + "\' from plugin mappings metadata.", e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -49,6 +49,7 @@ import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.MavenProjectBuilder;
|
import org.apache.maven.project.MavenProjectBuilder;
|
||||||
import org.apache.maven.project.ProjectBuildingException;
|
import org.apache.maven.project.ProjectBuildingException;
|
||||||
|
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||||
import org.apache.maven.project.path.PathTranslator;
|
import org.apache.maven.project.path.PathTranslator;
|
||||||
import org.apache.maven.reporting.MavenReport;
|
import org.apache.maven.reporting.MavenReport;
|
||||||
|
@ -74,7 +75,6 @@ import org.codehaus.plexus.util.StringUtils;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -136,7 +136,6 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project )
|
public Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project )
|
||||||
throws PluginManagerException
|
|
||||||
{
|
{
|
||||||
// TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other
|
// TODO: since this is only used in the lifecycle executor, maybe it should be moved there? There is no other
|
||||||
// use for the mapping manager in here
|
// use for the mapping manager in here
|
||||||
|
@ -147,8 +146,8 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
public PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException,
|
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
|
||||||
ArtifactNotFoundException, InvalidVersionSpecificationException
|
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException
|
||||||
{
|
{
|
||||||
// TODO: this should be possibly outside
|
// TODO: this should be possibly outside
|
||||||
// All version-resolution logic has been moved to DefaultPluginVersionManager.
|
// All version-resolution logic has been moved to DefaultPluginVersionManager.
|
||||||
|
@ -164,8 +163,8 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
private PluginDescriptor verifyVersionedPlugin( Plugin plugin, MavenProject project,
|
private PluginDescriptor verifyVersionedPlugin( Plugin plugin, MavenProject project,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws PluginVersionResolutionException, PluginManagerException, ArtifactNotFoundException,
|
throws PluginVersionResolutionException, ArtifactNotFoundException, ArtifactResolutionException,
|
||||||
ArtifactResolutionException, InvalidVersionSpecificationException
|
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException
|
||||||
{
|
{
|
||||||
// TODO: this might result in an artifact "RELEASE" being resolved continuously
|
// TODO: this might result in an artifact "RELEASE" being resolved continuously
|
||||||
// FIXME: need to find out how a plugin gets marked as 'installed'
|
// FIXME: need to find out how a plugin gets marked as 'installed'
|
||||||
|
@ -239,7 +238,7 @@ public class DefaultPluginManager
|
||||||
* manager which executes before the plugin is instantiated
|
* manager which executes before the plugin is instantiated
|
||||||
*/
|
*/
|
||||||
private void checkRequiredMavenVersion( Plugin plugin, ArtifactRepository localRepository, List remoteRepositories )
|
private void checkRequiredMavenVersion( Plugin plugin, ArtifactRepository localRepository, List remoteRepositories )
|
||||||
throws PluginVersionResolutionException, PluginManagerException
|
throws PluginVersionResolutionException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -264,15 +263,11 @@ public class DefaultPluginManager
|
||||||
throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(),
|
throw new PluginVersionResolutionException( plugin.getGroupId(), plugin.getArtifactId(),
|
||||||
"Unable to build project for plugin", e );
|
"Unable to build project for plugin", e );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new PluginManagerException( "Unable to determine Maven version for comparison", e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addPlugin( Plugin plugin, Artifact pluginArtifact, MavenProject project,
|
protected void addPlugin( Plugin plugin, Artifact pluginArtifact, MavenProject project,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, PluginManagerException, ArtifactNotFoundException
|
throws PluginManagerException, InvalidPluginException
|
||||||
{
|
{
|
||||||
PlexusContainer child;
|
PlexusContainer child;
|
||||||
try
|
try
|
||||||
|
@ -284,7 +279,8 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
catch ( PlexusContainerException e )
|
catch ( PlexusContainerException e )
|
||||||
{
|
{
|
||||||
throw new PluginManagerException( "Failed to create plugin container for plugin '" + plugin + "'", e );
|
throw new PluginManagerException(
|
||||||
|
"Failed to create plugin container for plugin '" + plugin + "': " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
// this plugin's descriptor should have been discovered in the child creation, so we should be able to
|
// this plugin's descriptor should have been discovered in the child creation, so we should be able to
|
||||||
|
@ -305,9 +301,9 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
addedPlugin.setIntroducedDependencyArtifacts( artifacts );
|
addedPlugin.setIntroducedDependencyArtifacts( artifacts );
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( InvalidDependencyVersionException e )
|
||||||
{
|
{
|
||||||
throw new PluginManagerException( "Error getting plugin dependencies", e );
|
throw new InvalidPluginException( "Plugin '" + plugin + "' is invalid: " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,8 +312,8 @@ public class DefaultPluginManager
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public void executeMojo( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
public void executeMojo( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
||||||
throws ArtifactResolutionException, PluginManagerException, MojoExecutionException, MojoFailureException,
|
throws ArtifactResolutionException, MojoExecutionException, MojoFailureException, ArtifactNotFoundException,
|
||||||
ArtifactNotFoundException
|
InvalidDependencyVersionException, PluginManagerException
|
||||||
{
|
{
|
||||||
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
||||||
|
|
||||||
|
@ -352,16 +348,8 @@ public class DefaultPluginManager
|
||||||
for ( Iterator i = projects.iterator(); i.hasNext(); )
|
for ( Iterator i = projects.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
MavenProject p = (MavenProject) i.next();
|
MavenProject p = (MavenProject) i.next();
|
||||||
try
|
resolveTransitiveDependencies( session, artifactResolver,
|
||||||
{
|
mojoDescriptor.isDependencyResolutionRequired(), artifactFactory, p );
|
||||||
resolveTransitiveDependencies( session, artifactResolver,
|
|
||||||
mojoDescriptor.isDependencyResolutionRequired(), artifactFactory,
|
|
||||||
p );
|
|
||||||
}
|
|
||||||
catch ( ProjectBuildingException e )
|
|
||||||
{
|
|
||||||
throw new PluginManagerException( e.getMessage(), e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadDependencies( project, session, artifactResolver );
|
downloadDependencies( project, session, artifactResolver );
|
||||||
|
@ -393,10 +381,6 @@ public class DefaultPluginManager
|
||||||
String msg = "Error configuring plugin for execution of '" + goalName + "'.";
|
String msg = "Error configuring plugin for execution of '" + goalName + "'.";
|
||||||
throw new MojoExecutionException( msg, e );
|
throw new MojoExecutionException( msg, e );
|
||||||
}
|
}
|
||||||
catch ( ComponentLookupException e )
|
|
||||||
{
|
|
||||||
throw new MojoExecutionException( "Error looking up mojo: " + goalName, e );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event monitoring.
|
// Event monitoring.
|
||||||
String event = MavenEvents.MOJO_EXECUTION;
|
String event = MavenEvents.MOJO_EXECUTION;
|
||||||
|
@ -456,7 +440,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
public MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
||||||
throws PluginManagerException, ArtifactNotFoundException
|
throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException
|
||||||
{
|
{
|
||||||
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
||||||
PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor();
|
PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor();
|
||||||
|
@ -467,25 +451,12 @@ public class DefaultPluginManager
|
||||||
dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
|
dom = Xpp3Dom.mergeXpp3Dom( dom, mojoExecution.getConfiguration() );
|
||||||
}
|
}
|
||||||
|
|
||||||
MavenReport reportMojo;
|
return (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution );
|
||||||
try
|
|
||||||
{
|
|
||||||
reportMojo = (MavenReport) getConfiguredMojo( session, dom, project, true, mojoExecution );
|
|
||||||
}
|
|
||||||
catch ( ComponentLookupException e )
|
|
||||||
{
|
|
||||||
throw new PluginManagerException( "Error looking up report: ", e );
|
|
||||||
}
|
|
||||||
catch ( PluginConfigurationException e )
|
|
||||||
{
|
|
||||||
throw new PluginManagerException( "Error configuring report: ", e );
|
|
||||||
}
|
|
||||||
return reportMojo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
|
public PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
|
||||||
throws PluginVersionResolutionException, ArtifactResolutionException, PluginManagerException,
|
throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException,
|
||||||
ArtifactNotFoundException, InvalidVersionSpecificationException
|
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException
|
||||||
{
|
{
|
||||||
String version = reportPlugin.getVersion();
|
String version = reportPlugin.getVersion();
|
||||||
|
|
||||||
|
@ -516,7 +487,7 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
if ( pluginContainer == null )
|
if ( pluginContainer == null )
|
||||||
{
|
{
|
||||||
throw new PluginManagerException( "Cannot find PlexusContainer for plugin: " + pluginKey );
|
throw new PluginManagerException( "Cannot find Plexus container for plugin: " + pluginKey );
|
||||||
}
|
}
|
||||||
|
|
||||||
return pluginContainer;
|
return pluginContainer;
|
||||||
|
@ -524,7 +495,7 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom, MavenProject project, boolean report,
|
private Mojo getConfiguredMojo( MavenSession session, Xpp3Dom dom, MavenProject project, boolean report,
|
||||||
MojoExecution mojoExecution )
|
MojoExecution mojoExecution )
|
||||||
throws ComponentLookupException, PluginConfigurationException, PluginManagerException, ArtifactNotFoundException
|
throws PluginConfigurationException, ArtifactNotFoundException, PluginManagerException
|
||||||
{
|
{
|
||||||
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
||||||
|
|
||||||
|
@ -537,11 +508,20 @@ public class DefaultPluginManager
|
||||||
// dependencies, and add them to the container.
|
// dependencies, and add them to the container.
|
||||||
ensurePluginContainerIsComplete( pluginDescriptor, pluginContainer, project, session );
|
ensurePluginContainerIsComplete( pluginDescriptor, pluginContainer, project, session );
|
||||||
|
|
||||||
Mojo plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
|
Mojo plugin;
|
||||||
if ( report && !( plugin instanceof MavenReport ) )
|
try
|
||||||
{
|
{
|
||||||
// TODO: the mojoDescriptor should actually capture this information so we don't get this far
|
plugin = (Mojo) pluginContainer.lookup( Mojo.ROLE, mojoDescriptor.getRoleHint() );
|
||||||
return null;
|
if ( report && !( plugin instanceof MavenReport ) )
|
||||||
|
{
|
||||||
|
// TODO: the mojoDescriptor should actually capture this information so we don't get this far
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( ComponentLookupException e )
|
||||||
|
{
|
||||||
|
throw new PluginManagerException( "Unable to find the mojo '" + mojoDescriptor.getRoleHint() +
|
||||||
|
"' in the plugin '" + pluginDescriptor.getPluginLookupKey() + "'", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( plugin instanceof ContextEnabled )
|
if ( plugin instanceof ContextEnabled )
|
||||||
|
@ -1155,7 +1135,7 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver, String scope,
|
private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver, String scope,
|
||||||
ArtifactFactory artifactFactory, MavenProject project )
|
ArtifactFactory artifactFactory, MavenProject project )
|
||||||
throws ArtifactResolutionException, ArtifactNotFoundException, ProjectBuildingException
|
throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException
|
||||||
{
|
{
|
||||||
ArtifactFilter filter = new ScopeArtifactFilter( scope );
|
ArtifactFilter filter = new ScopeArtifactFilter( scope );
|
||||||
|
|
||||||
|
@ -1197,7 +1177,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getPluginComponent( Plugin plugin, String role, String roleHint )
|
public Object getPluginComponent( Plugin plugin, String role, String roleHint )
|
||||||
throws ComponentLookupException, PluginManagerException
|
throws PluginManagerException, ComponentLookupException
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin );
|
PluginDescriptor pluginDescriptor = pluginCollector.getPluginDescriptor( plugin );
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.apache.maven.plugin;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown when a plugin is not internally consistent.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class InvalidPluginException
|
||||||
|
extends Exception
|
||||||
|
{
|
||||||
|
public InvalidPluginException( String message, Exception e )
|
||||||
|
{
|
||||||
|
super( message, e );
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ import org.apache.maven.model.ReportPlugin;
|
||||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||||
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
import org.apache.maven.plugin.version.PluginVersionResolutionException;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||||
import org.apache.maven.reporting.MavenReport;
|
import org.apache.maven.reporting.MavenReport;
|
||||||
import org.apache.maven.settings.Settings;
|
import org.apache.maven.settings.Settings;
|
||||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||||
|
@ -41,28 +42,27 @@ public interface PluginManager
|
||||||
String ROLE = PluginManager.class.getName();
|
String ROLE = PluginManager.class.getName();
|
||||||
|
|
||||||
void executeMojo( MavenProject project, MojoExecution execution, MavenSession session )
|
void executeMojo( MavenProject project, MojoExecution execution, MavenSession session )
|
||||||
throws MojoExecutionException, PluginManagerException, ArtifactResolutionException, MojoFailureException,
|
throws MojoExecutionException, ArtifactResolutionException, MojoFailureException, ArtifactNotFoundException,
|
||||||
ArtifactNotFoundException;
|
InvalidDependencyVersionException, PluginManagerException;
|
||||||
|
|
||||||
MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
|
||||||
throws PluginManagerException, ArtifactNotFoundException;
|
throws ArtifactNotFoundException, PluginConfigurationException, PluginManagerException;
|
||||||
|
|
||||||
PluginDescriptor getPluginDescriptorForPrefix( String prefix );
|
PluginDescriptor getPluginDescriptorForPrefix( String prefix );
|
||||||
|
|
||||||
Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project )
|
Plugin getPluginDefinitionForPrefix( String prefix, MavenSession session, MavenProject project );
|
||||||
throws PluginManagerException;
|
|
||||||
|
|
||||||
PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
PluginDescriptor verifyPlugin( Plugin plugin, MavenProject project, Settings settings,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException,
|
throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException,
|
||||||
ArtifactNotFoundException, InvalidVersionSpecificationException;
|
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException;
|
||||||
|
|
||||||
PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
|
PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
|
||||||
throws PluginVersionResolutionException, ArtifactResolutionException, PluginManagerException,
|
throws PluginVersionResolutionException, ArtifactResolutionException, ArtifactNotFoundException,
|
||||||
ArtifactNotFoundException, InvalidVersionSpecificationException;
|
InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException;
|
||||||
|
|
||||||
Object getPluginComponent( Plugin plugin, String role, String roleHint )
|
Object getPluginComponent( Plugin plugin, String role, String roleHint )
|
||||||
throws ComponentLookupException, PluginManagerException;
|
throws PluginManagerException, ComponentLookupException;
|
||||||
|
|
||||||
Map getPluginComponents( Plugin plugin, String role )
|
Map getPluginComponents( Plugin plugin, String role )
|
||||||
throws ComponentLookupException, PluginManagerException;
|
throws ComponentLookupException, PluginManagerException;
|
||||||
|
|
|
@ -696,11 +696,6 @@ public class DefaultPluginVersionManager
|
||||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
throw new PluginVersionResolutionException( groupId, artifactId,
|
||||||
"Unable to build resolve plugin project information", e );
|
"Unable to build resolve plugin project information", e );
|
||||||
}
|
}
|
||||||
catch ( IOException e )
|
|
||||||
{
|
|
||||||
throw new PluginVersionResolutionException( groupId, artifactId,
|
|
||||||
"Unable to determine Maven version for comparison", e );
|
|
||||||
}
|
|
||||||
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.plugin.AbstractMojo;
|
import org.apache.maven.plugin.AbstractMojo;
|
||||||
|
import org.apache.maven.plugin.InvalidPluginException;
|
||||||
import org.apache.maven.plugin.MojoExecutionException;
|
import org.apache.maven.plugin.MojoExecutionException;
|
||||||
import org.apache.maven.plugin.MojoFailureException;
|
import org.apache.maven.plugin.MojoFailureException;
|
||||||
import org.apache.maven.plugin.PluginManager;
|
import org.apache.maven.plugin.PluginManager;
|
||||||
|
@ -276,15 +277,7 @@ public class DescribeMojo
|
||||||
|
|
||||||
if ( descriptor == null )
|
if ( descriptor == null )
|
||||||
{
|
{
|
||||||
try
|
forLookup = pluginManager.getPluginDefinitionForPrefix( pi.prefix, session, project );
|
||||||
{
|
|
||||||
forLookup = pluginManager.getPluginDefinitionForPrefix( pi.prefix, session, project );
|
|
||||||
}
|
|
||||||
catch ( PluginManagerException e )
|
|
||||||
{
|
|
||||||
throw new MojoExecutionException(
|
|
||||||
"Cannot resolve plugin-prefix: \'" + pi.prefix + "\' from plugin mappings metadata.", e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( pi.groupId != null && pi.artifactId != null )
|
else if ( pi.groupId != null && pi.artifactId != null )
|
||||||
|
@ -336,6 +329,11 @@ public class DescribeMojo
|
||||||
throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId +
|
throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId +
|
||||||
"\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e );
|
"\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e );
|
||||||
}
|
}
|
||||||
|
catch ( InvalidPluginException e )
|
||||||
|
{
|
||||||
|
throw new MojoExecutionException( "Error retrieving plugin descriptor for:\n\ngroupId: \'" + groupId +
|
||||||
|
"\'\nartifactId: \'" + artifactId + "\'\nversion: \'" + version + "\'\n\n", e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return descriptor;
|
return descriptor;
|
||||||
|
|
|
@ -51,6 +51,7 @@ import org.apache.maven.profiles.ProfileManager;
|
||||||
import org.apache.maven.profiles.ProfilesConversionUtils;
|
import org.apache.maven.profiles.ProfilesConversionUtils;
|
||||||
import org.apache.maven.profiles.ProfilesRoot;
|
import org.apache.maven.profiles.ProfilesRoot;
|
||||||
import org.apache.maven.profiles.activation.ProfileActivationException;
|
import org.apache.maven.profiles.activation.ProfileActivationException;
|
||||||
|
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||||
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
|
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
|
||||||
import org.apache.maven.project.injection.ModelDefaultsInjector;
|
import org.apache.maven.project.injection.ModelDefaultsInjector;
|
||||||
import org.apache.maven.project.injection.ProfileInjector;
|
import org.apache.maven.project.injection.ProfileInjector;
|
||||||
|
@ -191,7 +192,16 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
ensureMetadataSourceIsInitialized();
|
ensureMetadataSourceIsInitialized();
|
||||||
|
|
||||||
project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
|
try
|
||||||
|
{
|
||||||
|
project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
|
||||||
|
}
|
||||||
|
catch ( InvalidDependencyVersionException e )
|
||||||
|
{
|
||||||
|
throw new ProjectBuildingException( projectId,
|
||||||
|
"Unable to build project due to an invalid dependency version: " +
|
||||||
|
e.getMessage(), e );
|
||||||
|
}
|
||||||
|
|
||||||
if ( transferListener != null )
|
if ( transferListener != null )
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,6 +45,7 @@ import org.apache.maven.model.Resource;
|
||||||
import org.apache.maven.model.Scm;
|
import org.apache.maven.model.Scm;
|
||||||
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
||||||
import org.apache.maven.project.artifact.ActiveProjectArtifact;
|
import org.apache.maven.project.artifact.ActiveProjectArtifact;
|
||||||
|
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||||
import org.apache.maven.project.artifact.MavenMetadataSource;
|
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||||
import org.apache.maven.project.overlay.BuildOverlay;
|
import org.apache.maven.project.overlay.BuildOverlay;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
@ -1405,7 +1406,7 @@ public class MavenProject
|
||||||
*/
|
*/
|
||||||
public Set createArtifacts( ArtifactFactory artifactFactory, String inheritedScope,
|
public Set createArtifacts( ArtifactFactory artifactFactory, String inheritedScope,
|
||||||
ArtifactFilter dependencyFilter )
|
ArtifactFilter dependencyFilter )
|
||||||
throws ProjectBuildingException
|
throws InvalidDependencyVersionException
|
||||||
{
|
{
|
||||||
return MavenMetadataSource.createArtifacts( artifactFactory, getDependencies(), inheritedScope,
|
return MavenMetadataSource.createArtifacts( artifactFactory, getDependencies(), inheritedScope,
|
||||||
dependencyFilter, this );
|
dependencyFilter, this );
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package org.apache.maven.project.artifact;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thrown if a dependency has an invalid version.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class InvalidDependencyVersionException
|
||||||
|
extends Exception
|
||||||
|
{
|
||||||
|
public InvalidDependencyVersionException( String message, Exception cause )
|
||||||
|
{
|
||||||
|
super( message, cause );
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,7 +17,6 @@ package org.apache.maven.project.artifact;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.ArtifactUtils;
|
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
|
@ -206,6 +205,10 @@ public class MavenMetadataSource
|
||||||
{
|
{
|
||||||
throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file", e );
|
throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file", e );
|
||||||
}
|
}
|
||||||
|
catch ( InvalidDependencyVersionException e )
|
||||||
|
{
|
||||||
|
throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file", e );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List aggregateRepositoryLists( List remoteRepositories, List remoteArtifactRepositories )
|
private List aggregateRepositoryLists( List remoteRepositories, List remoteArtifactRepositories )
|
||||||
|
@ -259,7 +262,7 @@ public class MavenMetadataSource
|
||||||
*/
|
*/
|
||||||
public static Set createArtifacts( ArtifactFactory artifactFactory, List dependencies, String inheritedScope,
|
public static Set createArtifacts( ArtifactFactory artifactFactory, List dependencies, String inheritedScope,
|
||||||
ArtifactFilter dependencyFilter, MavenProject project )
|
ArtifactFilter dependencyFilter, MavenProject project )
|
||||||
throws ProjectBuildingException
|
throws InvalidDependencyVersionException
|
||||||
{
|
{
|
||||||
Set projectArtifacts = new HashSet( dependencies.size() );
|
Set projectArtifacts = new HashSet( dependencies.size() );
|
||||||
|
|
||||||
|
@ -283,10 +286,7 @@ public class MavenMetadataSource
|
||||||
}
|
}
|
||||||
catch ( InvalidVersionSpecificationException e )
|
catch ( InvalidVersionSpecificationException e )
|
||||||
{
|
{
|
||||||
String projectId = project != null ? ArtifactUtils.versionlessKey( project.getGroupId(),
|
throw new InvalidDependencyVersionException( "Unable to parse version '" + d.getVersion() +
|
||||||
project.getArtifactId() )
|
|
||||||
: "unknown";
|
|
||||||
throw new ProjectBuildingException( projectId, "Unable to parse version '" + d.getVersion() +
|
|
||||||
"' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), e );
|
"' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), e );
|
||||||
}
|
}
|
||||||
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
|
Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
|
||||||
|
|
Loading…
Reference in New Issue