project = null;
}
catch ( ProjectBuildingException e )
{
throw new ArtifactMetadataRetrievalException( "Unable to read the metadata file for artifact '" +
artifact.getDependencyConflictId() + "': " + e.getMessage(), e, artifact );
}
if ( project != null )
{
Relocation relocation = null;
DistributionManagement distMgmt = project.getDistributionManagement();
if ( distMgmt != null )
{
relocation = distMgmt.getRelocation();
artifact.setDownloadUrl( distMgmt.getDownloadUrl() );
pomArtifact.setDownloadUrl( distMgmt.getDownloadUrl() );
}
if ( relocation != null )
{
if ( relocation.getGroupId() != null )
{
artifact.setGroupId( relocation.getGroupId() );
}
if ( relocation.getArtifactId() != null )
{
artifact.setArtifactId( relocation.getArtifactId() );
}
if ( relocation.getVersion() != null )
{
artifact.setVersionRange( VersionRange.createFromVersion( relocation.getVersion() ) );
}
if ( artifact.getDependencyFilter() != null &&
!artifact.getDependencyFilter().include( artifact ) )
{
return null;
}
String message = "\n This artifact has been relocated to " + artifact.getGroupId() + ":" +
artifact.getArtifactId() + ":" + artifact.getVersion() + ".\n";
if ( relocation.getMessage() != null )
{
message += " " + relocation.getMessage() + "\n";
}
if ( artifact.getDependencyTrail() != null && artifact.getDependencyTrail().size() == 1 )
{
getLogger().warn( "While downloading " + pomArtifact.getGroupId() + ":" +
pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion() + message + "\n" );
}
else
{
getLogger().debug( "While downloading " + pomArtifact.getGroupId() + ":" +
pomArtifact.getArtifactId() + ":" + pomArtifact.getVersion() + message + "\n" );
}
}
else
{
done = true;
}
}
else
{
done = true;
}
}
}
while ( !done );
// last ditch effort to try to get this set...
if ( artifact.getDownloadUrl() == null )
{
// TODO: this could come straight from the project, negating the need to set it in the project itself?
artifact.setDownloadUrl( pomArtifact.getDownloadUrl() );
}
ResolutionGroup result;
if ( project == null )
{
// if the project is null, we encountered an invalid model (read: m1 POM)
// we'll just return an empty resolution group.
// or used the inherited scope (should that be passed to the buildFromRepository method above?)
result = new ResolutionGroup( pomArtifact, Collections.EMPTY_SET, Collections.EMPTY_LIST );
}
else
{
Set artifacts = Collections.EMPTY_SET;
if ( !artifact.getArtifactHandler().isIncludesDependencies() )
{
// TODO: we could possibly use p.getDependencyArtifacts instead of this call, but they haven't been filtered
// or used the inherited scope (should that be passed to the buildFromRepository method above?)
try
{
artifacts = project.createArtifacts( artifactFactory, artifact.getScope(),
artifact.getDependencyFilter() );
}
catch ( InvalidDependencyVersionException e )
{
throw new ArtifactMetadataRetrievalException( "Error in metadata for artifact '" +
artifact.getDependencyConflictId() + "': " + e.getMessage(), e );
}
}
List repositories = aggregateRepositoryLists( remoteRepositories, project.getRemoteArtifactRepositories() );