PR: MNG-1110

differentiate between an artifact that is not found, and failure to obtain an artifact

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@307034 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-10-07 06:44:59 +00:00
parent 152130b172
commit 245d512c4a
31 changed files with 660 additions and 371 deletions

View File

@ -21,6 +21,7 @@ import org.apache.maven.archetype.descriptor.ArchetypeDescriptorBuilder;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.model.Build; import org.apache.maven.model.Build;
@ -82,12 +83,8 @@ public class DefaultArchetype
// artifactId = maven-foo-archetype // artifactId = maven-foo-archetype
// version = latest // version = latest
public void createArchetype( String archetypeGroupId, public void createArchetype( String archetypeGroupId, String archetypeArtifactId, String archetypeVersion,
String archetypeArtifactId, ArtifactRepository localRepository, List remoteRepositories, Map parameters )
String archetypeVersion,
ArtifactRepository localRepository,
List remoteRepositories,
Map parameters )
throws ArchetypeNotFoundException, ArchetypeDescriptorException, ArchetypeTemplateProcessingException throws ArchetypeNotFoundException, ArchetypeDescriptorException, ArchetypeTemplateProcessingException
{ {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -102,6 +99,11 @@ public class DefaultArchetype
artifactResolver.resolve( archetypeArtifact, remoteRepositories, localRepository ); artifactResolver.resolve( archetypeArtifact, remoteRepositories, localRepository );
} }
catch ( ArtifactResolutionException e ) catch ( ArtifactResolutionException e )
{
// TODO: this is an error now, not "not found"
throw new ArchetypeNotFoundException( "Cannot download archetype.", e );
}
catch ( ArtifactNotFoundException e )
{ {
throw new ArchetypeNotFoundException( "Cannot download archetype.", e ); throw new ArchetypeNotFoundException( "Cannot download archetype.", e );
} }
@ -115,7 +117,8 @@ public class DefaultArchetype
{ {
getLogger().info( "----------------------------------------------------------------------------" ); getLogger().info( "----------------------------------------------------------------------------" );
getLogger().info( "Using following parameters for creating Archetype: " + archetypeArtifactId + ":" + archetypeVersion ); getLogger().info( "Using following parameters for creating Archetype: " + archetypeArtifactId + ":" +
archetypeVersion );
getLogger().info( "----------------------------------------------------------------------------" ); getLogger().info( "----------------------------------------------------------------------------" );
@ -160,7 +163,8 @@ public class DefaultArchetype
if ( is == null ) if ( is == null )
{ {
throw new ArchetypeDescriptorException( "The " + ARCHETYPE_DESCRIPTOR + " descriptor cannot be found." ); throw new ArchetypeDescriptorException(
"The " + ARCHETYPE_DESCRIPTOR + " descriptor cannot be found." );
} }
descriptor = (ArchetypeDescriptor) builder.build( new InputStreamReader( is ) ); descriptor = (ArchetypeDescriptor) builder.build( new InputStreamReader( is ) );
@ -192,7 +196,8 @@ public class DefaultArchetype
if ( outputDirectoryFile.exists() ) if ( outputDirectoryFile.exists() )
{ {
throw new ArchetypeTemplateProcessingException( outputDirectoryFile.getName() + " already exists - please run from a clean directory" ); throw new ArchetypeTemplateProcessingException(
outputDirectoryFile.getName() + " already exists - please run from a clean directory" );
} }
pomFile = new File( outputDirectoryFile, ARCHETYPE_POM ); pomFile = new File( outputDirectoryFile, ARCHETYPE_POM );
@ -263,7 +268,8 @@ public class DefaultArchetype
if ( getLogger().isDebugEnabled() ) if ( getLogger().isDebugEnabled() )
{ {
getLogger().debug( "********************* Debug info for resources created from generated Model ***********************" ); getLogger().debug(
"********************* Debug info for resources created from generated Model ***********************" );
} }
if ( getLogger().isDebugEnabled() ) if ( getLogger().isDebugEnabled() )
@ -285,7 +291,8 @@ public class DefaultArchetype
srcDirectory = StringUtils.replace( srcDirectory, "\\", "/" ); srcDirectory = StringUtils.replace( srcDirectory, "\\", "/" );
FileUtils.mkdir( outputDirectory + ( srcDirectory.startsWith( "/" ) ? srcDirectory : ( "/" + srcDirectory ) ) ); FileUtils.mkdir(
outputDirectory + ( srcDirectory.startsWith( "/" ) ? srcDirectory : ( "/" + srcDirectory ) ) );
} }
// create script source directory if specified in POM // create script source directory if specified in POM
@ -326,7 +333,8 @@ public class DefaultArchetype
resourceDirectory = StringUtils.replace( resourceDirectory, "\\", "/" ); resourceDirectory = StringUtils.replace( resourceDirectory, "\\", "/" );
FileUtils.mkdir( outputDirectory + ( resourceDirectory.startsWith( "/" ) ? resourceDirectory : ( "/" + resourceDirectory ) ) ); FileUtils.mkdir( outputDirectory +
( resourceDirectory.startsWith( "/" ) ? resourceDirectory : ( "/" + resourceDirectory ) ) );
} }
} }
// create test source directory if specified in POM // create test source directory if specified in POM
@ -343,7 +351,8 @@ public class DefaultArchetype
testDirectory = StringUtils.replace( testDirectory, "\\", "/" ); testDirectory = StringUtils.replace( testDirectory, "\\", "/" );
FileUtils.mkdir( outputDirectory + ( testDirectory.startsWith( "/" ) ? testDirectory : ( "/" + testDirectory ) ) ); FileUtils.mkdir(
outputDirectory + ( testDirectory.startsWith( "/" ) ? testDirectory : ( "/" + testDirectory ) ) );
} }
// create test resource directory if specified in POM // create test resource directory if specified in POM
@ -371,7 +380,8 @@ public class DefaultArchetype
} }
} }
getLogger().info( "********************* End of debug info from resources from generated POM ***********************" ); getLogger().info(
"********************* End of debug info from resources from generated POM ***********************" );
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Main // Main
@ -473,8 +483,8 @@ public class DefaultArchetype
} }
} }
protected void processTemplate( String outputDirectory, Context context, String template, protected void processTemplate( String outputDirectory, Context context, String template, boolean packageInFileName,
boolean packageInFileName, String packageName ) String packageName )
throws Exception throws Exception
{ {
File f; File f;

View File

@ -21,6 +21,7 @@ import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.ArtifactResolver;
@ -177,6 +178,11 @@ public class DependenciesTask
{ {
throw new BuildException( "Unable to resolve artifact", 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 ) if ( pathId != null && getProject().getReference( pathId ) != null )
{ {

View File

@ -20,6 +20,7 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.ArtifactResolver;
@ -105,6 +106,10 @@ public class InstallWagonProviderTask
{ {
throw new BuildException( "Unable to locate wagon provider in remote repository", 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 );
}
} }
} }

View File

@ -59,20 +59,20 @@ public class DefaultArtifactResolver
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
resolve( artifact, remoteRepositories, localRepository, false ); resolve( artifact, remoteRepositories, localRepository, false );
} }
public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
resolve( artifact, remoteRepositories, localRepository, true ); resolve( artifact, remoteRepositories, localRepository, true );
} }
private void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository, private void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository,
boolean force ) boolean force )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
if ( artifact != null ) if ( artifact != null )
{ {
@ -82,7 +82,7 @@ public class DefaultArtifactResolver
if ( !systemFile.exists() ) if ( !systemFile.exists() )
{ {
throw new ArtifactResolutionException( throw new ArtifactNotFoundException(
"System artifact: " + artifact.getId() + " not found in path: " + systemFile, artifact ); "System artifact: " + artifact.getId() + " not found in path: " + systemFile, artifact );
} }
else else
@ -143,7 +143,7 @@ public class DefaultArtifactResolver
} }
catch ( ResourceDoesNotExistException e ) catch ( ResourceDoesNotExistException e )
{ {
throw new ArtifactResolutionException( e.getMessage(), artifact, remoteRepositories, e ); throw new ArtifactNotFoundException( e.getMessage(), artifact, remoteRepositories, e );
} }
catch ( TransferFailedException e ) catch ( TransferFailedException e )
{ {
@ -179,7 +179,7 @@ public class DefaultArtifactResolver
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
ArtifactRepository localRepository, List remoteRepositories, ArtifactRepository localRepository, List remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter ) ArtifactMetadataSource source, ArtifactFilter filter )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository,
remoteRepositories, source, filter ); remoteRepositories, source, filter );
@ -189,7 +189,7 @@ public class DefaultArtifactResolver
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
Map managedVersions, ArtifactRepository localRepository, Map managedVersions, ArtifactRepository localRepository,
List remoteRepositories, ArtifactMetadataSource source ) List remoteRepositories, ArtifactMetadataSource source )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository, return resolveTransitively( artifacts, originatingArtifact, managedVersions, localRepository,
remoteRepositories, source, null ); remoteRepositories, source, null );
@ -199,7 +199,7 @@ public class DefaultArtifactResolver
Map managedVersions, ArtifactRepository localRepository, Map managedVersions, ArtifactRepository localRepository,
List remoteRepositories, ArtifactMetadataSource source, List remoteRepositories, ArtifactMetadataSource source,
ArtifactFilter filter ) ArtifactFilter filter )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
// TODO: this is simplistic // TODO: this is simplistic
List listeners = new ArrayList(); List listeners = new ArrayList();
@ -219,7 +219,7 @@ public class DefaultArtifactResolver
Map managedVersions, ArtifactRepository localRepository, Map managedVersions, ArtifactRepository localRepository,
List remoteRepositories, ArtifactMetadataSource source, List remoteRepositories, ArtifactMetadataSource source,
ArtifactFilter filter, List listeners ) ArtifactFilter filter, List listeners )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
ArtifactResolutionResult artifactResolutionResult; ArtifactResolutionResult artifactResolutionResult;
artifactResolutionResult = artifactCollector.collect( artifacts, originatingArtifact, managedVersions, artifactResolutionResult = artifactCollector.collect( artifacts, originatingArtifact, managedVersions,
@ -238,7 +238,7 @@ public class DefaultArtifactResolver
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
List remoteRepositories, ArtifactRepository localRepository, List remoteRepositories, ArtifactRepository localRepository,
ArtifactMetadataSource source ) ArtifactMetadataSource source )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
return resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, source, null ); return resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, source, null );
} }
@ -246,7 +246,7 @@ public class DefaultArtifactResolver
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
List remoteRepositories, ArtifactRepository localRepository, List remoteRepositories, ArtifactRepository localRepository,
ArtifactMetadataSource source, List listeners ) ArtifactMetadataSource source, List listeners )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository, return resolveTransitively( artifacts, originatingArtifact, Collections.EMPTY_MAP, localRepository,
remoteRepositories, source, null, listeners ); remoteRepositories, source, null, listeners );

