org.eclipse.aether.graph.DependencyVisitor Java Examples

The following examples show how to use org.eclipse.aether.graph.DependencyVisitor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClassLoaderResolverTest.java    From byte-buddy with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {
    classLoaderResolver = new ClassLoaderResolver(log, repositorySystem, repositorySystemSession, Collections.<RemoteRepository>emptyList());
    when(repositorySystem.collectDependencies(eq(repositorySystemSession), any(CollectRequest.class)))
            .thenReturn(new CollectResult(new CollectRequest()).setRoot(root));
    when(child.getDependency()).thenReturn(new Dependency(new DefaultArtifact(FOO,
            BAR,
            QUX,
            BAZ,
            FOO + BAR,
            Collections.<String, String>emptyMap(),
            new File(FOO + "/" + BAR)), QUX + BAZ));
    when(root.accept(any(DependencyVisitor.class))).then(new Answer<Void>() {
        public Void answer(InvocationOnMock invocationOnMock) {
            DependencyVisitor dependencyVisitor = invocationOnMock.getArgument(0);
            dependencyVisitor.visitEnter(child);
            dependencyVisitor.visitLeave(child);
            return null;
        }
    });
}
 
Example #2
Source File: GraphSerializer.java    From migration-tooling with Apache License 2.0 4 votes vote down vote up
public static Set<MavenJarRule> generateBuildRules(DependencyNode root) {
  MutableGraph<MavenJarRule> graph = GraphBuilder.directed().allowsSelfLoops(false).build();
  DependencyVisitor visitor = new AetherGraphTraverser(graph);
  root.getChildren().forEach(c -> c.accept(visitor));
  return graph.nodes();
}
 
Example #3
Source File: NewestVersionSelectorTest.java    From wildfly-swarm with Apache License 2.0 4 votes vote down vote up
private DependencyNode createNode(String version) {
    return new DependencyNode() {
        @Override
        public List<DependencyNode> getChildren() {
            return null;
        }

        @Override
        public void setChildren(List<DependencyNode> children) {

        }

        @Override
        public Dependency getDependency() {
            return null;
        }

        @Override
        public Artifact getArtifact() {
            return null;
        }

        @Override
        public void setArtifact(Artifact artifact) {

        }

        @Override
        public List<? extends Artifact> getRelocations() {
            return null;
        }

        @Override
        public Collection<? extends Artifact> getAliases() {
            return null;
        }

        @Override
        public VersionConstraint getVersionConstraint() {
            return TestHelper.versionConstraint(version);
        }

        @Override
        public Version getVersion() {
            return TestHelper.version(version);
        }

        @Override
        public void setScope(String scope) {

        }

        @Override
        public void setOptional(Boolean optional) {

        }

        @Override
        public int getManagedBits() {
            return 0;
        }

        @Override
        public List<RemoteRepository> getRepositories() {
            return null;
        }

        @Override
        public String getRequestContext() {
            return null;
        }

        @Override
        public void setRequestContext(String context) {

        }

        @Override
        public Map<?, ?> getData() {
            return null;
        }

        @Override
        public void setData(Map<Object, Object> data) {

        }

        @Override
        public void setData(Object key, Object value) {

        }

        @Override
        public boolean accept(DependencyVisitor visitor) {
            return false;
        }
    };
}
 
Example #4
Source File: DependencyTreeBuilder.java    From archiva with Apache License 2.0 4 votes vote down vote up
void buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version,
                      DependencyVisitor dependencyVisitor )
throws Exception;
 
Example #5
Source File: Maven3DependencyTreeBuilder.java    From archiva with Apache License 2.0 4 votes vote down vote up
public void buildDependencyTree( List<String> repositoryIds, String groupId, String artifactId, String version,
                                 DependencyVisitor dependencyVisitor )
    throws DependencyTreeBuilderException
{

    Artifact projectArtifact = mavenRepositorySystem.createProjectArtifact(groupId, artifactId, version);
    ManagedRepository repository = findArtifactInRepositories( repositoryIds, projectArtifact );

    if ( repository == null )
    {
        // metadata could not be resolved
        log.info("Did not find repository with artifact {}/{}/{}", groupId, artifactId, version);
        return;
    }

    List<org.apache.archiva.repository.RemoteRepository> remoteRepositories = new ArrayList<>();
    Map<String, NetworkProxy> networkProxies = new HashMap<>();

    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!

        Map<String, List<ProxyConnector>> proxyConnectorsMap = proxyConnectorAdmin.getProxyConnectorAsMap();
        List<ProxyConnector> proxyConnectors = proxyConnectorsMap.get( repository.getId() );
        if ( proxyConnectors != null )
        {
            for ( ProxyConnector proxyConnector : proxyConnectors )
            {
                remoteRepositories.add(
                    repositoryRegistry.getRemoteRepository( proxyConnector.getTargetRepoId() ) );

                NetworkProxy networkProxyConfig = networkProxyAdmin.getNetworkProxy( proxyConnector.getProxyId() );

                if ( networkProxyConfig != null )
                {
                    // key/value: remote repo ID/proxy info
                    networkProxies.put( proxyConnector.getTargetRepoId(), networkProxyConfig );
                }
            }
        }
    }
    catch ( RepositoryAdminException e )
    {
        throw new DependencyTreeBuilderException( e.getMessage(), e );
    }

    // FIXME take care of relative path
    ResolveRequest resolveRequest = new ResolveRequest();
    resolveRequest.dependencyVisitor = dependencyVisitor;
    resolveRequest.localRepoDir = repository.getRoot().getFilePath().toAbsolutePath().toString();
    resolveRequest.groupId = groupId;
    resolveRequest.artifactId = artifactId;
    resolveRequest.version = version;
    resolveRequest.remoteRepositories = remoteRepositories;
    resolveRequest.networkProxies = networkProxies;
    resolve( resolveRequest );
}