Basic error reporting (tips aren't available for everything yet) is complete for everything the CLI typically handles directly.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@603779 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-12-12 23:40:49 +00:00
parent 147f00077b
commit fe523d1151
12 changed files with 1421 additions and 309 deletions

View File

@ -1,20 +1,42 @@
package org.apache.maven.errors;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.RealmManagementException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.plugin.InvalidPluginException;
import org.apache.maven.plugin.PluginManager;
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.extension.ExtensionScanningException;
import org.apache.maven.extension.DefaultBuildExtensionScanner;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.build.model.ModelLineage;
import org.apache.maven.project.interpolation.ModelInterpolator;
import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.apache.maven.extension.ExtensionManagerException;
import org.apache.maven.extension.DefaultExtensionManager;
import org.apache.maven.model.Prerequisites;
import org.apache.maven.plugin.DefaultPluginManager;
import org.apache.maven.plugin.version.DefaultPluginVersionManager;
import org.apache.maven.execution.RuntimeInformation;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public aspect ExtensionErrorReporterAspect
public privileged aspect ExtensionErrorReporterAspect
extends AbstractCoreReporterAspect
{
@ -63,6 +85,190 @@ public aspect ExtensionErrorReporterAspect
getReporter().reportErrorInterpolatingModel( model, inheritedValues, pomFile, request, cause );
}
// TODO: Finish ExtensionManagerException mapping!
private pointcut dem_addExtension( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request ):
execution( * DefaultExtensionManager.addExtension( Artifact, Artifact, List, MavenExecutionRequest, .. ) )
&& args( extensionArtifact, projectArtifact, remoteRepos, request, .. );
before( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactMetadataRetrievalException cause ):
cflow( dem_addExtension( extensionArtifact, projectArtifact, remoteRepos, request ) )
&& call( ExtensionManagerException.new( .., ArtifactMetadataRetrievalException ) )
&& args( .., cause )
{
getReporter().reportErrorResolvingExtensionDirectDependencies( extensionArtifact, projectArtifact, remoteRepos, request, cause );
}
before( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionResult resolutionResult, ExtensionManagerException err ):
cflow( dem_addExtension( extensionArtifact, projectArtifact, remoteRepos, request ) )
&& execution( ExtensionManagerException.new( .., ArtifactResolutionResult ) )
&& args( .., resolutionResult )
&& this( err )
{
getReporter().reportErrorResolvingExtensionDependencies( extensionArtifact, projectArtifact, remoteRepos, request, resolutionResult, err );
}
private pointcut call_eme_ctor_RealmManagementException( RealmManagementException cause ):
call( ExtensionManagerException.new( .., RealmManagementException ) )
&& args( .., cause );
private pointcut within_dem_addExtension():
withincode( void DefaultExtensionManager.addExtension( Artifact, Artifact, List, MavenExecutionRequest, .. ) );
before( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause ):
cflow( dem_addExtension( extensionArtifact, projectArtifact, remoteRepos, request ) )
&& within_dem_addExtension()
&& call_eme_ctor_RealmManagementException( cause )
{
getReporter().reportErrorManagingRealmForExtension( extensionArtifact, projectArtifact, remoteRepos, request, cause );
}
private pointcut dem_addPluginAsExtension( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request ):
execution( * DefaultExtensionManager.addPluginAsExtension( Plugin, Model, List, MavenExecutionRequest ) )
&& args( plugin, originModel, remoteRepos, request );
private pointcut within_dem_addPluginAsExtension():
withincode( void DefaultExtensionManager.addPluginAsExtension( Plugin, Model, List, MavenExecutionRequest, .. ) );
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause ):
cflow( dem_addPluginAsExtension( plugin, originModel, remoteRepos, request ) )
&& within_dem_addPluginAsExtension()
&& call_eme_ctor_RealmManagementException( cause )
{
getReporter().reportErrorManagingRealmForExtensionPlugin( plugin, originModel, remoteRepos, request, cause );
}
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactNotFoundException cause ):
cflow( dem_addPluginAsExtension( plugin, originModel, remoteRepos, request ) )
&& within_dem_addPluginAsExtension()
&& call( ExtensionManagerException.new( .., ArtifactNotFoundException ) )
&& args( .., cause )
{
getReporter().reportMissingArtifactWhileAddingExtensionPlugin( plugin, originModel, remoteRepos, request, cause );
}
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionException cause ):
cflow( dem_addPluginAsExtension( plugin, originModel, remoteRepos, request ) )
&& within_dem_addPluginAsExtension()
&& call( ExtensionManagerException.new( .., ArtifactResolutionException ) )
&& args( .., cause )
{
getReporter().reportUnresolvableArtifactWhileAddingExtensionPlugin( plugin, originModel, remoteRepos, request, cause );
}
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginNotFoundException cause ):
cflow( dem_addPluginAsExtension( plugin, originModel, remoteRepos, request ) )
&& within_dem_addPluginAsExtension()
&& call( ExtensionManagerException.new( .., PluginNotFoundException ) )
&& args( .., cause )
{
getReporter().reportExtensionPluginArtifactNotFound( plugin, originModel, remoteRepos, request, cause );
}
private pointcut within_dpvm_resolveMetaVersion():
withincode( * DefaultPluginVersionManager.resolveMetaVersion( .. ) );
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactMetadataRetrievalException cause ):
cflow( dem_addPluginAsExtension( plugin, originModel, remoteRepos, request ) )
&& cflow( execution( * PluginManager+.verifyPlugin( .. ) ) )
&& within_dpvm_resolveMetaVersion()
&& call( PluginVersionResolutionException.new( .., ArtifactMetadataRetrievalException ) )
&& args( .., cause )
{
getReporter().reportUnresolvableExtensionPluginPOM( plugin, originModel, remoteRepos, request, cause );
}
String requiredVersion = null;
String currentVersion = null;
after() returning( String mavenVersion ):
( withincode( * DefaultPluginManager.checkRequiredMavenVersion( .. ) )
|| within_dpvm_resolveMetaVersion() )
&& call( * Prerequisites.getMaven() )
{
requiredVersion = mavenVersion;
}
after() returning( ArtifactVersion mavenVersion ):
( withincode( * DefaultPluginManager.checkRequiredMavenVersion( .. ) )
|| within_dpvm_resolveMetaVersion() )
&& call( * RuntimeInformation+.getApplicationVersion() )
{
currentVersion = mavenVersion.toString();
}
after():
execution( * DefaultPluginManager.checkRequiredMavenVersion( .. ) )
{
requiredVersion = null;
currentVersion = null;
}
after():
execution( * DefaultPluginVersionManager.resolveMetaVersion( .. ) )
{
requiredVersion = null;
currentVersion = null;
}
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, InvalidVersionSpecificationException cause ):
cflow( dem_addPluginAsExtension( plugin, originModel, remoteRepos, request ) )
&& cflow( execution( * PluginManager+.verifyPlugin( .. ) ) )
&& withincode( * DefaultPluginVersionManager.resolveMetaVersion( .. ) )
&& call( PluginVersionResolutionException.new( .., InvalidVersionSpecificationException ) )
&& args( .., cause )
{
getReporter().reportErrorSearchingforCompatibleExtensionPluginVersion( plugin, originModel, remoteRepos, request, requiredVersion, currentVersion, cause );
}
private pointcut dpm_verifyVersionedPlugin( Plugin plugin ):
execution( * DefaultPluginManager.verifyVersionedPlugin( Plugin, .. ) )
&& args( plugin, .. );
after( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginVersionResolutionException err ):
cflow( dem_addPluginAsExtension( Plugin, originModel, remoteRepos, request ) )
&& cflow( execution( * PluginManager+.verifyPlugin( .. ) ) )
&& cflow( dpm_verifyVersionedPlugin( plugin ) )
&& execution( PluginVersionResolutionException.new( .., String ) )
&& this( err )
{
getReporter().reportIncompatibleMavenVersionForExtensionPlugin( plugin, originModel, remoteRepos, request, requiredVersion, currentVersion, err );
}
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ProjectBuildingException cause ):
cflow( dem_addPluginAsExtension( Plugin, originModel, remoteRepos, request ) )
&& cflow( execution( * PluginManager+.verifyPlugin( .. ) ) )
&& cflow( dpm_verifyVersionedPlugin( plugin ) )
&& execution( InvalidPluginException.new( .., ProjectBuildingException ) )
&& args( .., cause )
{
getReporter().handleErrorBuildingExtensionPluginPOM( plugin, originModel, remoteRepos, request, cause );
}
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, InvalidDependencyVersionException cause ):
cflow( dem_addPluginAsExtension( Plugin, originModel, remoteRepos, request ) )
&& cflow( execution( * PluginManager+.verifyPlugin( .. ) ) )
&& cflow( dpm_verifyVersionedPlugin( plugin ) )
&& execution( InvalidPluginException.new( .., InvalidDependencyVersionException ) )
&& args( .., cause )
{
getReporter().reportInvalidDependencyVersionInExtensionPluginPOM( plugin, originModel, remoteRepos, request, cause );
}
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginVersionNotFoundException cause ):
cflow( dem_addPluginAsExtension( plugin, originModel, remoteRepos, request ) )
&& within_dem_addPluginAsExtension()
&& call( ExtensionManagerException.new( .., PluginVersionNotFoundException ) )
&& args( .., cause )
{
getReporter().reportExtensionPluginVersionNotFound( plugin, originModel, remoteRepos, request, cause );
}
before( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginManagerException cause ):
cflow( dem_addPluginAsExtension( plugin, originModel, remoteRepos, request ) )
&& within_dem_addPluginAsExtension()
&& call( ExtensionManagerException.new( .., PluginManagerException+ ) )
&& args( .., cause )
{
getReporter().reportErrorConfiguringExtensionPluginRealm( plugin, originModel, remoteRepos, request, cause );
}
}