View File

@ -205,7 +205,7 @@ public class ArtifactResolverTest
artifactResolver.resolve( k, remoteRepositories(), localRepository() ); artifactResolver.resolve( k, remoteRepositories(), localRepository() );
fail( "Resolution succeeded when it should have failed" ); fail( "Resolution succeeded when it should have failed" );
} }
catch ( ArtifactResolutionException expected ) catch ( ArtifactNotFoundException expected )
{ {
assertTrue( true ); assertTrue( true );
} }

View File

@ -20,6 +20,8 @@ import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import java.io.File; import java.io.File;
@ -154,4 +156,10 @@ public interface Artifact
void setAvailableVersions( List versions ); void setAvailableVersions( List versions );
boolean isOptional(); boolean isOptional();
ArtifactVersion getSelectedVersion()
throws OverConstrainedVersionException;
boolean isSelectedVersionKnown()
throws OverConstrainedVersionException;
} }

View File

@ -20,6 +20,8 @@ import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
@ -520,4 +522,16 @@ public class DefaultArtifact
{ {
return optional; return optional;
} }
public ArtifactVersion getSelectedVersion()
throws OverConstrainedVersionException
{
return versionRange.getSelectedVersion( this );
}
public boolean isSelectedVersionKnown()
throws OverConstrainedVersionException
{
return versionRange.isSelectedVersionKnown( this );
}
} }

View File

@ -0,0 +1,188 @@
package org.apache.maven.artifact.resolver;
/*
* 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.
*/
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.Iterator;
import java.util.List;
/**
* Base class for artifact resolution exceptions.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class AbstractArtifactResolutionException
extends Exception
{
private String groupId;
private String artifactId;
private String version;
private String type;
private List remoteRepositories;
private final String originalMessage;
private final String path;
static final String LS = System.getProperty( "line.separator" );
protected AbstractArtifactResolutionException( String message, String groupId, String artifactId, String version,
String type, List remoteRepositories, List path )
{
super( constructMessageBase( message, groupId, artifactId, version, type, remoteRepositories, path ) );
this.originalMessage = message;
this.groupId = groupId;
this.artifactId = artifactId;
this.type = type;
this.version = version;
this.remoteRepositories = remoteRepositories;
this.path = constructArtifactPath( path );
}
protected AbstractArtifactResolutionException( String message, String groupId, String artifactId, String version,
String type, List remoteRepositories, List path, Throwable t )
{
super( constructMessageBase( message, groupId, artifactId, version, type, remoteRepositories, path ), t );
this.originalMessage = message;
this.groupId = groupId;
this.artifactId = artifactId;
this.type = type;
this.version = version;
this.remoteRepositories = remoteRepositories;
this.path = constructArtifactPath( path );
}
protected AbstractArtifactResolutionException( String message, Artifact artifact )
{
this( message, artifact, null );
}
protected AbstractArtifactResolutionException( String message, Artifact artifact, List remoteRepositories )
{
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(),
remoteRepositories, artifact.getDependencyTrail() );
}
protected AbstractArtifactResolutionException( String message, Artifact artifact, List remoteRepositories,
Throwable t )
{
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(),
remoteRepositories, artifact.getDependencyTrail(), t );
}
public String getGroupId()
{
return groupId;
}
public String getArtifactId()
{
return artifactId;
}
public String getVersion()
{
return version;
}
public String getType()
{
return type;
}
public List getRemoteRepositories()
{
return remoteRepositories;
}
public String getOriginalMessage()
{
return originalMessage;
}
protected static String constructArtifactPath( List path )
{
StringBuffer sb = new StringBuffer();
if ( path != null )
{
sb.append( LS );
sb.append( "Path to dependency: " );
sb.append( LS );
int num = 1;
for ( Iterator i = path.iterator(); i.hasNext(); )
{
sb.append( "\t" );
sb.append( num++ );
sb.append( ") " );
sb.append( i.next() );
sb.append( LS );
}
}
return sb.toString();
}
private static String constructMessageBase( String message, String groupId, String artifactId, String version,
String type, List remoteRepositories, List path )
{
StringBuffer sb = new StringBuffer();
sb.append( message );
sb.append( LS );
sb.append( " " + groupId + ":" + artifactId + ":" + version + ":" + type );
sb.append( LS );
if ( remoteRepositories != null && !remoteRepositories.isEmpty() )
{
sb.append( LS );
sb.append( "from the specified remote repositories:" );
sb.append( LS + " " );
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
{
ArtifactRepository remoteRepository = (ArtifactRepository) i.next();
sb.append( remoteRepository.getId() );
sb.append( " (" );
sb.append( remoteRepository.getUrl() );
sb.append( ")" );
if ( i.hasNext() )
{
sb.append( ",\n " );
}
}
}
sb.append( constructArtifactPath( path ) );
sb.append( LS );
return sb.toString();
}
public String getArtifactPath()
{
return path;
}
}

View File

@ -0,0 +1,97 @@
package org.apache.maven.artifact.resolver;
/*
* 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.
*/
import org.apache.maven.artifact.Artifact;
import java.util.List;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
*/
public class ArtifactNotFoundException
extends AbstractArtifactResolutionException
{
private String downloadUrl;
protected ArtifactNotFoundException( String message, Artifact artifact )
{
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), null,
null );
}
protected ArtifactNotFoundException( String message, Artifact artifact, List remoteRepositories, Throwable t )
{
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(),
remoteRepositories, null, t );
}
public ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type,
List remoteRepositories, String downloadUrl, Throwable t )
{
super( constructMessage( message, groupId, artifactId, version, type, downloadUrl ), groupId, artifactId,
version, type, remoteRepositories, null, t );
this.downloadUrl = downloadUrl;
}
private ArtifactNotFoundException( String message, String groupId, String artifactId, String version, String type,
List remoteRepositories, String downloadUrl )
{
super( constructMessage( message, groupId, artifactId, version, type, downloadUrl ), groupId, artifactId,
version, type, remoteRepositories, null );
this.downloadUrl = downloadUrl;
}
private static String constructMessage( String message, String groupId, String artifactId, String version,
String type, String downloadUrl )
{
StringBuffer sb = new StringBuffer( message );
if ( downloadUrl != null && !"pom".equals( type ) )
{
sb.append( LS );
sb.append( LS );
sb.append( "Try downloading the file manually from" );
sb.append( LS );
sb.append( " " );
sb.append( downloadUrl );
sb.append( LS );
sb.append( "and install it using the command: " );
sb.append( LS );
sb.append( " m2 install:install-file -DgroupId=" );
sb.append( groupId );
sb.append( " -DartifactId=" );
sb.append( artifactId );
sb.append( " -Dversion=" );
sb.append( version );
sb.append( " -Dpackaging=" );
sb.append( type );
sb.append( " -Dfile=/path/to/file" );
}
return sb.toString();
}
public String getDownloadUrl()
{
return downloadUrl;
}
}

