ArtifactRepository localRepo = createLocalArtifactRepository();
log( "Using local repository: " + localRepo.getBasedir(), Project.MSG_VERBOSE );
// Look up required resources from the plexus container
ArtifactResolver resolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
ArtifactFactory artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE );
MavenMetadataSource metadataSource = (MavenMetadataSource) lookup( ArtifactMetadataSource.ROLE );
Pom pom = initializePom( localRepo );
if ( pom != null )
{
dependencies = pom.getDependencies();
}
else
{
// we have to have some sort of Pom object in order to satisfy the requirements for building the
// originating Artifact below...
pom = createDummyPom( localRepo );
}
if ( dependencies.isEmpty() )
{
log( "There were no dependencies specified", Project.MSG_WARN );
}
else
{
// check scopes
for ( Dependency dependency : dependencies )
{
String scope = dependency.getScope();
if ( Artifact.SCOPE_SYSTEM.equals( scope ) )
{
if ( StringUtils.isBlank( dependency.getSystemPath() ) )
{
throw new BuildException( dependency.toString()
+ " is defined with scope='system': systemPath attribute is required." );
}
}
else if ( ( scope != null ) && !SCOPES_SET.contains( scope ) )
{
// see MANTTASKS-190
log( "Unknown scope='" + scope + "' for " + dependency + ", supported scopes are: " + SCOPES_SET,
Project.MSG_WARN );
}
}
}
log( "Resolving dependencies...", Project.MSG_VERBOSE );
ArtifactResolutionResult result;
List<ArtifactRepository> remoteArtifactRepositories = createRemoteArtifactRepositories( pom.getRepositories() );
try
{
Set<Artifact> artifacts = MavenMetadataSource.createArtifacts( artifactFactory, dependencies, null, null, null );
Artifact pomArtifact = artifactFactory.createBuildArtifact( pom.getGroupId(), pom.getArtifactId(),
pom.getVersion(), pom.getPackaging() );
List<AntResolutionListener> listeners = Collections.singletonList( new AntResolutionListener( getProject() ) );
Map<String,Artifact> managedDependencies = pom.getMavenProject().getManagedVersionMap();