View File

@ -3,11 +3,16 @@ package org.apache.maven.errors;
import org.apache.maven.NoGoalsSpecifiedException;
import org.apache.maven.ProjectCycleException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.RealmManagementException;
import org.apache.maven.extension.ExtensionManagerException;
import org.apache.maven.lifecycle.LifecycleException;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.lifecycle.LifecycleLoaderException;
@ -15,17 +20,23 @@ import org.apache.maven.lifecycle.LifecycleSpecificationException;
import org.apache.maven.lifecycle.TaskValidationResult;
import org.apache.maven.lifecycle.model.MojoBinding;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.PluginConfigurationException;
import org.apache.maven.plugin.PluginExecutionException;
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.PluginParameterException;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.loader.PluginLoaderException;
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.reactor.MavenExecutionException;
@ -109,4 +120,33 @@ public interface CoreErrorReporter
void handleSuperPomBuildingError( ProjectBuildingException exception );
void reportErrorInterpolatingModel( Model model, Map inheritedValues, File pomFile, MavenExecutionRequest request, ModelInterpolationException cause );
void reportErrorResolvingExtensionDirectDependencies( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactMetadataRetrievalException cause );
void reportErrorResolvingExtensionDependencies( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionResult resolutionResult, ExtensionManagerException err );
void reportErrorManagingRealmForExtension( Artifact extensionArtifact, Artifact projectArtifact, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause );
void reportErrorManagingRealmForExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, RealmManagementException cause );
void reportMissingArtifactWhileAddingExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactNotFoundException cause );
void reportUnresolvableArtifactWhileAddingExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactResolutionException cause );
void reportExtensionPluginArtifactNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginNotFoundException cause );
void reportUnresolvableExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ArtifactMetadataRetrievalException cause );
void handleErrorBuildingExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, ProjectBuildingException cause );
void reportInvalidDependencyVersionInExtensionPluginPOM( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, InvalidDependencyVersionException cause );
void reportErrorSearchingforCompatibleExtensionPluginVersion( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, InvalidVersionSpecificationException cause );
void reportIncompatibleMavenVersionForExtensionPlugin( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, String requiredMavenVersion, String currentMavenVersion, PluginVersionResolutionException err );
void reportExtensionPluginVersionNotFound( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginVersionNotFoundException cause );
void reportErrorConfiguringExtensionPluginRealm( Plugin plugin, Model originModel, List remoteRepos, MavenExecutionRequest request, PluginManagerException cause );
}