View File

@ -17,9 +17,7 @@ package org.apache.maven.artifact.resolver;
*/ */
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import java.util.Iterator;
import java.util.List; import java.util.List;
/** /**
@ -27,24 +25,30 @@ import java.util.List;
* @version $Id$ * @version $Id$
*/ */
public class ArtifactResolutionException public class ArtifactResolutionException
extends Exception extends AbstractArtifactResolutionException
{ {
private String groupId; public ArtifactResolutionException( String message, String groupId, String artifactId, String version, String type,
List remoteRepositories, List path, Throwable t )
{
super( message, groupId, artifactId, version, type, remoteRepositories, path, t );
}
private String artifactId; public ArtifactResolutionException( String message, Artifact artifact )
{
super( message, artifact );
}
private String version; protected ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories )
{
super( message, artifact, remoteRepositories );
}
private String type; protected ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories, Throwable t )
{
private String downloadUrl; super( message, artifact, remoteRepositories, t );
}
private List remoteRepositories;
private final String originalMessage;
private final String path;
/*
public ArtifactResolutionException( String message, String groupId, String artifactId, String version, String type, public ArtifactResolutionException( String message, String groupId, String artifactId, String version, String type,
List remoteRepositories, String downloadUrl, List path, Throwable t ) List remoteRepositories, String downloadUrl, List path, Throwable t )
{ {
@ -57,8 +61,8 @@ public class ArtifactResolutionException
this.type = type; this.type = type;
this.version = version; this.version = version;
this.remoteRepositories = remoteRepositories; this.remoteRepositories = remoteRepositories;
this.downloadUrl = downloadUrl;
this.path = constructArtifactPath( path ); this.path = constructArtifactPath( path );
this.downloadUrl = downloadUrl;
} }
public ArtifactResolutionException( String message, String groupId, String artifactId, String version, String type, public ArtifactResolutionException( String message, String groupId, String artifactId, String version, String type,
@ -82,93 +86,6 @@ public class ArtifactResolutionException
this.path = constructArtifactPath( path ); this.path = constructArtifactPath( path );
} }
public String getOriginalMessage()
{
return originalMessage;
}
private static final String LS = System.getProperty( "line.separator" );
private static String constructArtifactPath( List path )
{
StringBuffer sb = new StringBuffer();
if ( path != null )
{
sb.append( LS );
sb.append( "Path to dependency: " );
sb.append( LS );
int num = 1;
for ( Iterator i = path.iterator(); i.hasNext(); )
{
sb.append( "\t" );
sb.append( num++ );
sb.append( ") " );
sb.append( i.next() );
sb.append( LS );
}
}
return sb.toString();
}
private static String constructMessage( String message, String groupId, String artifactId, String version,
String type, List remoteRepositories, String downloadUrl, List path )
{
StringBuffer sb = new StringBuffer();
sb.append( message );
sb.append( LS );
sb.append( " " + groupId + ":" + artifactId + ":" + version + ":" + type );
sb.append( LS );
if ( remoteRepositories != null && !remoteRepositories.isEmpty() )
{
sb.append( LS );
sb.append( "from the specified remote repositories:" );
sb.append( LS + " " );
for ( Iterator i = remoteRepositories.iterator(); i.hasNext(); )
{
ArtifactRepository remoteRepository = (ArtifactRepository) i.next();
sb.append( remoteRepository.getId() );
sb.append( " (" );
sb.append( remoteRepository.getUrl() );
sb.append( ")" );
if ( i.hasNext() )
{
sb.append( ",\n " );
}
}
}
sb.append( constructArtifactPath( path ) );
sb.append( LS );
if ( downloadUrl != null && !type.equals( "pom" ) )
{
sb.append( LS );
sb.append( LS );
sb.append( "Try downloading the file manually from" );
sb.append( LS );
sb.append( " " + downloadUrl );
sb.append( LS );
sb.append( "and install it using the command: " );
sb.append( LS );
sb.append( " m2 install:install-file -DgroupId=" );
sb.append( groupId );
sb.append( " -DartifactId=" );
sb.append( artifactId );
sb.append( " -Dversion=" );
sb.append( version );
sb.append( " -Dpackaging=" );
sb.append( type );
sb.append( " -Dfile=/path/to/file" );
}
return sb.toString();
}
public ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories, Throwable t ) public ArtifactResolutionException( String message, Artifact artifact, List remoteRepositories, Throwable t )
{ {
this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), this( message, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(),
@ -195,39 +112,5 @@ public class ArtifactResolutionException
this.path = ""; this.path = "";
} }
public String getGroupId() */
{
return groupId;
}
public String getArtifactId()
{
return artifactId;
}
public String getVersion()
{
return version;
}
public String getType()
{
return type;
}
public List getRemoteRepositories()
{
return remoteRepositories;
}
public String getDownloadUrl()
{
return downloadUrl;
}
public String getArtifactPath()
{
return path;
}
} }

View File

@ -38,37 +38,37 @@ public interface ArtifactResolver
String ROLE = ArtifactResolver.class.getName(); String ROLE = ArtifactResolver.class.getName();
void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactResolutionException; throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories,
ArtifactRepository localRepository, ArtifactMetadataSource source ) ArtifactRepository localRepository, ArtifactMetadataSource source )
throws ArtifactResolutionException; throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories, ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories,
ArtifactRepository localRepository, ArtifactMetadataSource source, ArtifactRepository localRepository, ArtifactMetadataSource source,
List listeners ) List listeners )
throws ArtifactResolutionException; throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
ArtifactRepository localRepository, List remoteRepositories, ArtifactRepository localRepository, List remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter ) ArtifactMetadataSource source, ArtifactFilter filter )
throws ArtifactResolutionException; throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions,
ArtifactRepository localRepository, List remoteRepositories, ArtifactRepository localRepository, List remoteRepositories,
ArtifactMetadataSource source ) ArtifactMetadataSource source )
throws ArtifactResolutionException; throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions,
ArtifactRepository localRepository, List remoteRepositories, ArtifactRepository localRepository, List remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter ) ArtifactMetadataSource source, ArtifactFilter filter )
throws ArtifactResolutionException; throws ArtifactResolutionException, ArtifactNotFoundException;
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions, ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, Map managedVersions,
ArtifactRepository localRepository, List remoteRepositories, ArtifactRepository localRepository, List remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter, List listeners ) ArtifactMetadataSource source, ArtifactFilter filter, List listeners )
throws ArtifactResolutionException; throws ArtifactResolutionException, ArtifactNotFoundException;
void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository ) void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
throws ArtifactResolutionException; throws ArtifactResolutionException, ArtifactNotFoundException;
} }

View File

