Making resolution of artifacts from the reactor work with classifiers (hopefully).

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@541942 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-05-26 21:22:10 +00:00
parent 856767d7f8
commit a55e9c24fe
1 changed files with 45 additions and 18 deletions

View File

@ -31,6 +31,7 @@ import org.apache.maven.project.MavenProject;
import org.apache.maven.project.build.ProjectBuildCache;
import java.io.File;
import java.util.Iterator;
import java.util.List;
public class CacheAwareArtifactResolver
@ -41,7 +42,8 @@ public class CacheAwareArtifactResolver
private BuildContextManager buildContextManager;
public void resolve( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
public void resolve( final Artifact artifact, final List remoteRepositories,
final ArtifactRepository localRepository )
throws ArtifactResolutionException, ArtifactNotFoundException
{
resolveFromCache( artifact );
@ -52,7 +54,8 @@ public class CacheAwareArtifactResolver
}
}
public void resolveAlways( Artifact artifact, List remoteRepositories, ArtifactRepository localRepository )
public void resolveAlways( final Artifact artifact, final List remoteRepositories,
final ArtifactRepository localRepository )
throws ArtifactResolutionException, ArtifactNotFoundException
{
resolveFromCache( artifact );
@ -63,7 +66,7 @@ public class CacheAwareArtifactResolver
}
}
private void resolveFromCache( Artifact artifact )
private void resolveFromCache( final Artifact artifact )
{
ProjectBuildCache cache = ProjectBuildCache.read( buildContextManager );
@ -77,13 +80,16 @@ public class CacheAwareArtifactResolver
artifact.setResolved( true );
}
}
// currently, artifacts with classifiers are not really supported as the main project artifact...
else if ( artifact.getClassifier() == null )
{
MavenProject project = cache.getCachedProject( artifact );
ArtifactHandler handler = artifact.getArtifactHandler();
String classifier = artifact.getClassifier();
String type = artifact.getType();
if ( project != null && handler.getPackaging().equals( project.getPackaging() ) )
if ( classifier == null )
{
ArtifactHandler handler = artifact.getArtifactHandler();
if ( ( project != null ) && handler.getPackaging().equals( project.getPackaging() ) )
{
File projectArtifactFile = project.getArtifact().getFile();
@ -94,6 +100,27 @@ public class CacheAwareArtifactResolver
}
}
}
else
{
List attachments = project.getAttachedArtifacts();
for ( Iterator it = attachments.iterator(); it.hasNext(); )
{
Artifact attachment = (Artifact) it.next();
if ( classifier.equals( attachment.getClassifier() ) && type.equals( attachment.getType() ) )
{
File attachedFile = attachment.getFile();
if ( attachedFile != null )
{
artifact.setFile( attachedFile );
artifact.setResolved( true );
}
}
}
}
}
}
}