View File

@ -2,17 +2,27 @@ package org.apache.maven.errors;
import org.apache.maven.ProjectCycleException;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.execution.RealmManagementException;
import org.apache.maven.lifecycle.LifecycleException;
import org.apache.maven.lifecycle.TaskValidationResult;
import org.apache.maven.lifecycle.model.MojoBinding;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.PluginConfigurationException;
import org.apache.maven.plugin.PluginExecutionException;
import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.descriptor.Parameter;
import org.apache.maven.plugin.loader.PluginLoaderException;
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.configuration.PlexusConfiguration;
@ -177,4 +187,118 @@ public final class CoreErrorTips
return null;
}
public static List getIncompatibleProjectMavenVersionPrereqTips( MavenProject project,
ArtifactVersion mavenVersion )
{
// TODO Auto-generated method stub
return null;
}
public static List getPomFileScanningErrorTips( File basedir,
String includes,
String excludes )
{
// TODO Auto-generated method stub
return null;
}
public static List getErrorResolvingExtensionDirectDepsTips( Artifact extensionArtifact,
Artifact projectArtifact,
ArtifactMetadataRetrievalException cause )
{
// TODO Auto-generated method stub
return null;
}
public static List getErrorResolvingExtensionArtifactsTips( Artifact extensionArtifact,
Artifact projectArtifact,
ArtifactResolutionResult resolutionResult )
{
// TODO Auto-generated method stub
return null;
}
public static List getErrorManagingExtensionRealmTips( Artifact extensionArtifact,
Artifact projectArtifact,
RealmManagementException cause )
{
// TODO Auto-generated method stub
return null;
}
public static List getErrorManagingExtensionPluginRealmTips( Plugin plugin,
Model originModel,
RealmManagementException cause )
{
// TODO Auto-generated method stub
return null;
}
public static List getErrorResolvingExtensionPluginArtifactsTips( Plugin plugin,
Model originModel,
AbstractArtifactResolutionException cause )
{
// TODO Auto-generated method stub
return null;
}
public static List getErrorResolvingExtensionPluginVersionTips( Plugin plugin,
Model originModel,
PluginVersionResolutionException cause )
{
// TODO Auto-generated method stub
return null;
}
public static List getInvalidDependencyVersionForExtensionPluginTips( Plugin plugin,
Model originModel,
InvalidDependencyVersionException cause )
{
// TODO Auto-generated method stub
return null;
}
public static List getInvalidPluginVersionRangeForExtensionPluginTips( Plugin plugin,
Model originModel,
String requiredMavenVersion,
String currentMavenVersion )
{
// TODO Auto-generated method stub
return null;
}
public static List getInvalidPluginVersionRangeForExtensionPluginTips( Plugin plugin,
Model originModel,
String requiredMavenVersion,
String currentMavenVersion,
InvalidVersionSpecificationException cause )
{
// TODO Auto-generated method stub
return null;
}
public static List getUnresolvableExtensionPluginPOMTips( Plugin plugin,
Model originModel,
ArtifactMetadataRetrievalException cause )
{
// TODO Auto-generated method stub
return null;
}
public static List getExtensionPluginVersionNotFoundTips( Plugin plugin,
Model originModel,
PluginVersionNotFoundException cause )
{
// TODO Auto-generated method stub
return null;
}
public static List getErrorManagingExtensionPluginRealmTips( Plugin plugin,
Model originModel,
PluginManagerException cause )
{
// TODO Auto-generated method stub
return null;
}
}