@ -62,8 +62,6 @@ public class DefaultArtifactCollector
ResolutionNode root = new ResolutionNode( originatingArtifact, remoteRepositories ); ResolutionNode root = new ResolutionNode( originatingArtifact, remoteRepositories );
try
{
root.addDependencies( artifacts, remoteRepositories, filter ); root.addDependencies( artifacts, remoteRepositories, filter );
recurse( root, resolvedArtifacts, managedVersions, localRepository, remoteRepositories, source, filter, recurse( root, resolvedArtifacts, managedVersions, localRepository, remoteRepositories, source, filter,
@ -96,11 +94,6 @@ public class DefaultArtifactCollector
result.setArtifactResolutionNodes( set ); result.setArtifactResolutionNodes( set );
return result; return result;
} }
catch ( OverConstrainedVersionException e )
{
throw new ArtifactResolutionException( "Unable to mediate dependency", e );
}
}
private void recurse( ResolutionNode node, Map resolvedArtifacts, Map managedVersions, private void recurse( ResolutionNode node, Map resolvedArtifacts, Map managedVersions,
ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source, ArtifactRepository localRepository, List remoteRepositories, ArtifactMetadataSource source,
@ -212,11 +205,9 @@ public class DefaultArtifactCollector
if ( artifact.getVersion() == null ) if ( artifact.getVersion() == null )
{ {
// set the recommended version // set the recommended version
VersionRange versionRange = artifact.getVersionRange();
// TODO: maybe its better to just pass the range through to retrieval and use a transformation? // TODO: maybe its better to just pass the range through to retrieval and use a transformation?
ArtifactVersion version; ArtifactVersion version;
if ( !versionRange.isSelectedVersionKnown() ) if ( !artifact.isSelectedVersionKnown() )
{ {
List versions = artifact.getAvailableVersions(); List versions = artifact.getAvailableVersions();
if ( versions == null ) if ( versions == null )
@ -226,6 +217,7 @@ public class DefaultArtifactCollector
artifact.setAvailableVersions( versions ); artifact.setAvailableVersions( versions );
} }
VersionRange versionRange = artifact.getVersionRange();
version = versionRange.matchVersion( versions ); version = versionRange.matchVersion( versions );
if ( version == null ) if ( version == null )
@ -234,18 +226,19 @@ public class DefaultArtifactCollector
{ {
throw new OverConstrainedVersionException( throw new OverConstrainedVersionException(
"No versions are present in the repository for the artifact with a range " + "No versions are present in the repository for the artifact with a range " +
versionRange ); versionRange, artifact, remoteRepositories );
} }
else else
{ {
throw new OverConstrainedVersionException( "Couldn't find a version in " + throw new OverConstrainedVersionException( "Couldn't find a version in " +
versions + " to match range " + versionRange ); versions + " to match range " + versionRange, artifact,
remoteRepositories );
} }
} }
} }
else else
{ {
version = versionRange.getSelectedVersion(); version = artifact.getSelectedVersion();
} }
artifact.selectVersion( version.toString() ); artifact.selectVersion( version.toString() );

View File

@ -116,7 +116,7 @@ public class ResolutionNode
{ {
// set the recommended version // set the recommended version
VersionRange versionRange = artifact.getVersionRange(); VersionRange versionRange = artifact.getVersionRange();
String version = versionRange.getSelectedVersion().toString(); String version = artifact.getSelectedVersion().toString();
artifact.selectVersion( version ); artifact.selectVersion( version );
} }

View File

@ -32,9 +32,4 @@ public class TransitiveArtifactResolutionException
{ {
super( message, artifact, remoteRepositories, t ); super( message, artifact, remoteRepositories, t );
} }
public TransitiveArtifactResolutionException( String message, Throwable cause )
{
super( message, cause );
}
} }

View File

@ -1,5 +1,10 @@
package org.apache.maven.artifact.versioning; package org.apache.maven.artifact.versioning;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import java.util.List;
/* /*
* Copyright 2001-2005 The Apache Software Foundation. * Copyright 2001-2005 The Apache Software Foundation.
* *
@ -23,10 +28,16 @@ package org.apache.maven.artifact.versioning;
* @version $Id$ * @version $Id$
*/ */
public class OverConstrainedVersionException public class OverConstrainedVersionException
extends Exception extends ArtifactResolutionException
{ {
public OverConstrainedVersionException( String msg ) public OverConstrainedVersionException( String msg, Artifact artifact )
{ {
super( msg ); super( msg, artifact );
} }
public OverConstrainedVersionException( String msg, Artifact artifact, List remoteRepositories )
{
super( msg, artifact, remoteRepositories );
}
} }

View File

