mirror of https://github.com/apache/maven.git
Generalized error diagnosis for use outside of maven-core. This allows us to print diagnostic messages in the Ant tasks, for instance (these modifications are also included), and share diagnosers between multiple uses (maven-core, maven-artifact-ant, for example). This should help with MNG-784, but I'll verify that before I close it.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@314804 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0497cc28e7
commit
c933da0504
|
@ -46,6 +46,15 @@
|
|||
<version>1.0-alpha-5-SNAPSHOT</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-error-diagnostics</artifactId>
|
||||
<version>2.0-beta-4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
|
|
|
@ -31,6 +31,7 @@ import org.apache.maven.settings.Mirror;
|
|||
import org.apache.maven.settings.Server;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnostics;
|
||||
import org.apache.tools.ant.BuildException;
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.apache.tools.ant.Task;
|
||||
|
@ -366,6 +367,29 @@ public abstract class AbstractArtifactTask
|
|||
|
||||
return pom;
|
||||
}
|
||||
|
||||
public void diagnoseError( Throwable error )
|
||||
{
|
||||
try
|
||||
{
|
||||
ErrorDiagnostics diagnostics = (ErrorDiagnostics) embedder.lookup( ErrorDiagnostics.ROLE );
|
||||
|
||||
StringBuffer message = new StringBuffer();
|
||||
|
||||
message.append( "An error has occurred while processing the Maven artifact tasks.\n" );
|
||||
message.append( " Diagnosis:\n\n" );
|
||||
|
||||
message.append( diagnostics.diagnose( error ) );
|
||||
|
||||
message.append( "\n\n" );
|
||||
|
||||
log( message.toString(), Project.MSG_INFO );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
log( "Failed to retrieve error diagnoser.", Project.MSG_DEBUG );
|
||||
}
|
||||
}
|
||||
|
||||
public void addPom( Pom pom )
|
||||
{
|
||||
|
|
|
@ -75,161 +75,170 @@ public class DependenciesTask
|
|||
*/
|
||||
public void execute()
|
||||
{
|
||||
ArtifactRepository localRepo = createLocalArtifactRepository();
|
||||
|
||||
ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
|
||||
MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||
MavenMetadataSource metadataSource = (MavenMetadataSource) lookup( ArtifactMetadataSource.ROLE );
|
||||
|
||||
List dependencies = this.dependencies;
|
||||
|
||||
Pom pom = buildPom( projectBuilder, localRepo );
|
||||
if ( pom != null )
|
||||
{
|
||||
if ( !dependencies.isEmpty() )
|
||||
{
|
||||
throw new BuildException( "You cannot specify both dependencies and a pom in the dependencies task" );
|
||||
}
|
||||
|
||||
dependencies = pom.getDependencies();
|
||||
|
||||
for ( Iterator i = pom.getRepositories().iterator(); i.hasNext(); )
|
||||
{
|
||||
Repository pomRepository = (Repository) i.next();
|
||||
|
||||
remoteRepositories.add( createAntRemoteRepository( pomRepository ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have to have some sort of Pom object in order to satisfy the requirements for building the
|
||||
// originating Artifact below...
|
||||
pom = createDummyPom();
|
||||
}
|
||||
|
||||
if ( dependencies.isEmpty() )
|
||||
{
|
||||
log( "There were no dependencies specified", Project.MSG_WARN );
|
||||
}
|
||||
|
||||
Set artifacts;
|
||||
try
|
||||
{
|
||||
artifacts = MavenMetadataSource.createArtifacts( artifactFactory, dependencies, null, null, null );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new BuildException( "Invalid version specification", e );
|
||||
}
|
||||
ArtifactRepository localRepo = createLocalArtifactRepository();
|
||||
|
||||
log( "Resolving dependencies...", Project.MSG_VERBOSE );
|
||||
ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
|
||||
MavenProjectBuilder projectBuilder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||
MavenMetadataSource metadataSource = (MavenMetadataSource) lookup( ArtifactMetadataSource.ROLE );
|
||||
|
||||
WagonManager wagonManager = (WagonManager) lookup( WagonManager.ROLE );
|
||||
wagonManager.setDownloadMonitor( new AntDownloadMonitor() );
|
||||
List dependencies = this.dependencies;
|
||||
|
||||
ArtifactResolutionResult result;
|
||||
try
|
||||
{
|
||||
Artifact pomArtifact = artifactFactory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(),
|
||||
pom.getVersion(), pom.getPackaging() );
|
||||
|
||||
List listeners = Collections.EMPTY_LIST;
|
||||
if ( verbose )
|
||||
Pom pom = buildPom( projectBuilder, localRepo );
|
||||
if ( pom != null )
|
||||
{
|
||||
listeners = Collections.singletonList( new AntResolutionListener( getProject() ) );
|
||||
}
|
||||
|
||||
List remoteRepositories = getRemoteRepositories();
|
||||
|
||||
RemoteRepository remoteRepository = getDefaultRemoteRepository();
|
||||
remoteRepositories.add( remoteRepository );
|
||||
|
||||
List remoteArtifactRepositories = createRemoteArtifactRepositories( remoteRepositories );
|
||||
|
||||
// TODO: managed dependencies
|
||||
Map managedDependencies = Collections.EMPTY_MAP;
|
||||
|
||||
ArtifactFilter filter = null;
|
||||
if ( useScope != null )
|
||||
{
|
||||
filter = new ScopeArtifactFilter( useScope );
|
||||
}
|
||||
if ( type != null )
|
||||
{
|
||||
TypeArtifactFilter typeArtifactFilter = new TypeArtifactFilter( type );
|
||||
if ( filter != null )
|
||||
if ( !dependencies.isEmpty() )
|
||||
{
|
||||
AndArtifactFilter andFilter = new AndArtifactFilter();
|
||||
andFilter.add( filter );
|
||||
andFilter.add( typeArtifactFilter );
|
||||
filter = andFilter;
|
||||
throw new BuildException( "You cannot specify both dependencies and a pom in the dependencies task" );
|
||||
}
|
||||
else
|
||||
|
||||
dependencies = pom.getDependencies();
|
||||
|
||||
for ( Iterator i = pom.getRepositories().iterator(); i.hasNext(); )
|
||||
{
|
||||
filter = typeArtifactFilter;
|
||||
Repository pomRepository = (Repository) i.next();
|
||||
|
||||
remoteRepositories.add( createAntRemoteRepository( pomRepository ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have to have some sort of Pom object in order to satisfy the requirements for building the
|
||||
// originating Artifact below...
|
||||
pom = createDummyPom();
|
||||
}
|
||||
|
||||
if ( dependencies.isEmpty() )
|
||||
{
|
||||
log( "There were no dependencies specified", Project.MSG_WARN );
|
||||
}
|
||||
|
||||
Set artifacts;
|
||||
try
|
||||
{
|
||||
artifacts = MavenMetadataSource.createArtifacts( artifactFactory, dependencies, null, null, null );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new BuildException( "Invalid version specification", e );
|
||||
}
|
||||
|
||||
log( "Resolving dependencies...", Project.MSG_VERBOSE );
|
||||
|
||||
WagonManager wagonManager = (WagonManager) lookup( WagonManager.ROLE );
|
||||
wagonManager.setDownloadMonitor( new AntDownloadMonitor() );
|
||||
|
||||
ArtifactResolutionResult result;
|
||||
try
|
||||
{
|
||||
Artifact pomArtifact = artifactFactory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(), pom
|
||||
.getVersion(), pom.getPackaging() );
|
||||
|
||||
List listeners = Collections.EMPTY_LIST;
|
||||
if ( verbose )
|
||||
{
|
||||
listeners = Collections.singletonList( new AntResolutionListener( getProject() ) );
|
||||
}
|
||||
|
||||
List remoteRepositories = getRemoteRepositories();
|
||||
|
||||
RemoteRepository remoteRepository = getDefaultRemoteRepository();
|
||||
remoteRepositories.add( remoteRepository );
|
||||
|
||||
List remoteArtifactRepositories = createRemoteArtifactRepositories( remoteRepositories );
|
||||
|
||||
// TODO: managed dependencies
|
||||
Map managedDependencies = Collections.EMPTY_MAP;
|
||||
|
||||
ArtifactFilter filter = null;
|
||||
if ( useScope != null )
|
||||
{
|
||||
filter = new ScopeArtifactFilter( useScope );
|
||||
}
|
||||
if ( type != null )
|
||||
{
|
||||
TypeArtifactFilter typeArtifactFilter = new TypeArtifactFilter( type );
|
||||
if ( filter != null )
|
||||
{
|
||||
AndArtifactFilter andFilter = new AndArtifactFilter();
|
||||
andFilter.add( filter );
|
||||
andFilter.add( typeArtifactFilter );
|
||||
filter = andFilter;
|
||||
}
|
||||
else
|
||||
{
|
||||
filter = typeArtifactFilter;
|
||||
}
|
||||
}
|
||||
|
||||
result = resolver.resolveTransitively( artifacts, pomArtifact, managedDependencies, localRepo,
|
||||
remoteArtifactRepositories, metadataSource, filter, listeners );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new BuildException( "Unable to resolve artifact", e );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
// TODO: improve handling
|
||||
throw new BuildException( "Unable to locate artifact", e );
|
||||
}
|
||||
|
||||
if ( pathId != null && getProject().getReference( pathId ) != null )
|
||||
{
|
||||
throw new BuildException( "Reference ID " + pathId + " already exists" );
|
||||
}
|
||||
|
||||
if ( filesetId != null && getProject().getReference( filesetId ) != null )
|
||||
{
|
||||
throw new BuildException( "Reference ID " + filesetId + " already exists" );
|
||||
}
|
||||
|
||||
FileList fileList = new FileList();
|
||||
fileList.setDir( getLocalRepository().getLocation() );
|
||||
|
||||
FileSet fileSet = new FileSet();
|
||||
fileSet.setDir( fileList.getDir( getProject() ) );
|
||||
|
||||
if ( result.getArtifacts().isEmpty() )
|
||||
{
|
||||
fileSet.createExclude().setName( "**/**" );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
String filename = localRepo.pathOf( artifact );
|
||||
|
||||
FileList.FileName file = new FileList.FileName();
|
||||
file.setName( filename );
|
||||
|
||||
fileList.addConfiguredFile( file );
|
||||
|
||||
fileSet.createInclude().setName( filename );
|
||||
}
|
||||
}
|
||||
|
||||
result = resolver.resolveTransitively( artifacts, pomArtifact, managedDependencies, localRepo,
|
||||
remoteArtifactRepositories, metadataSource, filter, listeners );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new BuildException( "Unable to resolve artifact", e );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
// TODO: improve handling
|
||||
throw new BuildException( "Unable to locate artifact", e );
|
||||
}
|
||||
|
||||
if ( pathId != null && getProject().getReference( pathId ) != null )
|
||||
{
|
||||
throw new BuildException( "Reference ID " + pathId + " already exists" );
|
||||
}
|
||||
|
||||
if ( filesetId != null && getProject().getReference( filesetId ) != null )
|
||||
{
|
||||
throw new BuildException( "Reference ID " + filesetId + " already exists" );
|
||||
}
|
||||
|
||||
FileList fileList = new FileList();
|
||||
fileList.setDir( getLocalRepository().getLocation() );
|
||||
|
||||
FileSet fileSet = new FileSet();
|
||||
fileSet.setDir( fileList.getDir( getProject() ) );
|
||||
|
||||
if ( result.getArtifacts().isEmpty() )
|
||||
{
|
||||
fileSet.createExclude().setName( "**/**" );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); )
|
||||
if ( pathId != null )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
String filename = localRepo.pathOf( artifact );
|
||||
Path path = new Path( getProject() );
|
||||
path.addFilelist( fileList );
|
||||
getProject().addReference( pathId, path );
|
||||
}
|
||||
|
||||
FileList.FileName file = new FileList.FileName();
|
||||
file.setName( filename );
|
||||
|
||||
fileList.addConfiguredFile( file );
|
||||
|
||||
fileSet.createInclude().setName( filename );
|
||||
if ( filesetId != null )
|
||||
{
|
||||
getProject().addReference( filesetId, fileSet );
|
||||
}
|
||||
}
|
||||
|
||||
if ( pathId != null )
|
||||
catch ( BuildException e )
|
||||
{
|
||||
Path path = new Path( getProject() );
|
||||
path.addFilelist( fileList );
|
||||
getProject().addReference( pathId, path );
|
||||
}
|
||||
|
||||
if ( filesetId != null )
|
||||
{
|
||||
getProject().addReference( filesetId, fileSet );
|
||||
diagnoseError( e );
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,81 +45,90 @@ public class DeployTask
|
|||
|
||||
public void execute()
|
||||
{
|
||||
ArtifactRepository localRepo = createLocalArtifactRepository();
|
||||
MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||
|
||||
Pom pom = buildPom( builder, localRepo );
|
||||
|
||||
if ( pom == null )
|
||||
{
|
||||
throw new BuildException( "A POM element is required to deploy to the repository" );
|
||||
}
|
||||
|
||||
Artifact artifact = createArtifact( pom );
|
||||
|
||||
DistributionManagement distributionManagement = pom.getDistributionManagement();
|
||||
|
||||
if ( remoteSnapshotRepository == null && remoteRepository == null )
|
||||
{
|
||||
if ( distributionManagement != null )
|
||||
{
|
||||
if ( distributionManagement.getSnapshotRepository() != null )
|
||||
{
|
||||
remoteSnapshotRepository = createAntRemoteRepositoryBase(
|
||||
distributionManagement.getSnapshotRepository() );
|
||||
}
|
||||
if ( distributionManagement.getRepository() != null )
|
||||
{
|
||||
remoteRepository = createAntRemoteRepositoryBase( distributionManagement.getRepository() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( remoteSnapshotRepository == null )
|
||||
{
|
||||
remoteSnapshotRepository = remoteRepository;
|
||||
}
|
||||
|
||||
ArtifactRepository deploymentRepository = null;
|
||||
if ( artifact.isSnapshot() && remoteSnapshotRepository != null )
|
||||
{
|
||||
deploymentRepository = createRemoteArtifactRepository( remoteSnapshotRepository );
|
||||
}
|
||||
else if ( remoteRepository != null )
|
||||
{
|
||||
deploymentRepository = createRemoteArtifactRepository( remoteRepository );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new BuildException(
|
||||
"A distributionManagement element or remoteRepository element is required to deploy" );
|
||||
}
|
||||
|
||||
// Deploy the POM
|
||||
boolean isPomArtifact = "pom".equals( pom.getPackaging() );
|
||||
if ( !isPomArtifact )
|
||||
{
|
||||
ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pom.getFile() );
|
||||
artifact.addMetadata( metadata );
|
||||
}
|
||||
|
||||
log( "Deploying to " + deploymentRepository.getUrl() );
|
||||
ArtifactDeployer deployer = (ArtifactDeployer) lookup( ArtifactDeployer.ROLE );
|
||||
try
|
||||
{
|
||||
if ( !isPomArtifact )
|
||||
ArtifactRepository localRepo = createLocalArtifactRepository();
|
||||
MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||
|
||||
Pom pom = buildPom( builder, localRepo );
|
||||
|
||||
if ( pom == null )
|
||||
{
|
||||
deployer.deploy( file, artifact, deploymentRepository, localRepo );
|
||||
throw new BuildException( "A POM element is required to deploy to the repository" );
|
||||
}
|
||||
|
||||
Artifact artifact = createArtifact( pom );
|
||||
|
||||
DistributionManagement distributionManagement = pom.getDistributionManagement();
|
||||
|
||||
if ( remoteSnapshotRepository == null && remoteRepository == null )
|
||||
{
|
||||
if ( distributionManagement != null )
|
||||
{
|
||||
if ( distributionManagement.getSnapshotRepository() != null )
|
||||
{
|
||||
remoteSnapshotRepository = createAntRemoteRepositoryBase( distributionManagement
|
||||
.getSnapshotRepository() );
|
||||
}
|
||||
if ( distributionManagement.getRepository() != null )
|
||||
{
|
||||
remoteRepository = createAntRemoteRepositoryBase( distributionManagement.getRepository() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( remoteSnapshotRepository == null )
|
||||
{
|
||||
remoteSnapshotRepository = remoteRepository;
|
||||
}
|
||||
|
||||
ArtifactRepository deploymentRepository = null;
|
||||
if ( artifact.isSnapshot() && remoteSnapshotRepository != null )
|
||||
{
|
||||
deploymentRepository = createRemoteArtifactRepository( remoteSnapshotRepository );
|
||||
}
|
||||
else if ( remoteRepository != null )
|
||||
{
|
||||
deploymentRepository = createRemoteArtifactRepository( remoteRepository );
|
||||
}
|
||||
else
|
||||
{
|
||||
deployer.deploy( pom.getFile(), artifact, deploymentRepository, localRepo );
|
||||
throw new BuildException(
|
||||
"A distributionManagement element or remoteRepository element is required to deploy" );
|
||||
}
|
||||
|
||||
// Deploy the POM
|
||||
boolean isPomArtifact = "pom".equals( pom.getPackaging() );
|
||||
if ( !isPomArtifact )
|
||||
{
|
||||
ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pom.getFile() );
|
||||
artifact.addMetadata( metadata );
|
||||
}
|
||||
|
||||
log( "Deploying to " + deploymentRepository.getUrl() );
|
||||
ArtifactDeployer deployer = (ArtifactDeployer) lookup( ArtifactDeployer.ROLE );
|
||||
try
|
||||
{
|
||||
if ( !isPomArtifact )
|
||||
{
|
||||
deployer.deploy( file, artifact, deploymentRepository, localRepo );
|
||||
}
|
||||
else
|
||||
{
|
||||
deployer.deploy( pom.getFile(), artifact, deploymentRepository, localRepo );
|
||||
}
|
||||
}
|
||||
catch ( ArtifactDeploymentException e )
|
||||
{
|
||||
// TODO: deployment exception that does not give a trace
|
||||
throw new BuildException( "Error deploying artifact", e );
|
||||
}
|
||||
}
|
||||
catch ( ArtifactDeploymentException e )
|
||||
catch ( BuildException e )
|
||||
{
|
||||
// TODO: deployment exception that does not give a trace
|
||||
throw new BuildException( "Error deploying artifact", e );
|
||||
diagnoseError( e );
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,36 +41,45 @@ public class InstallTask
|
|||
|
||||
public void execute()
|
||||
{
|
||||
ArtifactRepository localRepo = createLocalArtifactRepository();
|
||||
|
||||
MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||
Pom pom = buildPom( builder, localRepo );
|
||||
|
||||
Artifact artifact = createArtifact( pom );
|
||||
|
||||
boolean isPomArtifact = "pom".equals( pom.getPackaging() );
|
||||
if ( !isPomArtifact )
|
||||
{
|
||||
ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pom.getFile() );
|
||||
artifact.addMetadata( metadata );
|
||||
}
|
||||
|
||||
ArtifactInstaller installer = (ArtifactInstaller) lookup( ArtifactInstaller.ROLE );
|
||||
try
|
||||
{
|
||||
ArtifactRepository localRepo = createLocalArtifactRepository();
|
||||
|
||||
MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||
Pom pom = buildPom( builder, localRepo );
|
||||
|
||||
Artifact artifact = createArtifact( pom );
|
||||
|
||||
boolean isPomArtifact = "pom".equals( pom.getPackaging() );
|
||||
if ( !isPomArtifact )
|
||||
{
|
||||
installer.install( file, artifact, localRepo );
|
||||
ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, pom.getFile() );
|
||||
artifact.addMetadata( metadata );
|
||||
}
|
||||
else
|
||||
|
||||
ArtifactInstaller installer = (ArtifactInstaller) lookup( ArtifactInstaller.ROLE );
|
||||
try
|
||||
{
|
||||
installer.install( pom.getFile(), artifact, localRepo );
|
||||
if ( !isPomArtifact )
|
||||
{
|
||||
installer.install( file, artifact, localRepo );
|
||||
}
|
||||
else
|
||||
{
|
||||
installer.install( pom.getFile(), artifact, localRepo );
|
||||
}
|
||||
}
|
||||
catch ( ArtifactInstallationException e )
|
||||
{
|
||||
// TODO: install exception that does not give a trace
|
||||
throw new BuildException( "Error installing artifact", e );
|
||||
}
|
||||
}
|
||||
catch ( ArtifactInstallationException e )
|
||||
catch ( BuildException e )
|
||||
{
|
||||
// TODO: install exception that does not give a trace
|
||||
throw new BuildException( "Error installing artifact", e );
|
||||
diagnoseError( e );
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,45 +70,55 @@ public class InstallWagonProviderTask
|
|||
public void execute()
|
||||
throws BuildException
|
||||
{
|
||||
MavenMetadataSource metadataSource = (MavenMetadataSource) lookup( ArtifactMetadataSource.ROLE );
|
||||
|
||||
ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
|
||||
ArtifactRepository artifactRepository = createRemoteArtifactRepository( getDefaultRemoteRepository() );
|
||||
List remoteRepositories = Collections.singletonList( artifactRepository );
|
||||
try
|
||||
{
|
||||
ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||
VersionRange versionRange = VersionRange.createFromVersionSpec( version );
|
||||
Artifact providerArtifact = factory.createExtensionArtifact( "org.apache.maven.wagon", artifactId,
|
||||
versionRange );
|
||||
ArtifactResolutionResult result = resolver.resolveTransitively( Collections.singleton( providerArtifact ),
|
||||
createArtifact( createDummyPom() ),
|
||||
createLocalArtifactRepository(),
|
||||
remoteRepositories, metadataSource, null );
|
||||
MavenMetadataSource metadataSource = (MavenMetadataSource) lookup( ArtifactMetadataSource.ROLE );
|
||||
|
||||
log( "Installing provider: " + providerArtifact );
|
||||
|
||||
for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); )
|
||||
ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
|
||||
ArtifactRepository artifactRepository = createRemoteArtifactRepository( getDefaultRemoteRepository() );
|
||||
List remoteRepositories = Collections.singletonList( artifactRepository );
|
||||
try
|
||||
{
|
||||
Artifact a = (Artifact) i.next();
|
||||
getEmbedder().getContainer().addJarResource( a.getFile() );
|
||||
ArtifactFactory factory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
|
||||
VersionRange versionRange = VersionRange.createFromVersionSpec( version );
|
||||
Artifact providerArtifact = factory.createExtensionArtifact( "org.apache.maven.wagon", artifactId,
|
||||
versionRange );
|
||||
ArtifactResolutionResult result = resolver.resolveTransitively( Collections
|
||||
.singleton( providerArtifact ), createArtifact( createDummyPom() ),
|
||||
createLocalArtifactRepository(),
|
||||
remoteRepositories, metadataSource,
|
||||
null );
|
||||
|
||||
log( "Installing provider: " + providerArtifact );
|
||||
|
||||
for ( Iterator i = result.getArtifacts().iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact a = (Artifact) i.next();
|
||||
getEmbedder().getContainer().addJarResource( a.getFile() );
|
||||
}
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
throw new BuildException( "Unable to locate wagon provider in remote repository", e );
|
||||
}
|
||||
catch ( PlexusContainerException e )
|
||||
{
|
||||
throw new BuildException( "Unable to locate wagon provider in remote repository", e );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new BuildException( "Unable to locate wagon provider in remote repository", e );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
throw new BuildException( "Unable to locate wagon provider in remote repository", e );
|
||||
}
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
catch ( BuildException e )
|
||||
{
|
||||
throw new BuildException( "Unable to locate wagon provider in remote repository", e );
|
||||
}
|
||||
catch ( PlexusContainerException e )
|
||||
{
|
||||
throw new BuildException( "Unable to locate wagon provider in remote repository", e );
|
||||
}
|
||||
catch ( InvalidVersionSpecificationException e )
|
||||
{
|
||||
throw new BuildException( "Unable to locate wagon provider in remote repository", e );
|
||||
}
|
||||
catch ( ArtifactNotFoundException e )
|
||||
{
|
||||
throw new BuildException( "Unable to locate wagon provider in remote repository", e );
|
||||
diagnoseError( e );
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,6 +67,11 @@
|
|||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-error-diagnostics</artifactId>
|
||||
<version>2.0-beta-4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-provider-api</artifactId>
|
||||
|
|
|
@ -44,8 +44,8 @@ import org.apache.maven.settings.Proxy;
|
|||
import org.apache.maven.settings.Server;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.settings.SettingsUtils;
|
||||
import org.apache.maven.usability.DiagnosisUtils;
|
||||
import org.apache.maven.usability.ErrorDiagnoser;
|
||||
import org.apache.maven.usability.SystemWarnings;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnostics;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
|
||||
|
@ -66,7 +66,6 @@ import java.util.Collections;
|
|||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
|
||||
/**
|
||||
|
@ -89,8 +88,8 @@ public class DefaultMaven
|
|||
protected LifecycleExecutor lifecycleExecutor;
|
||||
|
||||
protected PlexusContainer container;
|
||||
|
||||
protected Map errorDiagnosers;
|
||||
|
||||
protected ErrorDiagnostics errorDiagnostics;
|
||||
|
||||
protected RuntimeInformation runtimeInformation;
|
||||
|
||||
|
@ -109,7 +108,7 @@ public class DefaultMaven
|
|||
{
|
||||
if ( request.getSettings().isOffline() )
|
||||
{
|
||||
getLogger().info( DiagnosisUtils.getOfflineWarning() );
|
||||
getLogger().info( SystemWarnings.getOfflineWarning() );
|
||||
|
||||
WagonManager wagonManager = null;
|
||||
|
||||
|
@ -650,20 +649,9 @@ public class DefaultMaven
|
|||
private void diagnoseError( Throwable error )
|
||||
{
|
||||
String message = null;
|
||||
if ( errorDiagnosers != null )
|
||||
if ( errorDiagnostics != null )
|
||||
{
|
||||
for ( Iterator it = errorDiagnosers.values().iterator(); it.hasNext(); )
|
||||
{
|
||||
ErrorDiagnoser diagnoser = (ErrorDiagnoser) it.next();
|
||||
|
||||
if ( diagnoser.canDiagnose( error ) )
|
||||
{
|
||||
message = diagnoser.diagnose( error );
|
||||
|
||||
// first one wins.
|
||||
break;
|
||||
}
|
||||
}
|
||||
message = errorDiagnostics.diagnose( error );
|
||||
}
|
||||
|
||||
if ( message == null )
|
||||
|
@ -698,20 +686,9 @@ public class DefaultMaven
|
|||
line();
|
||||
|
||||
String message = null;
|
||||
if ( errorDiagnosers != null )
|
||||
if ( errorDiagnostics != null )
|
||||
{
|
||||
for ( Iterator it = errorDiagnosers.values().iterator(); it.hasNext(); )
|
||||
{
|
||||
ErrorDiagnoser diagnoser = (ErrorDiagnoser) it.next();
|
||||
|
||||
if ( diagnoser.canDiagnose( error ) )
|
||||
{
|
||||
message = diagnoser.diagnose( error );
|
||||
|
||||
// first one wins.
|
||||
break;
|
||||
}
|
||||
}
|
||||
message = errorDiagnostics.diagnose( error );
|
||||
}
|
||||
|
||||
if ( message == null )
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.apache.maven.usability;
|
|||
|
||||
import org.apache.maven.artifact.manager.WagonManager;
|
||||
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
||||
import org.apache.maven.usability.diagnostics.DiagnosisUtils;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
|
||||
|
||||
public class ArtifactNotFoundDiagnoser
|
||||
implements ErrorDiagnoser
|
||||
|
@ -46,7 +48,7 @@ public class ArtifactNotFoundDiagnoser
|
|||
|
||||
if ( !wagonManager.isOnline() )
|
||||
{
|
||||
message.append( "\n" ).append( DiagnosisUtils.getOfflineWarning() );
|
||||
message.append( "\n" ).append( SystemWarnings.getOfflineWarning() );
|
||||
}
|
||||
|
||||
Throwable root = DiagnosisUtils.getRootCause( exception );
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.apache.maven.usability;
|
|||
|
||||
import org.apache.maven.artifact.manager.WagonManager;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.usability.diagnostics.DiagnosisUtils;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
|
||||
|
||||
public class ArtifactResolverDiagnoser
|
||||
implements ErrorDiagnoser
|
||||
|
@ -43,7 +45,7 @@ public class ArtifactResolverDiagnoser
|
|||
|
||||
if ( !wagonManager.isOnline() )
|
||||
{
|
||||
message.append( "\n" ).append( DiagnosisUtils.getOfflineWarning() );
|
||||
message.append( "\n" ).append( SystemWarnings.getOfflineWarning() );
|
||||
}
|
||||
|
||||
Throwable root = DiagnosisUtils.getRootCause( exception );
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.apache.maven.usability;
|
||||
|
||||
import org.apache.maven.artifact.InvalidArtifactRTException;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.apache.maven.usability;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.usability.diagnostics.DiagnosisUtils;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
|
||||
|
||||
public class MojoExecutionExceptionDiagnoser
|
||||
implements ErrorDiagnoser
|
||||
|
|
|
@ -21,6 +21,8 @@ import org.apache.maven.plugin.PluginParameterException;
|
|||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.Parameter;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.usability.diagnostics.DiagnosisUtils;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
|
||||
import org.apache.maven.usability.plugin.Expression;
|
||||
import org.apache.maven.usability.plugin.ExpressionDocumentationException;
|
||||
import org.apache.maven.usability.plugin.ExpressionDocumenter;
|
||||
|
|
|
@ -2,6 +2,8 @@ package org.apache.maven.usability;
|
|||
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.PluginContainerException;
|
||||
import org.apache.maven.usability.diagnostics.DiagnosisUtils;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
|
||||
|
||||
public class PluginContainerDiagnoser
|
||||
implements ErrorDiagnoser
|
||||
|
@ -31,7 +33,7 @@ public class PluginContainerDiagnoser
|
|||
|
||||
if ( originalMessage.startsWith( "Cannot resolve artifact" ) )
|
||||
{
|
||||
message.append( DiagnosisUtils.getOfflineWarning() );
|
||||
message.append( SystemWarnings.getOfflineWarning() );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.apache.maven.usability;
|
||||
|
||||
import org.apache.maven.profiles.activation.ProfileActivationException;
|
||||
import org.apache.maven.usability.diagnostics.DiagnosisUtils;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
|
||||
public class ProfileActivationDiagnoser
|
||||
|
|
|
@ -3,6 +3,8 @@ package org.apache.maven.usability;
|
|||
import org.apache.maven.project.InvalidProjectModelException;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.validation.ModelValidationResult;
|
||||
import org.apache.maven.usability.diagnostics.DiagnosisUtils;
|
||||
import org.apache.maven.usability.diagnostics.ErrorDiagnoser;
|
||||
|
||||
public class ProjectBuildDiagnoser
|
||||
implements ErrorDiagnoser
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package org.apache.maven.usability;
|
||||
|
||||
public class SystemWarnings
|
||||
{
|
||||
|
||||
public static String getOfflineWarning()
|
||||
{
|
||||
return "\nNOTE: Maven is executing in offline mode. Any artifacts not already in your local\n" +
|
||||
"repository will be inaccessible.\n";
|
||||
}
|
||||
|
||||
}
|
|
@ -78,8 +78,7 @@
|
|||
<role>org.apache.maven.lifecycle.LifecycleExecutor</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.usability.ErrorDiagnoser</role>
|
||||
<field-name>errorDiagnosers</field-name>
|
||||
<role>org.apache.maven.usability.diagnostics.ErrorDiagnostics</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.execution.RuntimeInformation</role>
|
||||
|
@ -97,7 +96,7 @@
|
|||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.usability.ErrorDiagnoser</role>
|
||||
<role>org.apache.maven.usability.diagnostics.ErrorDiagnoser</role>
|
||||
<role-hint>MojoExecutionExceptionDiagnoser</role-hint>
|
||||
<implementation>org.apache.maven.usability.MojoExecutionExceptionDiagnoser</implementation>
|
||||
</component>
|
||||
|
@ -107,7 +106,7 @@
|
|||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.usability.ErrorDiagnoser</role>
|
||||
<role>org.apache.maven.usability.diagnostics.ErrorDiagnoser</role>
|
||||
<role-hint>ProjectBuildDiagnoser</role-hint>
|
||||
<implementation>org.apache.maven.usability.ProjectBuildDiagnoser</implementation>
|
||||
</component>
|
||||
|
@ -117,7 +116,7 @@
|
|||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.usability.ErrorDiagnoser</role>
|
||||
<role>org.apache.maven.usability.diagnostics.ErrorDiagnoser</role>
|
||||
<role-hint>ProfileActivationDiagnoser</role-hint>
|
||||
<implementation>org.apache.maven.usability.ProfileActivationDiagnoser</implementation>
|
||||
</component>
|
||||
|
@ -127,7 +126,7 @@
|
|||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.usability.ErrorDiagnoser</role>
|
||||
<role>org.apache.maven.usability.diagnostics.ErrorDiagnoser</role>
|
||||
<role-hint>PluginConfigurationDiagnoser</role-hint>
|
||||
<implementation>org.apache.maven.usability.PluginConfigurationDiagnoser</implementation>
|
||||
</component>
|
||||
|
@ -137,7 +136,7 @@
|
|||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.usability.ErrorDiagnoser</role>
|
||||
<role>org.apache.maven.usability.diagnostics.ErrorDiagnoser</role>
|
||||
<role-hint>PluginContainerDiagnoser</role-hint>
|
||||
<implementation>org.apache.maven.usability.PluginContainerDiagnoser</implementation>
|
||||
</component>
|
||||
|
@ -147,7 +146,7 @@
|
|||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.usability.ErrorDiagnoser</role>
|
||||
<role>org.apache.maven.usability.diagnostics.ErrorDiagnoser</role>
|
||||
<role-hint>ArtifactNotFoundDiagnoser</role-hint>
|
||||
<implementation>org.apache.maven.usability.ArtifactNotFoundDiagnoser</implementation>
|
||||
<requirements>
|
||||
|
@ -162,7 +161,7 @@
|
|||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.usability.ErrorDiagnoser</role>
|
||||
<role>org.apache.maven.usability.diagnostics.ErrorDiagnoser</role>
|
||||
<role-hint>ArtifactResolverDiagnoser</role-hint>
|
||||
<implementation>org.apache.maven.usability.ArtifactResolverDiagnoser</implementation>
|
||||
<requirements>
|
||||
|
@ -177,7 +176,7 @@
|
|||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.usability.ErrorDiagnoser</role>
|
||||
<role>org.apache.maven.usability.diagnostics.ErrorDiagnoser</role>
|
||||
<role-hint>InvalidArtifactDiagnoser</role-hint>
|
||||
<implementation>org.apache.maven.usability.InvalidArtifactDiagnoser</implementation>
|
||||
</component>
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 ../../../m2-subclipse/maven-site/target/site/maven-v4_0_0.xsd ">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven</artifactId>
|
||||
<version>2.0-beta-4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>maven-error-diagnostics</artifactId>
|
||||
<name>Maven Error Diagnostics</name>
|
||||
|
||||
<description>
|
||||
Provides a manager component which will process a given Throwable instance through a set of diagnostic
|
||||
sub-components, and return a String message with user-friendly information about the error and possibly
|
||||
how to fix it.
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.usability;
|
||||
package org.apache.maven.usability.diagnostics;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -23,12 +23,6 @@ public final class DiagnosisUtils
|
|||
{
|
||||
}
|
||||
|
||||
public static String getOfflineWarning()
|
||||
{
|
||||
return "\nNOTE: Maven is executing in offline mode. Any artifacts not already in your local\n" +
|
||||
"repository will be inaccessible.\n";
|
||||
}
|
||||
|
||||
public static boolean containsInCausality( Throwable error, Class test )
|
||||
{
|
||||
Throwable cause = error;
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.usability;
|
||||
package org.apache.maven.usability.diagnostics;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
|
@ -0,0 +1,129 @@
|
|||
package org.apache.maven.usability.diagnostics;
|
||||
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.context.Context;
|
||||
import org.codehaus.plexus.context.ContextException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ErrorDiagnostics
|
||||
extends AbstractLogEnabled
|
||||
implements Contextualizable
|
||||
{
|
||||
public static final String ROLE = ErrorDiagnostics.class.getName();
|
||||
|
||||
private PlexusContainer container;
|
||||
|
||||
private List errorDiagnosers;
|
||||
|
||||
public void setErrorDiagnosers( List errorDiagnosers )
|
||||
{
|
||||
this.errorDiagnosers = errorDiagnosers;
|
||||
}
|
||||
|
||||
public String diagnose( Throwable error )
|
||||
{
|
||||
List diags = errorDiagnosers;
|
||||
|
||||
boolean releaseDiags = false;
|
||||
boolean errorProcessed = false;
|
||||
|
||||
String message = null;
|
||||
|
||||
try
|
||||
{
|
||||
if ( diags == null )
|
||||
{
|
||||
releaseDiags = true;
|
||||
|
||||
try
|
||||
{
|
||||
diags = container.lookupList( ErrorDiagnoser.ROLE );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
getLogger().error( "Failed to lookup the list of error diagnosers.", e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( diags != null )
|
||||
{
|
||||
for ( Iterator it = diags.iterator(); it.hasNext(); )
|
||||
{
|
||||
ErrorDiagnoser diagnoser = (ErrorDiagnoser) it.next();
|
||||
|
||||
if ( diagnoser.canDiagnose( error ) )
|
||||
{
|
||||
errorProcessed = true;
|
||||
|
||||
message = diagnose( error );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( releaseDiags && diags != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
container.releaseAll( diags );
|
||||
}
|
||||
catch ( ComponentLifecycleException e )
|
||||
{
|
||||
getLogger().debug( "Failed to release error diagnoser list.", e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !errorProcessed )
|
||||
{
|
||||
message = new PuntErrorDiagnoser().diagnose( error );
|
||||
}
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
public void contextualize( Context context )
|
||||
throws ContextException
|
||||
{
|
||||
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||
}
|
||||
|
||||
private static class PuntErrorDiagnoser implements ErrorDiagnoser
|
||||
{
|
||||
|
||||
public boolean canDiagnose( Throwable error )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public String diagnose( Throwable error )
|
||||
{
|
||||
StringBuffer message = new StringBuffer();
|
||||
|
||||
message.append( "Error: " ).append( error.getClass().getName() );
|
||||
message.append( "\nMessage: " ).append( error.getMessage() );
|
||||
|
||||
Throwable root = DiagnosisUtils.getRootCause( error );
|
||||
|
||||
if ( root != null && root != error )
|
||||
{
|
||||
message.append( "\n\nRoot Cause\n\n" );
|
||||
message.append( "Error: " ).append( root.getClass().getName() );
|
||||
message.append( "\nMessage: " ).append( root.getMessage() );
|
||||
}
|
||||
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.usability.diagnostics.ErrorDiagnostics</role>
|
||||
<implementation>org.apache.maven.usability.diagnostics.ErrorDiagnostics</implementation>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
|
@ -42,7 +42,7 @@ public class MBoot
|
|||
"maven-artifact", "maven-plugin-descriptor", "maven-repository-metadata", "maven-artifact-manager",
|
||||
"maven-artifact-test", "maven-script/maven-script-beanshell", "maven-profile", "maven-project",
|
||||
"maven-plugin-registry", "maven-reporting/maven-reporting-api", "maven-reporting/maven-reporting-impl",
|
||||
"maven-plugin-parameter-documenter", "maven-core", "maven-archiver",
|
||||
"maven-plugin-parameter-documenter", "maven-error-diagnostics", "maven-core", "maven-archiver",
|
||||
"maven-plugin-tools/maven-plugin-tools-api", "maven-plugin-tools/maven-plugin-tools-java",
|
||||
"maven-plugin-tools/maven-plugin-tools-beanshell", "maven-plugin-tools/maven-plugin-tools-pluggy",
|
||||
"maven-core-it-verifier"};
|
||||
|
|
Loading…
Reference in New Issue