View File

@ -11,13 +11,6 @@ import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.version.PluginVersionNotFoundException;
import org.apache.maven.plugin.version.PluginVersionResolutionException;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import java.net.MalformedURLException;
public class ExtensionManagerException
extends Exception
@ -47,86 +40,6 @@ public class ExtensionManagerException
this.projectVersion = projectVersion;
}
public ExtensionManagerException( String message,
Artifact extensionArtifact,
String projectGroupId,
String projectArtifactId,
String projectVersion,
MalformedURLException cause )
{
super( message, cause );
this.extensionArtifact = extensionArtifact;
this.projectGroupId = projectGroupId;
this.projectArtifactId = projectArtifactId;
this.projectVersion = projectVersion;
}
public ExtensionManagerException( String message,
Artifact extensionArtifact,
String projectGroupId,
String projectArtifactId,
String projectVersion,
PlexusConfigurationException cause )
{
super( message, cause );
this.extensionArtifact = extensionArtifact;
this.projectGroupId = projectGroupId;
this.projectArtifactId = projectArtifactId;
this.projectVersion = projectVersion;
}
public ExtensionManagerException( String message,
String projectGroupId,
String projectArtifactId,
String projectVersion,
DuplicateRealmException cause )
{
super( message, cause );
this.projectGroupId = projectGroupId;
this.projectArtifactId = projectArtifactId;
this.projectVersion = projectVersion;
}
public ExtensionManagerException( String message,
Artifact extensionArtifact,
String projectGroupId,
String projectArtifactId,
String projectVersion,
NoSuchRealmException cause )
{
super( message, cause );
this.extensionArtifact = extensionArtifact;
this.projectGroupId = projectGroupId;
this.projectArtifactId = projectArtifactId;
this.projectVersion = projectVersion;
}
public ExtensionManagerException( String message,
String projectGroupId,
String projectArtifactId,
String projectVersion,
PlexusContainerException cause )
{
super( message, cause );
this.projectGroupId = projectGroupId;
this.projectArtifactId = projectArtifactId;
this.projectVersion = projectVersion;
}
public ExtensionManagerException( String message,
Artifact extensionArtifact,
String projectGroupId,
String projectArtifactId,
String projectVersion,
ComponentRepositoryException cause )
{
super( message, cause );
this.extensionArtifact = extensionArtifact;
this.projectGroupId = projectGroupId;
this.projectArtifactId = projectArtifactId;
this.projectVersion = projectVersion;
}
public ExtensionManagerException( String message,
Artifact extensionArtifact,
String projectGroupId,

View File

@ -3,16 +3,11 @@ package org.apache.maven.plugin;
import org.apache.maven.execution.RealmManagementException;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.codehaus.plexus.PlexusContainerException;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.DuplicateRealmException;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException;
import org.codehaus.plexus.configuration.PlexusConfigurationException;
import java.net.MalformedURLException;
/**
* Exception which occurs to indicate that the plugin cannot be initialized due
* to some deeper problem with Plexus. Context information includes the groupId,
@ -39,36 +34,6 @@ public class PluginContainerException
this.pluginRealm = pluginRealm;
}
public PluginContainerException( Plugin plugin,
ClassRealm pluginRealm,
String message,
NoSuchRealmException e )
{
super( plugin, message, e );
this.pluginRealm = pluginRealm;
}
public PluginContainerException( Plugin plugin,
ClassRealm pluginRealm,
String message,
DuplicateRealmException e )
{
super( plugin, message, e );
this.pluginRealm = pluginRealm;
}
public PluginContainerException( Plugin plugin,
ClassRealm pluginRealm,
String message,
MalformedURLException e )
{
super( plugin, message, e );
this.pluginRealm = pluginRealm;
}
public PluginContainerException( Plugin plugin,
ClassRealm pluginRealm,
String message,
@ -89,16 +54,6 @@ public class PluginContainerException
this.pluginRealm = pluginRealm;
}
public PluginContainerException( Plugin plugin,
ClassRealm pluginRealm,
String message,
PlexusContainerException e )
{
super( plugin, message, e );
this.pluginRealm = pluginRealm;
}
public PluginContainerException( Plugin plugin,
String message,
RealmManagementException e )

View File

@ -11,7 +11,9 @@ import org.apache.maven.errors.CoreReporterManager;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.project.error.ProjectReporterManager;
import org.apache.maven.project.error.ProjectErrorReporter;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.reactor.MavenExecutionException;
public privileged aspect ErrorReportingAspect
{
@ -79,6 +81,51 @@ public privileged aspect ErrorReportingAspect
}
}
boolean around( DuplicateProjectException e, boolean showStackTraces, StringWriter writer ):
execution( private static boolean CLIReportingUtils.handleDuplicateProjectException( DuplicateProjectException, boolean, StringWriter ) )
&& args( e, showStackTraces, writer )
{
ProjectErrorReporter projectErrorReporter = ProjectReporterManager.getReporter();
if ( projectErrorReporter == null )
{
return proceed( e, showStackTraces, writer );
}
else
{
Throwable reportingError = projectErrorReporter.findReportedException( e );
boolean result = false;
if ( reportingError != null )
{
writer.write( projectErrorReporter.getFormattedMessage( reportingError ) );
if ( showStackTraces )
{
writer.write( CLIReportingUtils.NEWLINE );
writer.write( CLIReportingUtils.NEWLINE );
Throwable cause = projectErrorReporter.getRealCause( reportingError );
if ( cause != null )
{
cause.printStackTrace( new PrintWriter( writer ) );
}
}
writer.write( CLIReportingUtils.NEWLINE );
writer.write( CLIReportingUtils.NEWLINE );
result = true;
}
else
{
result = proceed( e, showStackTraces, writer );
}
return result;
}
}
boolean around( BuildFailureException e, boolean showStackTraces, StringWriter writer ):
execution( private static boolean CLIReportingUtils.handleBuildFailureException( BuildFailureException, boolean, StringWriter ) )
&& args( e, showStackTraces, writer )
@ -169,4 +216,48 @@ public privileged aspect ErrorReportingAspect
}
}
boolean around( MavenExecutionException e, boolean showStackTraces, StringWriter writer ):
execution( private static boolean CLIReportingUtils.handleMavenExecutionException( MavenExecutionException, boolean, StringWriter ) )
&& args( e, showStackTraces, writer )
{
CoreErrorReporter coreErrorReporter = CoreReporterManager.getReporter();
if ( coreErrorReporter == null )
{
return proceed( e, showStackTraces, writer );
}
else
{
Throwable reportingError = coreErrorReporter.findReportedException( e );
boolean result = false;
if ( reportingError != null )
{
writer.write( coreErrorReporter.getFormattedMessage( reportingError ) );
if ( showStackTraces )
{
writer.write( CLIReportingUtils.NEWLINE );
writer.write( CLIReportingUtils.NEWLINE );
Throwable cause = coreErrorReporter.getRealCause( reportingError );
if ( cause != null )
{
cause.printStackTrace( new PrintWriter( writer ) );
}
}
writer.write( CLIReportingUtils.NEWLINE );
writer.write( CLIReportingUtils.NEWLINE );
result = true;
}
else
{
result = proceed( e, showStackTraces, writer );
}
return result;
}
}
}

View File

@ -1,21 +1,18 @@
package org.apache.maven.cli;
import org.apache.maven.BuildFailureException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.embedder.MavenEmbedderConsoleLogger;
import org.apache.maven.embedder.MavenEmbedderLogger;
import org.apache.maven.execution.BuildFailure;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.apache.maven.execution.ReactorManager;
import org.apache.maven.extension.ExtensionScanningException;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.reactor.MavenExecutionException;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
@ -279,69 +276,7 @@ public final class CLIReportingUtils
boolean showStackTraces,
StringWriter writer )
{
// =====================================================================
// Cases covered:
// =====================================================================
//
// MavenExecutionException(String, File, ProjectBuildingException)
// MavenExecutionException(String, ExtensionScanningException)
// MavenExecutionException(String, IOException)
//
// =====================================================================
// Cases left to cover:
// =====================================================================
//
// MavenExecutionException(String, ArtifactResolutionException)
// MavenExecutionException(String, File)
Throwable cause = e.getCause();
if ( cause != null )
{
if ( cause instanceof IOException )
{
writer.write( e.getMessage() );
writer.write( NEWLINE );
handleGenericException( cause, showStackTraces, writer );
return true;
}
else if ( cause instanceof ExtensionScanningException )
{
writer.write( "While scanning for build extensions:" );
writer.write( NEWLINE );
writer.write( NEWLINE );
Throwable nestedCause = cause.getCause();
if ( ( nestedCause != null ) && ( nestedCause instanceof ProjectBuildingException ) )
{
return handleProjectBuildingException( (ProjectBuildingException) nestedCause,
showStackTraces,
writer );
}
else
{
handleGenericException( cause, showStackTraces, writer );
return true;
}
}
else if ( cause instanceof ProjectBuildingException )
{
return handleProjectBuildingException( (ProjectBuildingException) cause,
showStackTraces,
writer );
}
else if ( cause instanceof ArtifactResolutionException )
{
}
}
else
{
}
handleGenericException( e, showStackTraces, writer );
if ( e.getPomFile() != null )
{
@ -360,26 +295,7 @@ public final class CLIReportingUtils
boolean showStackTraces,
StringWriter writer )
{
// =====================================================================
// Cases covered:
// =====================================================================
//
// DuplicateProjectException(String, File, File, String)
File existing = e.getExistingProjectFile();
File conflicting = e.getConflictingProjectFile();
String projectId = e.getProjectId();
writer.write( "Duplicated project detected." );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Project: " + projectId );
writer.write( NEWLINE );
writer.write( "File: " );
writer.write( existing.getAbsolutePath() );
writer.write( NEWLINE );
writer.write( "File: " );
writer.write( conflicting.getAbsolutePath() );
handleGenericException( e, showStackTraces, writer );
return true;
}
@ -445,6 +361,7 @@ public final class CLIReportingUtils
StringWriter writer )
{
handleGenericException( e, showStackTraces, writer );
return true;
}

View File

@ -0,0 +1,32 @@
package org.apache.maven.project.aspect;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.ProjectSorter;
import java.util.List;
public aspect ProjectCollisionReporterAspect
extends AbstractProjectErrorReporterAspect
{
/**
* <b>Call Stack:</b>
* <br/>
* <pre>
* MavenEmbedder.execute(MavenExecutionRequest)
* MavenEmbedder.readProjectWithDependencies(MavenExecutionRequest)
* --&gt; DefaultMaven.execute(MavenExecutionRequest)
* --&gt; DefaultMaven.createReactorManager(MavenExecutionRequest, MavenExecutionResult)
* --&gt; new ReactorManager(List, String)
* --&gt; new ProjectSorter(List)
* &lt;----------------------- DuplicateProjectException
* </pre>
*/
after( List allProjectInstances ) throwing( DuplicateProjectException err ):
execution( ProjectSorter.new( List ) )
&& args( allProjectInstances )
{
getReporter().reportProjectCollision( allProjectInstances, err );
}
}