@ -16,6 +16,8 @@ package org.apache.maven.artifact.versioning;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.maven.artifact.Artifact;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
@ -377,27 +379,7 @@ public class VersionRange
return restrictions; return restrictions;
} }
private ArtifactVersion max( ArtifactVersion v1, ArtifactVersion v2 ) public ArtifactVersion getSelectedVersion( Artifact artifact )
{
if ( v1 == null )
{
return v2;
}
if ( v2 == null )
{
return v1;
}
else if ( v1.compareTo( v2 ) > 0 )
{
return v1;
}
else
{
return v2;
}
}
public ArtifactVersion getSelectedVersion()
throws OverConstrainedVersionException throws OverConstrainedVersionException
{ {
ArtifactVersion version; ArtifactVersion version;
@ -409,7 +391,7 @@ public class VersionRange
{ {
if ( restrictions.size() == 0 ) if ( restrictions.size() == 0 )
{ {
throw new OverConstrainedVersionException( "The artifact has no valid ranges" ); throw new OverConstrainedVersionException( "The artifact has no valid ranges", artifact );
} }
else else
{ {
@ -425,7 +407,7 @@ public class VersionRange
return version; return version;
} }
public boolean isSelectedVersionKnown() public boolean isSelectedVersionKnown( Artifact artifact )
throws OverConstrainedVersionException throws OverConstrainedVersionException
{ {
boolean value = false; boolean value = false;
@ -437,7 +419,7 @@ public class VersionRange
{ {
if ( restrictions.size() == 0 ) if ( restrictions.size() == 0 )
{ {
throw new OverConstrainedVersionException( "The artifact has no valid ranges" ); throw new OverConstrainedVersionException( "The artifact has no valid ranges", artifact );
} }
else else
{ {

View File

@ -18,6 +18,7 @@ package org.apache.maven;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion; import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest;
@ -255,7 +256,7 @@ public class DefaultMaven
logError( response ); logError( response );
} }
} }
else if ( exception instanceof ArtifactResolutionException ) else if ( exception instanceof ArtifactNotFoundException )
{ {
logFailure( response, exception, null ); logFailure( response, exception, null );
} }
@ -487,13 +488,8 @@ public class DefaultMaven
protected MavenSession createSession( MavenExecutionRequest request, ReactorManager rpm ) protected MavenSession createSession( MavenExecutionRequest request, ReactorManager rpm )
{ {
return new MavenSession( container, return new MavenSession( container, request.getSettings(), request.getLocalRepository(),
request.getSettings(), request.getEventDispatcher(), rpm, request.getGoals(), request.getBaseDirectory(),
request.getLocalRepository(),
request.getEventDispatcher(),
rpm,
request.getGoals(),
request.getBaseDirectory(),
request.getExecutionProperties() ); request.getExecutionProperties() );
} }

View File

@ -20,6 +20,7 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.ArtifactResolver;
@ -52,7 +53,8 @@ public class DefaultExtensionManager
private PlexusContainer container; private PlexusContainer container;
public void addExtension( Extension extension, MavenProject project, ArtifactRepository localRepository ) public void addExtension( Extension extension, MavenProject project, ArtifactRepository localRepository )
throws ArtifactResolutionException, PlexusContainerException, InvalidVersionSpecificationException throws ArtifactResolutionException, PlexusContainerException, InvalidVersionSpecificationException,
ArtifactNotFoundException
{ {
String extensionId = ArtifactUtils.versionlessKey( extension.getGroupId(), extension.getArtifactId() ); String extensionId = ArtifactUtils.versionlessKey( extension.getGroupId(), extension.getArtifactId() );

View File

@ -17,6 +17,7 @@ package org.apache.maven.extension;
*/ */
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.model.Extension; import org.apache.maven.model.Extension;
@ -32,5 +33,6 @@ import org.codehaus.plexus.PlexusContainerException;
public interface ExtensionManager public interface ExtensionManager
{ {
void addExtension( Extension extension, MavenProject project, ArtifactRepository localRepository ) void addExtension( Extension extension, MavenProject project, ArtifactRepository localRepository )
throws ArtifactResolutionException, PlexusContainerException, InvalidVersionSpecificationException; throws ArtifactResolutionException, PlexusContainerException, InvalidVersionSpecificationException,
ArtifactNotFoundException;
} }

View File

@ -19,6 +19,7 @@ package org.apache.maven.lifecycle;
import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.execution.MavenExecutionResponse; import org.apache.maven.execution.MavenExecutionResponse;
@ -38,7 +39,6 @@ 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;
import org.apache.maven.plugin.PluginManagerException; import org.apache.maven.plugin.PluginManagerException;
import org.apache.maven.plugin.PluginNotFoundException;
import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.lifecycle.Execution; import org.apache.maven.plugin.lifecycle.Execution;
@ -157,6 +157,10 @@ public class DefaultLifecycleExecutor
{ {
response.setException( e ); response.setException( e );
} }
catch ( ArtifactNotFoundException e )
{
response.setException( e );
}
catch ( ArtifactResolutionException e ) catch ( ArtifactResolutionException e )
{ {
response.setException( e ); response.setException( e );
@ -196,8 +200,7 @@ public class DefaultLifecycleExecutor
private void executeTaskSegments( List taskSegments, ReactorManager rm, MavenSession session, private void executeTaskSegments( List taskSegments, ReactorManager rm, MavenSession session,
MavenProject rootProject, EventDispatcher dispatcher, MavenProject rootProject, EventDispatcher dispatcher,
MavenExecutionResponse response ) MavenExecutionResponse response )
throws PluginNotFoundException, MojoExecutionException, ArtifactResolutionException, throws ArtifactNotFoundException, MojoExecutionException, LifecycleExecutionException, MojoFailureException
LifecycleExecutionException, MojoFailureException
{ {
for ( Iterator it = taskSegments.iterator(); it.hasNext(); ) for ( Iterator it = taskSegments.iterator(); it.hasNext(); )
{ {
@ -234,16 +237,22 @@ public class DefaultLifecycleExecutor
} }
catch ( MojoExecutionException e ) catch ( MojoExecutionException e )
{ {
// TODO: should this be removed?
handleExecutionFailure( rm, rootProject, e, task ); handleExecutionFailure( rm, rootProject, e, task );
} }
catch ( ArtifactResolutionException e ) catch ( ArtifactResolutionException e )
{ {
// TODO: should this be removed?
handleExecutionFailure( rm, rootProject, e, task ); handleExecutionFailure( rm, rootProject, e, task );
} }
catch ( MojoFailureException e ) catch ( MojoFailureException e )
{ {
handleExecutionFailure( rm, rootProject, e, task ); handleExecutionFailure( rm, rootProject, e, task );
} }
catch ( ArtifactNotFoundException e )
{
handleExecutionFailure( rm, rootProject, e, task );
}
} }
dispatcher.dispatchEnd( event, rootProject.getId() + " ( " + segment + " )" ); dispatcher.dispatchEnd( event, rootProject.getId() + " ( " + segment + " )" );
@ -308,16 +317,22 @@ public class DefaultLifecycleExecutor
} }
catch ( MojoExecutionException e ) catch ( MojoExecutionException e )
{ {
// TODO: should this be removed?
handleExecutionFailure( rm, currentProject, e, task ); handleExecutionFailure( rm, currentProject, e, task );
} }
catch ( ArtifactResolutionException e ) catch ( ArtifactResolutionException e )
{ {
// TODO: should this be removed?
handleExecutionFailure( rm, currentProject, e, task ); handleExecutionFailure( rm, currentProject, e, task );
} }
catch ( MojoFailureException e ) catch ( MojoFailureException e )
{ {
handleExecutionFailure( rm, currentProject, e, task ); handleExecutionFailure( rm, currentProject, e, task );
} }
catch ( ArtifactNotFoundException e )
{
handleExecutionFailure( rm, currentProject, e, task );
}
} }
dispatcher.dispatchEnd( event, currentProject.getId() + " ( " + segment + " )" ); dispatcher.dispatchEnd( event, currentProject.getId() + " ( " + segment + " )" );
@ -348,7 +363,7 @@ public class DefaultLifecycleExecutor
} }
private void handleExecutionFailure( ReactorManager rm, MavenProject project, Exception e, String task ) private void handleExecutionFailure( ReactorManager rm, MavenProject project, Exception e, String task )
throws MojoExecutionException, ArtifactResolutionException, MojoFailureException throws MojoExecutionException, MojoFailureException, ArtifactNotFoundException
{ {
if ( ReactorManager.FAIL_FAST.equals( rm.getFailureBehavior() ) ) if ( ReactorManager.FAIL_FAST.equals( rm.getFailureBehavior() ) )
{ {
@ -362,9 +377,9 @@ public class DefaultLifecycleExecutor
{ {
throw (MojoFailureException) e; throw (MojoFailureException) e;
} }
else if ( e instanceof ArtifactResolutionException ) else if ( e instanceof ArtifactNotFoundException )
{ {
throw (ArtifactResolutionException) e; throw (ArtifactNotFoundException) e;
} }
else else
{ {
@ -383,6 +398,7 @@ public class DefaultLifecycleExecutor
} }
private List segmentTaskListByAggregationNeeds( List tasks, MavenSession session, MavenProject project ) private List segmentTaskListByAggregationNeeds( List tasks, MavenSession session, MavenProject project )
throws LifecycleExecutionException
{ {
List segments = new ArrayList(); List segments = new ArrayList();
@ -419,13 +435,13 @@ public class DefaultLifecycleExecutor
// definitely a CLI goal, can use prefix // definitely a CLI goal, can use prefix
mojo = getMojoDescriptor( task, session, project, task, true ); mojo = getMojoDescriptor( task, session, project, task, true );
} }
catch ( LifecycleExecutionException e ) catch ( ArtifactResolutionException e )
{ {
getLogger().info( getLogger().info(
"Cannot find mojo descriptor for: \'" + task + "\' - Treating as non-aggregator." ); "Cannot find mojo descriptor for: \'" + task + "\' - Treating as non-aggregator." );
getLogger().debug( "", e ); getLogger().debug( "", e );
} }
catch ( ArtifactResolutionException e ) catch ( ArtifactNotFoundException e )
{ {
getLogger().info( getLogger().info(
"Cannot find mojo descriptor for: \'" + task + "\' - Treating as non-aggregator." ); "Cannot find mojo descriptor for: \'" + task + "\' - Treating as non-aggregator." );
@ -484,7 +500,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, PluginNotFoundException, MojoExecutionException, throws LifecycleExecutionException, ArtifactNotFoundException, MojoExecutionException,
ArtifactResolutionException, MojoFailureException ArtifactResolutionException, MojoFailureException
{ {
if ( phases.contains( task ) ) if ( phases.contains( task ) )
@ -501,7 +517,8 @@ 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 ) MavenProject project, MavenExecutionResponse response )
throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException throws ArtifactResolutionException, LifecycleExecutionException, MojoExecutionException, MojoFailureException,
ArtifactNotFoundException
{ {
List goals = processGoalChain( task, lifecycleMappings ); List goals = processGoalChain( task, lifecycleMappings );
@ -510,7 +527,8 @@ 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
{ {
// 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 );
@ -518,7 +536,8 @@ 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
{ {
for ( Iterator i = goals.iterator(); i.hasNext(); ) for ( Iterator i = goals.iterator(); i.hasNext(); )
{ {
@ -561,7 +580,7 @@ public class DefaultLifecycleExecutor
} }
private List getReports( MavenProject project, MojoExecution mojoExecution, MavenSession session ) private List getReports( MavenProject project, MojoExecution mojoExecution, MavenSession session )
throws ArtifactResolutionException, LifecycleExecutionException throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException
{ {
List reportPlugins = project.getReportPlugins(); List reportPlugins = project.getReportPlugins();
@ -658,7 +677,8 @@ public class DefaultLifecycleExecutor
private List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project, MavenSession session, private List getReports( ReportPlugin reportPlugin, ReportSet reportSet, MavenProject project, MavenSession session,
MojoExecution mojoExecution ) MojoExecution mojoExecution )
throws PluginManagerException, PluginVersionResolutionException, ArtifactResolutionException throws PluginManagerException, PluginVersionResolutionException, ArtifactResolutionException,
ArtifactNotFoundException
{ {
PluginDescriptor pluginDescriptor = pluginManager.verifyReportPlugin( reportPlugin, project, session ); PluginDescriptor pluginDescriptor = pluginManager.verifyReportPlugin( reportPlugin, project, session );
@ -694,7 +714,8 @@ 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
{ {
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
getLogger().info( "Preparing " + pluginDescriptor.getGoalPrefix() + ":" + mojoDescriptor.getGoal() ); getLogger().info( "Preparing " + pluginDescriptor.getGoalPrefix() + ":" + mojoDescriptor.getGoal() );
@ -724,7 +745,8 @@ 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
{ {
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor(); PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
@ -841,7 +863,7 @@ public class DefaultLifecycleExecutor
} }
private Map constructLifecycleMappings( MavenSession session, String selectedPhase, MavenProject project ) private Map constructLifecycleMappings( MavenSession session, String selectedPhase, MavenProject project )
throws ArtifactResolutionException, LifecycleExecutionException throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException
{ {
// first, bind those associated with the packaging // first, bind those associated with the packaging
Map lifecycleMappings = bindLifecycleForPackaging( session, selectedPhase, project ); Map lifecycleMappings = bindLifecycleForPackaging( session, selectedPhase, project );
@ -858,7 +880,7 @@ public class DefaultLifecycleExecutor
} }
private Map bindLifecycleForPackaging( MavenSession session, String selectedPhase, MavenProject project ) private Map bindLifecycleForPackaging( MavenSession session, String selectedPhase, MavenProject project )
throws ArtifactResolutionException, LifecycleExecutionException throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException
{ {
Map mappings = findMappingsForLifecycle( session, project ); Map mappings = findMappingsForLifecycle( session, project );
@ -901,7 +923,7 @@ public class DefaultLifecycleExecutor
} }
private Map findMappingsForLifecycle( MavenSession session, MavenProject project ) private Map findMappingsForLifecycle( MavenSession session, MavenProject project )
throws ArtifactResolutionException, LifecycleExecutionException throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException
{ {
String packaging = project.getPackaging(); String packaging = project.getPackaging();
LifecycleMapping m; LifecycleMapping m;
@ -940,7 +962,8 @@ public class DefaultLifecycleExecutor
private Object findExtension( MavenProject project, String role, String roleHint, Settings settings, private Object findExtension( MavenProject project, String role, String roleHint, Settings settings,
ArtifactRepository localRepository ) ArtifactRepository localRepository )
throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException,
ArtifactNotFoundException
{ {
for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); ) for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
{ {
@ -969,7 +992,8 @@ public class DefaultLifecycleExecutor
* lookup directly, or have them passed in * lookup directly, or have them passed in
*/ */
private Map findArtifactTypeHandlers( MavenProject project, Settings settings, ArtifactRepository localRepository ) private Map findArtifactTypeHandlers( MavenProject project, Settings settings, ArtifactRepository localRepository )
throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException,
ArtifactNotFoundException
{ {
Map map = new HashMap(); Map map = new HashMap();
for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); ) for ( Iterator i = project.getBuildPlugins().iterator(); i.hasNext(); )
@ -1014,7 +1038,7 @@ public class DefaultLifecycleExecutor
* @param session * @param session
*/ */
private void bindPluginToLifecycle( Plugin plugin, MavenSession session, Map phaseMap, MavenProject project ) private void bindPluginToLifecycle( Plugin plugin, MavenSession session, Map phaseMap, MavenProject project )
throws LifecycleExecutionException, ArtifactResolutionException throws LifecycleExecutionException, ArtifactResolutionException, ArtifactNotFoundException
{ {
PluginDescriptor pluginDescriptor; PluginDescriptor pluginDescriptor;
Settings settings = session.getSettings(); Settings settings = session.getSettings();
@ -1048,7 +1072,7 @@ public class DefaultLifecycleExecutor
} }
private PluginDescriptor verifyPlugin( Plugin plugin, MavenSession session, MavenProject project ) private PluginDescriptor verifyPlugin( Plugin plugin, MavenSession session, MavenProject project )
throws ArtifactResolutionException, LifecycleExecutionException throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException
{ {
PluginDescriptor pluginDescriptor; PluginDescriptor pluginDescriptor;
try try
@ -1154,7 +1178,7 @@ public class DefaultLifecycleExecutor
private MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project, private MojoDescriptor getMojoDescriptor( String task, MavenSession session, MavenProject project,
String invokedVia, boolean canUsePrefix ) String invokedVia, boolean canUsePrefix )
throws ArtifactResolutionException, LifecycleExecutionException throws ArtifactResolutionException, LifecycleExecutionException, ArtifactNotFoundException
{ {
String goal; String goal;
Plugin plugin = null; Plugin plugin = null;

View File

@ -22,6 +22,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.metadata.ArtifactMetadataSource; import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.ArtifactResolver;
@ -74,7 +75,6 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Field;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -147,7 +147,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, PluginManagerException, PluginVersionResolutionException,
ArtifactNotFoundException
{ {
// 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.
@ -163,7 +164,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, ArtifactResolutionException throws PluginVersionResolutionException, PluginManagerException, ArtifactNotFoundException,
ArtifactResolutionException
{ {
// 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'
@ -187,7 +189,7 @@ public class DefaultPluginManager
project.addPlugin( plugin ); project.addPlugin( plugin );
} }
catch ( ArtifactResolutionException e ) catch ( ArtifactNotFoundException e )
{ {
String groupId = plugin.getGroupId(); String groupId = plugin.getGroupId();
String artifactId = plugin.getArtifactId(); String artifactId = plugin.getArtifactId();
@ -255,7 +257,7 @@ public class DefaultPluginManager
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 throws ArtifactResolutionException, PluginManagerException, ArtifactNotFoundException
{ {
// TODO: share with MMS? Not sure if it belongs here // TODO: share with MMS? Not sure if it belongs here
if ( project.getProjectReferences() != null && !project.getProjectReferences().isEmpty() ) if ( project.getProjectReferences() != null && !project.getProjectReferences().isEmpty() )
@ -330,7 +332,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, PluginManagerException, MojoExecutionException, MojoFailureException,
ArtifactNotFoundException
{ {
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
@ -461,7 +464,7 @@ public class DefaultPluginManager
} }
public MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session ) public MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
throws PluginManagerException throws PluginManagerException, ArtifactNotFoundException
{ {
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor(); PluginDescriptor descriptor = mojoDescriptor.getPluginDescriptor();
@ -489,7 +492,8 @@ public class DefaultPluginManager
} }
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, PluginManagerException,
ArtifactNotFoundException
{ {
String version = reportPlugin.getVersion(); String version = reportPlugin.getVersion();
@ -527,7 +531,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 throws ComponentLookupException, PluginConfigurationException, PluginManagerException, ArtifactNotFoundException
{ {
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor(); MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
@ -593,7 +597,7 @@ public class DefaultPluginManager
private void ensurePluginContainerIsComplete( PluginDescriptor pluginDescriptor, PlexusContainer pluginContainer, private void ensurePluginContainerIsComplete( PluginDescriptor pluginDescriptor, PlexusContainer pluginContainer,
MavenProject project, MavenSession session ) MavenProject project, MavenSession session )
throws PluginConfigurationException throws PluginConfigurationException, ArtifactNotFoundException
{ {
// if the plugin's already been used once, don't re-do this step... // if the plugin's already been used once, don't re-do this step...
// otherwise, we have to finish resolving the plugin's classpath and start the container. // otherwise, we have to finish resolving the plugin's classpath and start the container.
@ -662,7 +666,7 @@ public class DefaultPluginManager
private void resolveCoreArtifacts( List unresolved, ArtifactRepository localRepository, private void resolveCoreArtifacts( List unresolved, ArtifactRepository localRepository,
List resolutionRepositories ) List resolutionRepositories )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
for ( Iterator it = unresolved.iterator(); it.hasNext(); ) for ( Iterator it = unresolved.iterator(); it.hasNext(); )
{ {
@ -1152,7 +1156,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 throws ArtifactResolutionException, ArtifactNotFoundException
{ {
ArtifactFilter filter = new ScopeArtifactFilter( scope ); ArtifactFilter filter = new ScopeArtifactFilter( scope );
@ -1172,7 +1176,8 @@ public class DefaultPluginManager
} }
catch ( InvalidVersionSpecificationException e ) catch ( InvalidVersionSpecificationException e )
{ {
throw new ArtifactResolutionException( "Error in dependency version", e ); // TODO: should that exception be derived from ArtifactResolutionException instead?
throw new ArtifactResolutionException( e.getMessage(), artifact );
} }
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(), ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
artifact, context.getLocalRepository(), artifact, context.getLocalRepository(),
@ -1187,7 +1192,7 @@ public class DefaultPluginManager
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
private void downloadDependencies( MavenProject project, MavenSession context, ArtifactResolver artifactResolver ) private void downloadDependencies( MavenProject project, MavenSession context, ArtifactResolver artifactResolver )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
ArtifactRepository localRepository = context.getLocalRepository(); ArtifactRepository localRepository = context.getLocalRepository();
List remoteArtifactRepositories = project.getRemoteArtifactRepositories(); List remoteArtifactRepositories = project.getRemoteArtifactRepositories();

View File

@ -17,6 +17,7 @@ package org.apache.maven.plugin;
*/ */
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin; import org.apache.maven.model.Plugin;
@ -39,10 +40,11 @@ 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, PluginManagerException, ArtifactResolutionException, MojoFailureException,
ArtifactNotFoundException;
MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session ) MavenReport getReport( MavenProject project, MojoExecution mojoExecution, MavenSession session )
throws PluginManagerException; throws PluginManagerException, ArtifactNotFoundException;
PluginDescriptor getPluginDescriptorForPrefix( String prefix ); PluginDescriptor getPluginDescriptorForPrefix( String prefix );
@ -51,10 +53,12 @@ public interface PluginManager
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, PluginManagerException, PluginVersionResolutionException,
ArtifactNotFoundException;
PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session ) PluginDescriptor verifyReportPlugin( ReportPlugin reportPlugin, MavenProject project, MavenSession session )
throws PluginVersionResolutionException, ArtifactResolutionException, PluginManagerException; throws PluginVersionResolutionException, ArtifactResolutionException, PluginManagerException,
ArtifactNotFoundException;
Object getPluginComponent( Plugin plugin, String role, String roleHint ) Object getPluginComponent( Plugin plugin, String role, String roleHint )
throws ComponentLookupException, PluginManagerException; throws ComponentLookupException, PluginManagerException;

View File

@ -16,7 +16,7 @@ package org.apache.maven.plugin;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
/** /**
* Exception occurring trying to resolve a plugin. * Exception occurring trying to resolve a plugin.
@ -25,11 +25,11 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException;
* @version $Id$ * @version $Id$
*/ */
public class PluginNotFoundException public class PluginNotFoundException
extends ArtifactResolutionException extends ArtifactNotFoundException
{ {
public PluginNotFoundException( ArtifactResolutionException e ) public PluginNotFoundException( ArtifactNotFoundException e )
{ {
super( "Mojo could not be found - check that the goal name is correct", e.getGroupId(), e.getArtifactId(), super( "Plugin could not be found - check that the goal name is correct", e.getGroupId(), e.getArtifactId(),
e.getVersion(), "maven-plugin", e.getRemoteRepositories(), e.getDownloadUrl(), e ); e.getVersion(), "maven-plugin", e.getRemoteRepositories(), e.getDownloadUrl(), e.getCause() );
} }
} }

View File

@ -17,6 +17,7 @@ package org.apache.maven.usability;
*/ */
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.artifact.resolver.AbstractArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
public class ArtifactResolverDiagnoser public class ArtifactResolverDiagnoser
@ -27,17 +28,18 @@ public class ArtifactResolverDiagnoser
public boolean canDiagnose( Throwable error ) public boolean canDiagnose( Throwable error )
{ {
return DiagnosisUtils.containsInCausality( error, ArtifactResolutionException.class ); return DiagnosisUtils.containsInCausality( error, AbstractArtifactResolutionException.class );
} }
public String diagnose( Throwable error ) public String diagnose( Throwable error )
{ {
ArtifactResolutionException exception = (ArtifactResolutionException) DiagnosisUtils.getFromCausality( error, ArtifactResolutionException.class ); AbstractArtifactResolutionException exception = (AbstractArtifactResolutionException) DiagnosisUtils.getFromCausality(
error, ArtifactResolutionException.class );
StringBuffer message = new StringBuffer(); StringBuffer message = new StringBuffer();
message.append( "Failed to resolve artifact." ); message.append( "Failed to resolve artifact." );
message.append( "\n\n"); message.append( "\n\n" );
message.append( exception.getMessage() ); message.append( exception.getMessage() );
if ( !wagonManager.isOnline() ) if ( !wagonManager.isOnline() )

View File

@ -10,6 +10,9 @@
<packaging>maven-plugin</packaging> <packaging>maven-plugin</packaging>
<name>Maven Eclipse Plugin</name> <name>Maven Eclipse Plugin</name>
<version>2.0-beta-2-SNAPSHOT</version> <version>2.0-beta-2-SNAPSHOT</version>
<prerequisites>
<maven>2.0-beta-4-SNAPSHOT</maven>
</prerequisites>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
@ -19,10 +22,15 @@
<groupId>plexus</groupId> <groupId>plexus</groupId>
<artifactId>plexus-utils</artifactId> <artifactId>plexus-utils</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0-beta-4-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-artifact-manager</artifactId> <artifactId>maven-artifact-manager</artifactId>
<version>2.0-beta-3</version> <version>2.0-beta-4-SNAPSHOT</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -16,16 +16,10 @@ package org.apache.maven.plugin.eclipse;
* limitations under the License. * limitations under the License.
*/ */
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory; import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.plugin.logging.Log; import org.apache.maven.plugin.logging.Log;
@ -34,8 +28,16 @@ import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
import org.codehaus.plexus.util.xml.XMLWriter; import org.codehaus.plexus.util.xml.XMLWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
/** /**
* Writes eclipse .classpath file. * Writes eclipse .classpath file.
*
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a> * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a> * @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
* @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a> * @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
@ -52,8 +54,8 @@ public class EclipseClasspathWriter
} }
/** /**
* @todo the list of needed parameters is really long, maybe this should become a Plexus component
* @param outputDirectory TODO * @param outputDirectory TODO
* @todo the list of needed parameters is really long, maybe this should become a Plexus component
*/ */
protected void write( File projectBaseDir, File basedir, MavenProject project, List referencedReactorArtifacts, protected void write( File projectBaseDir, File basedir, MavenProject project, List referencedReactorArtifacts,
EclipseSourceDir[] sourceDirs, List classpathContainers, ArtifactRepository localRepository, EclipseSourceDir[] sourceDirs, List classpathContainers, ArtifactRepository localRepository,
@ -70,7 +72,8 @@ public class EclipseClasspathWriter
} }
catch ( IOException ex ) catch ( IOException ex )
{ {
throw new EclipsePluginException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$ throw new EclipsePluginException( Messages.getString( "EclipsePlugin.erroropeningfile" ),
ex ); //$NON-NLS-1$
} }
XMLWriter writer = new PrettyPrintXMLWriter( w ); XMLWriter writer = new PrettyPrintXMLWriter( w );
@ -153,6 +156,7 @@ public class EclipseClasspathWriter
ArtifactRepository localRepository, ArtifactResolver artifactResolver, ArtifactRepository localRepository, ArtifactResolver artifactResolver,
ArtifactFactory artifactFactory, List remoteArtifactRepositories, ArtifactFactory artifactFactory, List remoteArtifactRepositories,
boolean downloadSources ) boolean downloadSources )
throws EclipsePluginException
{ {
String path; String path;
@ -183,8 +187,8 @@ public class EclipseClasspathWriter
if ( downloadSources ) if ( downloadSources )
{ {
Artifact sourceArtifact = retrieveSourceArtifact( artifact, remoteArtifactRepositories, Artifact sourceArtifact = retrieveSourceArtifact( artifact, remoteArtifactRepositories, localRepository,
localRepository, artifactResolver, artifactFactory ); artifactResolver, artifactFactory );
if ( !sourceArtifact.isResolved() ) if ( !sourceArtifact.isResolved() )
{ {
@ -194,12 +198,12 @@ public class EclipseClasspathWriter
else else
{ {
log.debug( Messages.getString( "EclipseClasspathWriter.sourcesavailable", //$NON-NLS-1$ log.debug( Messages.getString( "EclipseClasspathWriter.sourcesavailable", //$NON-NLS-1$
new Object[] { new Object[]{sourceArtifact.getArtifactId(),
sourceArtifact.getArtifactId(), sourceArtifact.getFile().getAbsolutePath()} ) );
sourceArtifact.getFile().getAbsolutePath() } ) );
sourcepath = "M2_REPO/" //$NON-NLS-1$ sourcepath = "M2_REPO/" //$NON-NLS-1$
+ EclipseUtils.toRelativeAndFixSeparator( localRepositoryFile, sourceArtifact.getFile().getAbsolutePath(), false ); + EclipseUtils.toRelativeAndFixSeparator( localRepositoryFile,
sourceArtifact.getFile().getAbsolutePath(), false );
} }
} }
@ -221,12 +225,16 @@ public class EclipseClasspathWriter
} }
private Artifact retrieveSourceArtifact( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, ArtifactResolver artifactResolver, private Artifact retrieveSourceArtifact( Artifact artifact, List remoteArtifactRepositories,
ArtifactRepository localRepository, ArtifactResolver artifactResolver,
ArtifactFactory artifactFactory ) ArtifactFactory artifactFactory )
throws EclipsePluginException
{ {
// source artifact: use the "sources" classifier added by the source plugin // source artifact: use the "sources" classifier added by the source plugin
Artifact sourceArtifact = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact Artifact sourceArtifact = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(),
.getArtifactId(), artifact.getVersion(), "java-source", "sources" ); //$NON-NLS-1$ //$NON-NLS-2$ artifact.getArtifactId(),
artifact.getVersion(), "java-source",
"sources" ); //$NON-NLS-1$ //$NON-NLS-2$
try try
{ {
@ -235,7 +243,7 @@ public class EclipseClasspathWriter
artifactResolver.resolve( sourceArtifact, remoteArtifactRepositories, localRepository ); artifactResolver.resolve( sourceArtifact, remoteArtifactRepositories, localRepository );
} }
catch ( ArtifactResolutionException e ) catch ( ArtifactNotFoundException e )
{ {
// ignore, the jar has not been found // ignore, the jar has not been found
if ( log.isDebugEnabled() ) if ( log.isDebugEnabled() )
@ -243,6 +251,10 @@ public class EclipseClasspathWriter
log.debug( "Cannot resolve source artifact", e ); log.debug( "Cannot resolve source artifact", e );
} }
} }
catch ( ArtifactResolutionException e )
{
throw new EclipsePluginException( "Error getting soruce artifact", e );
}
return sourceArtifact; return sourceArtifact;
} }

View File

@ -24,6 +24,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.ArtifactResolver; import org.apache.maven.artifact.resolver.ArtifactResolver;
@ -153,7 +154,7 @@ public class DefaultMavenProjectBuilder
public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository, public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository,
ProfileManager profileManager ) ProfileManager profileManager )
throws ProjectBuildingException, ArtifactResolutionException throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException
{ {
return buildWithDependencies( projectDescriptor, localRepository, profileManager, null ); return buildWithDependencies( projectDescriptor, localRepository, profileManager, null );
} }
@ -163,7 +164,7 @@ public class DefaultMavenProjectBuilder
*/ */
public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository, public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository,
ProfileManager profileManager, TransferListener transferListener ) ProfileManager profileManager, TransferListener transferListener )
throws ProjectBuildingException, ArtifactResolutionException throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException
{ {
MavenProject project = buildFromSourceFile( projectDescriptor, localRepository, profileManager ); MavenProject project = buildFromSourceFile( projectDescriptor, localRepository, profileManager );
@ -373,8 +374,8 @@ public class DefaultMavenProjectBuilder
if ( policy.checkOutOfDate( new Date( file.lastModified() ) ) ) if ( policy.checkOutOfDate( new Date( file.lastModified() ) ) )
{ {
getLogger().info( getLogger().info( projectArtifact.getArtifactId() +
projectArtifact.getArtifactId() + ": updating metadata due to status of '" + status + "'" ); ": updating metadata due to status of '" + status + "'" );
try try
{ {
projectArtifact.setResolved( false ); projectArtifact.setResolved( false );
@ -386,6 +387,13 @@ public class DefaultMavenProjectBuilder
getLogger().warn( "Error updating POM - using existing version" ); getLogger().warn( "Error updating POM - using existing version" );
getLogger().debug( "Cause", e ); getLogger().debug( "Cause", e );
} }
catch ( ArtifactNotFoundException e )
{
getLogger().warn( "Error updating POM - not found. Removing local copy." );
getLogger().debug( "Cause", e );
file.delete();
throw e;
}
} }
} }
@ -407,10 +415,10 @@ public class DefaultMavenProjectBuilder
} }
catch ( ArtifactResolutionException e ) catch ( ArtifactResolutionException e )
{ {
// TODO: a not found would be better vs other errors throw new ProjectBuildingException( "Error getting the POM in the repository", e );
// only not found should have the below behaviour }
// throw new ProjectBuildingException( "Unable to find the POM in the repository", e ); catch ( ArtifactNotFoundException e )
{
model = createStubModel( projectArtifact ); model = createStubModel( projectArtifact );
} }
} }
@ -422,7 +430,7 @@ public class DefaultMavenProjectBuilder
return model; return model;
} }
private Model createStubModel(Artifact projectArtifact) private Model createStubModel( Artifact projectArtifact )
{ {
getLogger().warn( "\n ***** Using defaults for missing POM " + projectArtifact.getId() + " *****\n" ); getLogger().warn( "\n ***** Using defaults for missing POM " + projectArtifact.getId() + " *****\n" );
@ -676,9 +684,8 @@ public class DefaultMavenProjectBuilder
"\'.\n\n Reason(s):\n" + validationResult.render( " " ) ); "\'.\n\n Reason(s):\n" + validationResult.render( " " ) );
} }
project.setRemoteArtifactRepositories( ProjectUtils.buildArtifactRepositories( model.getRepositories(), project.setRemoteArtifactRepositories(
artifactRepositoryFactory, ProjectUtils.buildArtifactRepositories( model.getRepositories(), artifactRepositoryFactory, container ) );
container ) );
// TODO: these aren't taking active project artifacts into consideration in the reactor // TODO: these aren't taking active project artifacts into consideration in the reactor
project.setPluginArtifacts( createPluginArtifacts( project.getBuildPlugins() ) ); project.setPluginArtifacts( createPluginArtifacts( project.getBuildPlugins() ) );

View File

@ -18,6 +18,7 @@ package org.apache.maven.project;
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.profiles.ProfileManager; import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.events.TransferListener;
@ -44,11 +45,11 @@ public interface MavenProjectBuilder
MavenProject buildWithDependencies( File project, ArtifactRepository localRepository, MavenProject buildWithDependencies( File project, ArtifactRepository localRepository,
ProfileManager globalProfileManager, TransferListener transferListener ) ProfileManager globalProfileManager, TransferListener transferListener )
throws ProjectBuildingException, ArtifactResolutionException; throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException;
MavenProject buildWithDependencies( File project, ArtifactRepository localRepository, MavenProject buildWithDependencies( File project, ArtifactRepository localRepository,
ProfileManager globalProfileManager ) ProfileManager globalProfileManager )
throws ProjectBuildingException, ArtifactResolutionException; throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException;
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// //

View File

@ -21,6 +21,8 @@ import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata; import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
@ -276,4 +278,16 @@ public class ActiveProjectArtifact
{ {
return artifact.isOptional(); return artifact.isOptional();
} }
public ArtifactVersion getSelectedVersion()
throws OverConstrainedVersionException
{
return artifact.getSelectedVersion();
}
public boolean isSelectedVersionKnown()
throws OverConstrainedVersionException
{
return artifact.isSelectedVersionKnown();
}
} }

View File

@ -1,5 +1,21 @@
package org.apache.maven.project.artifact; 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.
*/
import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.InvalidArtifactRTException; import org.apache.maven.artifact.InvalidArtifactRTException;
@ -19,19 +35,22 @@ public class AttachedArtifact
private final Artifact parent; private final Artifact parent;
public AttachedArtifact ( Artifact parent, String type, String classifier ) public AttachedArtifact( Artifact parent, String type, String classifier )
{ {
super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type, classifier, parent.getArtifactHandler(), parent.isOptional() ); super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type,
classifier, parent.getArtifactHandler(), parent.isOptional() );
this.parent = parent; this.parent = parent;
if ( type == null || type.trim().length() < 1 ) if ( type == null || type.trim().length() < 1 )
{ {
throw new InvalidArtifactRTException( getGroupId(), getArtifactId(), getVersion(), type, "Attached artifacts must specify a type." ); throw new InvalidArtifactRTException( getGroupId(), getArtifactId(), getVersion(), type,
"Attached artifacts must specify a type." );
} }
if ( classifier == null || classifier.trim().length() < 1 ) if ( classifier == null || classifier.trim().length() < 1 )
{ {
throw new InvalidArtifactRTException( getGroupId(), getArtifactId(), getVersion(), type, "Attached artifacts must specify a classifier." ); throw new InvalidArtifactRTException( getGroupId(), getArtifactId(), getVersion(), type,
"Attached artifacts must specify a classifier." );
} }
} }

View File

@ -23,6 +23,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
import org.apache.maven.artifact.metadata.ResolutionGroup; import org.apache.maven.artifact.metadata.ResolutionGroup;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
import org.apache.maven.artifact.resolver.DefaultArtifactResolver; import org.apache.maven.artifact.resolver.DefaultArtifactResolver;
@ -192,7 +193,7 @@ public class TestArtifactResolver
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
ArtifactRepository localRepository, List remoteRepositories, ArtifactRepository localRepository, List remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter ) ArtifactMetadataSource source, ArtifactFilter filter )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
return super.resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories, return super.resolveTransitively( artifacts, originatingArtifact, localRepository, remoteRepositories,
new Source( artifactFactory, repositoryFactory, container ), filter ); new Source( artifactFactory, repositoryFactory, container ), filter );
@ -201,7 +202,7 @@ public class TestArtifactResolver
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
List remoteRepositories, ArtifactRepository localRepository, List remoteRepositories, ArtifactRepository localRepository,
ArtifactMetadataSource source ) ArtifactMetadataSource source )
throws ArtifactResolutionException throws ArtifactResolutionException, ArtifactNotFoundException
{ {
return super.resolveTransitively( artifacts, originatingArtifact, remoteRepositories, localRepository, return super.resolveTransitively( artifacts, originatingArtifact, remoteRepositories, localRepository,
new Source( artifactFactory, repositoryFactory, container ) ); new Source( artifactFactory, repositoryFactory, container ) );