public void buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version,
DependencyNodeVisitor nodeVisitor )
throws DependencyTreeBuilderException
{
DependencyTreeResolutionListener listener =
new DependencyTreeResolutionListener( new Slf4JPlexusLogger( getClass() ) );
Artifact projectArtifact = factory.createProjectArtifact( groupId, artifactId, version );
ManagedRepositoryConfiguration repository = findArtifactInRepositories( repositoryIds, projectArtifact );
if ( repository == null )
{
// metadata could not be resolved
return;
}
File basedir = new File( repository.getLocation() );
try
{
// MRM-1411
// TODO: this is a workaround for a lack of proxy capability in the resolvers - replace when it can all be
// handled there. It doesn't cache anything locally!
List< RemoteRepositoryConfiguration > remoteRepositories = new ArrayList<RemoteRepositoryConfiguration>();
Map<String, ProxyInfo > networkProxies = new HashMap<String, ProxyInfo>();
Map<String, List< ProxyConnectorConfiguration >> proxyConnectorsMap = archivaConfiguration.getConfiguration().getProxyConnectorAsMap();
List<ProxyConnectorConfiguration> proxyConnectors = proxyConnectorsMap.get( repository.getId() );
if( proxyConnectors != null )
{
for( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
{
remoteRepositories.add( archivaConfiguration.getConfiguration().findRemoteRepositoryById( proxyConnector.getTargetRepoId() ) );
NetworkProxyConfiguration networkProxyConfig = archivaConfiguration.getConfiguration().getNetworkProxiesAsMap().get(
proxyConnector.getProxyId() );
if( networkProxyConfig != null )
{
ProxyInfo proxy = new ProxyInfo();
proxy.setType( networkProxyConfig.getProtocol() );
proxy.setHost( networkProxyConfig.getHost() );
proxy.setPort( networkProxyConfig.getPort() );
proxy.setUserName( networkProxyConfig.getUsername() );
proxy.setPassword( networkProxyConfig.getPassword() );
// key/value: remote repo ID/proxy info
networkProxies.put( proxyConnector.getTargetRepoId(), proxy );
}
}
}
Model model = buildProject( new RepositoryModelResolver( basedir, pathTranslator, wagonFactory, remoteRepositories,
networkProxies, repository ), groupId, artifactId, version );
Map managedVersions = createManagedVersionMap( model );
Set<Artifact> dependencyArtifacts = createArtifacts( model, null );
RepositorySession repositorySession = repositorySessionFactory.createSession();
try
{
ArtifactMetadataSource metadataSource =
new MetadataArtifactMetadataSource( repositoryIds, repositorySession );
// Note that we don't permit going to external repositories. We don't need to pass in a local and remote
// since our metadata source has control over them
collector.collect( dependencyArtifacts, projectArtifact, managedVersions, null, null, metadataSource,
null, Collections.singletonList( listener ) );
//collector.collect( dependencyArtifacts, projectArtifact, null, Collections.<ArtifactRepository>emptyList(),
// metadataSource, null, Collections.singletonList( (ResolutionListener) listener ) );
/*
Set<Artifact> artifacts, Artifact originatingArtifact,
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
ArtifactMetadataSource source, ArtifactFilter filter,
List< ResolutionListener > listeners
*/
}
finally
{
repositorySession.close();
}
DependencyNode rootNode = listener.getRootNode();
// TODO: remove the need for this when the serializer can calculate last nodes from visitor calls only
DependencyNodeVisitor visitor = new BuildingDependencyNodeVisitor( nodeVisitor );
CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();