View File

@ -15,6 +15,7 @@ import org.apache.maven.model.Repository;
import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationException;
import org.apache.maven.profiles.activation.ProfileActivator;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.InvalidProjectModelException;
import org.apache.maven.project.InvalidProjectVersionException;
import org.apache.maven.project.MavenProject;
@ -791,4 +792,34 @@ public class DefaultProjectErrorReporter
registerProjectBuildError( cause, writer.toString() );
}
public void reportProjectCollision( List allProjectInstances,
DuplicateProjectException err )
{
File existing = err.getExistingProjectFile();
File conflicting = err.getConflictingProjectFile();
String projectId = err.getProjectId();
StringWriter writer = new StringWriter();
writer.write( "Duplicated project detected." );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "Project: " + projectId );
writer.write( NEWLINE );
writer.write( "File: " );
writer.write( String.valueOf( existing ) );
writer.write( NEWLINE );
writer.write( "File: " );
writer.write( String.valueOf( conflicting ) );
writer.write( NEWLINE );
writer.write( NEWLINE );
writer.write( "NOTE: Each project in a Maven build must have a unique combination of groupId and artifactId." );
addTips( ProjectErrorTips.getTipsForDuplicateProjectError( allProjectInstances, err ),
writer );
registerProjectBuildError( err, writer.toString() );
}
}

