Refine search
@Override public boolean accept(final DependencyNode node, final List<DependencyNode> parents) { final Dependency dependency = node.getDependency(); if (dependency == null) { return false; } final String groupId = dependency.getArtifact().getGroupId(); final boolean accept = groupId.startsWith(prefix); return accept; }
private void processArtifacts() { dependencyTree.accept( new ArtifactsProcessor() ); }
private void collectDependencies(DependencyNode node, List<Dependency>result) { result.add(node.getDependency()); for (DependencyNode child: node.getChildren()) { collectDependencies(child); } }
public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ) throws RepositoryException { String ctx = node.getRequestContext(); if ( "project".equals( ctx ) ) { String scope = getClasspathScope( node ); if ( scope != null ) { ctx += '/' + scope; node.setRequestContext( ctx ); } } for ( DependencyNode child : node.getChildren() ) { transformGraph( child, context ); } return node; }
private void pruneNonSelectedVersions( ConflictGroup group, Map<?, ?> conflictIds ) { for ( Position pos : group.positions ) { for ( Iterator<DependencyNode> it = pos.parent.getChildren().iterator(); it.hasNext(); ) { DependencyNode child = it.next(); Object key = conflictIds.get( child ); if ( group.key.equals( key ) ) { if ( !group.pruned && group.position.depth == pos.depth && group.version.equals( child.getVersion() ) ) { group.pruned = true; } else { it.remove(); } } } } }
/** * Creates a shallow clone of the specified node. * * @param node The node to copy, must not be {@code null}. */ public TestDependencyNode( DependencyNode node ) { setDependency( node.getDependency() ); setAliases( node.getAliases() ); setRequestContext( node.getRequestContext() ); setPremanagedScope( node.getPremanagedScope() ); setPremanagedVersion( node.getPremanagedVersion() ); setRelocations( node.getRelocations() ); setRepositories( node.getRepositories() ); setVersion( node.getVersion() ); setVersionConstraint( node.getVersionConstraint() ); }
private static String toPath( List<DependencyNode> path ) { StringBuilder buffer = new StringBuilder( 256 ); for ( Iterator<DependencyNode> it = path.iterator(); it.hasNext(); ) { DependencyNode node = it.next(); if ( node.getDependency() == null ) { continue; } Artifact artifact = node.getDependency().getArtifact(); buffer.append( artifact.getGroupId() ); buffer.append( ':' ).append( artifact.getArtifactId() ); buffer.append( ':' ).append( artifact.getExtension() ); if ( artifact.getClassifier().length() > 0 ) { buffer.append( ':' ).append( artifact.getClassifier() ); } buffer.append( ':' ).append( node.getVersionConstraint() ); if ( it.hasNext() ) { buffer.append( " -> " ); } } return buffer.toString(); }
public static DependencyTree newInstance(DependencyNode node, MavenResolver resolver, Filter<Dependency> excludeDependencyFilter) throws MalformedURLException, ArtifactResolutionException { List<DependencyNode> childrenNodes = node.getChildren(); List<DependencyTree> children = new ArrayList<DependencyTree>(); for (DependencyNode childNode : childrenNodes) { if (!DependencyFilters.matches(childNode, excludeDependencyFilter) && !node.getDependency().equals(childNode.getDependency())) { DependencyTree child = newInstance(childNode, resolver, excludeDependencyFilter); children.add(child); } } Artifact artifact = node.getDependency().getArtifact(); DependencyTree dependencyTree = new DependencyTree(DependencyId.newInstance(artifact), node.getDependency(), children); File file = artifact.getFile(); if (file == null) { file = resolver.resolveFile(artifact); } if (file != null) { String url = file.toURI().toURL().toExternalForm(); dependencyTree.setUrl(url); } return dependencyTree; }
public static DependencyTree newInstance(DependencyNode node) throws MalformedURLException { List<DependencyNode> childrenNodes = node.getChildren(); List<DependencyTree> children = new ArrayList<DependencyTree>(); for (DependencyNode childNode : childrenNodes) { DependencyTree child = newInstance(childNode); children.add(child); } Artifact artifact = node.getDependency().getArtifact(); //DependencyTree dependencyTree = new DependencyTree(DependencyId.newInstance(artifact), artifact.getVersion(), children); DependencyTree dependencyTree = new DependencyTree(DependencyId.newInstance(artifact), node.getDependency(), children); File file = artifact.getFile(); if (file != null) { String url = file.toURI().toURL().toExternalForm(); dependencyTree.setUrl(url); } return dependencyTree; }
static Dependency convertToDependency(ResourceFactory factory, DependencyNode node) { org.sonatype.aether.graph.Dependency artifactDependency = node.getDependency(); Artifact artifact = artifactDependency.getArtifact(); File file = artifact.getFile(); @SuppressWarnings("unchecked") FileResource<?> artifactResource = factory.create(FileResource.class, file); Dependency d = DependencyBuilder.create().setArtifactId(artifact.getArtifactId()) .setGroupId(artifact.getGroupId()).setVersion(artifact.getBaseVersion()) .setPackaging(artifact.getExtension()).setArtifact(artifactResource) .setOptional(artifactDependency.isOptional()) .setClassifier(artifact.getClassifier()) .setScopeType(artifactDependency.getScope()); return d; }
@Override protected List<File> resolve(String fqtn) throws Exception { StringTokenizer tokenizer = new StringTokenizer(fqtn, ":", false); String groupId = tokenizer.nextToken(); String templateId = tokenizer.nextToken(); String version = tokenizer.nextToken(); Dependency dependency = new Dependency(new DefaultArtifact(groupId + ':' + templateId + ':' + version), null); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(dependency); collectRequest.addRepository(local); collectRequest.addRepository(central); RepositorySystemSession session = newSession(repoSystem); DependencyNode node = repoSystem.collectDependencies(session, collectRequest).getRoot(); DependencyRequest dependencyRequest = new DependencyRequest(node, null); repoSystem.resolveDependencies(session, dependencyRequest); PreorderNodeListGenerator nlg = new PreorderNodeListGenerator(); node.accept(nlg); return nlg.getFiles(); }
@Override public boolean visitEnter( DependencyNode dependencyNode ) { TreeEntry entry = new TreeEntry( getModelMapper().map( dependencyNode.getDependency().getArtifact(), Artifact.class ) ); entry.getArtifact().setFileExtension( dependencyNode.getDependency().getArtifact().getExtension() ); entry.getArtifact().setScope( dependencyNode.getDependency().getScope() ); entry.setParent( currentEntry ); currentEntry = entry; if ( firstDependencyNode == null ) { firstDependencyNode = dependencyNode; treeEntries.add( currentEntry ); } else { currentEntry.getParent().getChilds().add( currentEntry ); } return true; }
public boolean visitLeave( final DependencyNode node ) { if ( node.getDependency() == null ) { return true; } parents.removeFirst(); return true; }
@Override public Collection<Advice> getAdvices( final DependencyNode root ) { final PreorderNodeListGenerator collector = new PreorderNodeListGenerator(); root.accept( collector ); final Collection<Advice> advices = new ArrayList<Advice>(); for ( final Artifact artifact : collector.getArtifacts( false ) ) { if ( "advice".equals( artifact.getExtension() ) ) { advices.addAll( extractAdvices( artifact.getFile(), Utils.fullArtifactId( root.getDependency().getArtifact() ) ) ); } } return advices; }
private DependencyNode buildDependencyNode( DependencyNode parent, org.sonatype.aether.graph.DependencyNode node, Artifact artifact, ArtifactFilter filter ) { DefaultDependencyNode current = new DefaultDependencyNode( parent, artifact, null /* node.getPremanagedVersion() */, null /* node.getPremanagedScope() */, getVersionSelectedFromRange( node.getVersionConstraint() ) ); List<DependencyNode> nodes = new ArrayList<DependencyNode>( node.getChildren().size() ); for ( org.sonatype.aether.graph.DependencyNode child : node.getChildren() ) { Artifact childArtifact = getDependencyArtifact( child.getDependency() ); if ( ( filter == null ) || filter.include( childArtifact ) ) { nodes.add( buildDependencyNode( current, child, childArtifact, filter ) ); } } current.setChildren( Collections.unmodifiableList( nodes ) ); return current; }
if (!group.isAcceptable(node.getVersion())) { return; if (!node.getVersionConstraint().getRanges().isEmpty()) { group.constraints.add(node.getVersionConstraint()); if (group.version == null || isNearer(pos, node.getVersion(), group.position, group.version)) { group.version = node.getVersion(); group.versionDependency = node; group.position = pos; Version version = entry.getKey().getVersion(); pos = entry.getValue(); for (DependencyNode child : node.getChildren()) { selectVersion(child, node, depth, depths, group, conflictIds);
@Override public boolean accept(final DependencyNode node, final List<DependencyNode> parents) { final Dependency dependency = node.getDependency(); if (dependency == null) { return false; } final String scope = dependency.getScope(); final boolean accept = !("test".equals(scope)); return accept; }
private void resolve( ConflictGroup group, Map<?, ?> conflictIds, Set<?> prerequisites ) { if ( group.scope == null ) { Set<String> inheritedScopes = getInheritedScopes( group, conflictIds, prerequisites ); group.scope = chooseEffectiveScope( inheritedScopes ); } for ( DependencyNode node : group.parents.keySet() ) { if ( node.getPremanagedScope() == null ) { String scope = node.getDependency().getScope(); if ( !group.scope.equals( scope ) && !JavaScopes.SYSTEM.equals( scope ) ) { node.setScope( group.scope ); } } } }
@Override public boolean accept(final DependencyNode node, final List<DependencyNode> parents) { return !node.getDependency().isOptional(); } }
protected void copyDependencies(DependencyNode dependency, File libDir) throws IOException, ArtifactResolutionException { List<DependencyNode> children = dependency.getChildren(); if (children != null) { for (DependencyNode child : children) { File file = getFile(child); if (file == null) { System.out.println("Cannot find file for dependent jar " + child); } else { Files.copy(file, new File(libDir,file.getName())); } copyDependencies(child, libDir); } } }