Resolving: MNG-1021, MNG-1049

o Added check for projectArtifact.isResolved() before attempting to read the model from it within DefaultMavenProjectBuilder, otherwise, stub out a dummy model just like if an ArtifactResolutionException occurs.

o Disabled metadata handling for AttachedArtifact...attachments should be slaves to the main artifact, deriving version info and metadata from it.

o Cleaned up entry for it2003 in maven-core-it/README.txt...that test has been removed.



git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@295069 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-10-05 18:31:37 +00:00
parent a565ef8590
commit 79cad82736
3 changed files with 98 additions and 79 deletions

View File

@ -312,11 +312,5 @@ it2001: Test that repositories are accumulated as the artifact resolution
it2002: Test the release plugin.
it2003: Test that source artifacts share the same build number as the main
project artifact. This is only defined in the 2000 series because of
the exorbitant time it takes to execute (it uses a uniquely defined
local repository, to avoid pollution from existing artifacts in
pattern matching of the results).
-------------------------------------------------------------------------------

View File

@ -324,6 +324,7 @@ public class DefaultMavenProjectBuilder
{
Artifact projectArtifact;
// if the artifact is not a POM, we need to construct a POM artifact based on the artifact parameter given.
if ( "pom".equals( artifact.getType() ) )
{
projectArtifact = artifact;
@ -342,12 +343,13 @@ public class DefaultMavenProjectBuilder
Model model;
if ( project == null )
{
// TODO: can't assume artifact is a POM
try
{
artifactResolver.resolve( projectArtifact, remoteArtifactRepositories, localRepository );
File file = projectArtifact.getFile();
if ( projectArtifact.isResolved() )
{
model = readModel( file );
String downloadUrl = null;
@ -397,7 +399,11 @@ public class DefaultMavenProjectBuilder
{
projectArtifact.setDownloadUrl( model.getUrl() );
}
}
else
{
model = createStubModel( projectArtifact );
}
}
catch ( ArtifactResolutionException e )
{
@ -405,9 +411,22 @@ public class DefaultMavenProjectBuilder
// only not found should have the below behaviour
// throw new ProjectBuildingException( "Unable to find the POM in the repository", e );
model = createStubModel( projectArtifact );
}
}
else
{
model = project.getModel();
}
return model;
}
private Model createStubModel(Artifact projectArtifact)
{
getLogger().warn( "\n ***** Using defaults for missing POM " + projectArtifact.getId() + " *****\n" );
model = new Model();
Model model = new Model();
model.setModelVersion( "4.0.0" );
model.setArtifactId( projectArtifact.getArtifactId() );
model.setGroupId( projectArtifact.getGroupId() );
@ -439,13 +458,6 @@ public class DefaultMavenProjectBuilder
IOUtil.close( writer );
}
*/
}
}
else
{
model = project.getModel();
}
return model;
}

View File

@ -4,10 +4,13 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.InvalidArtifactRTException;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.metadata.ArtifactMetadata;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.VersionRange;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class AttachedArtifact
@ -112,4 +115,14 @@ public class AttachedArtifact
return parent.isSnapshot();
}
public void addMetadata( ArtifactMetadata metadata )
{
// ignore. The parent artifact will handle metadata.
}
public Collection getMetadataList()
{
return Collections.EMPTY_LIST;
}
}