View File

@ -13,6 +13,7 @@ import org.apache.maven.model.Repository;
import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationException;
import org.apache.maven.profiles.activation.ProfileActivator;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.InvalidProjectModelException;
import org.apache.maven.project.InvalidProjectVersionException;
import org.apache.maven.project.MavenProject;
@ -413,4 +414,20 @@ public interface ProjectErrorReporter
String childId,
File childPomFile,
ArtifactResolutionException cause );
/**
* <b>Call Stack:</b>
* <br/>
* <pre>
* MavenEmbedder.execute(MavenExecutionRequest)
* MavenEmbedder.readProjectWithDependencies(MavenExecutionRequest)
* --&gt; DefaultMaven.execute(MavenExecutionRequest)
* --&gt; DefaultMaven.createReactorManager(MavenExecutionRequest, MavenExecutionResult)
* --&gt; new ReactorManager(List, String)
* --&gt; new ProjectSorter(List)
* &lt;----------------------- DuplicateProjectException
* </pre>
*/
void reportProjectCollision( List allProjectInstances,
DuplicateProjectException err );
}

View File

@ -8,6 +8,7 @@ import org.apache.maven.model.RepositoryBase;
import org.apache.maven.profiles.activation.ProfileActivationContext;
import org.apache.maven.profiles.activation.ProfileActivationException;
import org.apache.maven.profiles.activation.ProfileActivator;
import org.apache.maven.project.DuplicateProjectException;
import org.apache.maven.project.InvalidProjectVersionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.interpolation.ModelInterpolationException;
@ -168,4 +169,11 @@ public final class ProjectErrorTips
return null;
}
public static List getTipsForDuplicateProjectError( List allProjectInstances,
DuplicateProjectException err )
{
// TODO Auto-generated method stub
return null;
}
}