Refine search
public static String gavOf(Dependency d) { return d.getArtifact().getGroupId() + ":" + d.getArtifact().getArtifactId() + ":" + d.getArtifact().getVersion(); }
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
public DependencyTree(DependencyId dependencyId, Dependency dependency, List<DependencyTree> children) { this(dependencyId, dependency.getArtifact().getVersion(), children); this.scope = dependency.getScope(); this.optional = dependency.isOptional(); }
/** * Sets the exclusions for the dependency. * * @param exclusions The exclusions, may be {@code null}. * @return The new dependency, never {@code null}. */ public Dependency setExclusions( Collection<Exclusion> exclusions ) { if ( hasEquivalentExclusions( exclusions ) ) { return this; } return new Dependency( artifact, scope, optional, exclusions ); }
@Override public String toString() { return String.valueOf( getArtifact() ) + " (" + getScope() + ( isOptional() ? "?" : "" ) + ")"; }
Dependency dependency = root.getDependency(); StringBuilder defBuilder = new StringBuilder(); if ( dependency == null ) Artifact artifact = dependency.getArtifact(); defBuilder.append( artifact.getGroupId() ).append( ":" ).append( artifact.getArtifactId() ).append( ":" ).append( artifact.getExtension() ).append( ":" ).append( artifact.getVersion() ); if ( dependency.getScope() != null && ( !"".equals( dependency.getScope() ) ) ) defBuilder.append( ":" ).append( dependency.getScope() ); for ( DependencyNode node : root.getChildren() )
private Artifact getDependencyArtifact( Dependency dep ) { org.sonatype.aether.artifact.Artifact artifact = dep.getArtifact(); return factory.createDependencyArtifact( artifact.getGroupId(), artifact.getArtifactId(), VersionRange.createFromVersion( artifact.getVersion() ), artifact.getProperty( "type", artifact.getExtension() ), artifact.getClassifier(), dep.getScope(), dep.isOptional() ); }
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; }
private static ArtifactRef createArtifact(final DependencyNode node) { final Artifact artifact = node.getDependency().getArtifact(); final ArtifactId.Builder builder = new ArtifactId.Builder(); final String classifier = normalize(artifact); builder.withGroupId(artifact.getGroupId()) .withName(artifact.getArtifactId()).withVersion(artifact.getVersion()) .withArchiveType(artifact.getExtension()).withClassifier(classifier); final ArtifactId id = builder.build(); final File file = artifact.getFile(); final URL url = toUrl(file); final ArtifactRef ref = new ArtifactRef(id, url); return ref; }
/** * When a DependencyResolutionResult event occurs during the build, the * event dependencies are recorded to the build-info.json file using Json * * @param event * DependencyResolutionResult a dependency resolution event * * @throws Exception */ public void onEvent(final DependencyResolutionResult event) throws Exception { final List<Dependency> dependencies = event.getDependencies(); logger.debug("onEvent(DependencyResolutionResult): " + event.getClass().getName() + "::" + event); logger.debug("Dependencies #: " + dependencies.size()); final List<BuildDependency> projectDependencies = new ArrayList<BuildDependency>(); for (final Dependency d : dependencies) { final BuildDependency currentDependency = new BuildDependency(); final Artifact artifact = d.getArtifact(); currentDependency.setGroup(artifact.getGroupId()); currentDependency.setArtifact(artifact.getArtifactId()); currentDependency.setVersion(artifact.getVersion()); final ArrayList<String> scopes = new ArrayList<String>(); scopes.add(d.getScope()); currentDependency.setScope(scopes); currentDependency.setClassifier(artifact.getClassifier()); currentDependency.setExtension(artifact.getExtension()); projectDependencies.add(currentDependency); } buildInfo.addDependencies(projectDependencies); }
@Override public boolean visitEnter(DependencyNode node) { if (scopes.contains(node.getDependency().getScope()) && (!_omits.contains(node.getDependency().getArtifact()))) { artifacts.add(node.getDependency().getArtifact()); if (LOGGER.isLoggable(Level.FINER)) { final Artifact depArtifact = node.getDependency().getArtifact(); final Artifact rootArtifact = root.getDependency().getArtifact();; LOGGER.finer(String.format("Adding transitive dependency '%s:%s:%s' for artifact '%s:%s:%s'", depArtifact.getGroupId(), depArtifact.getArtifactId(), depArtifact.getVersion(), rootArtifact.getGroupId(), rootArtifact.getArtifactId(), rootArtifact.getVersion())); } return true; } if (LOGGER.isLoggable(Level.FINER)) { final Artifact depArtifact = node.getDependency().getArtifact(); final Artifact rootArtifact = root.getDependency().getArtifact();; LOGGER.finer(String.format( "Omitting transitive dependency '%s:%s:%s' and the transitive envelope for artifact '%s:%s:%s'", depArtifact.getGroupId(), depArtifact.getArtifactId(), depArtifact.getVersion(), rootArtifact.getGroupId(), rootArtifact.getArtifactId(), rootArtifact.getVersion())); } return false; } });
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; }
protected File getFile(DependencyNode node) throws ArtifactResolutionException { if (node != null) { Dependency dependency = node.getDependency(); if (dependency != null) { Artifact artifact = dependency.getArtifact(); if (artifact != null) { File file = artifact.getFile(); if (file == null) { return mavenResolver.resolveFile(artifact); } return file; } } } return null; }
@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; }
public static String gaOf(Dependency d) { return d.getArtifact().getGroupId() + ":" + d.getArtifact().getArtifactId(); }
public boolean accept( DependencyNode node, List<DependencyNode> parents ) { Dependency dependency = node.getDependency(); if ( dependency == null ) { return true; } String id = dependency.getArtifact().getArtifactId(); if ( excludes.contains( id ) ) { return false; } id = dependency.getArtifact().getGroupId() + ':' + id; if ( excludes.contains( id ) ) { return false; } return true; }
/** * Sets the dependency node to resolve. * * @param node The dependency node to resolve, may be {@code null}. * @return This request for chaining, never {@code null}. */ public ArtifactRequest setDependencyNode( DependencyNode node ) { this.node = node; if ( node != null ) { setArtifact( node.getDependency().getArtifact() ); } return this; }
@Override public boolean selectDependency(Dependency dependency) { boolean result = false; if (!isExcluded(dependency)) { boolean optional = dependency.isOptional(); if (depth < 1) return !optional; String scope = dependency.getScope(); String classifier = dependency.getArtifact().getClassifier(); if ("test".equals(scope)) return false; result = (FORGE_ADDON.equals(classifier) && depth == 1) || (!FORGE_ADDON.equals(classifier) && !"provided".equals(scope) && !optional); } return result; }
@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; }
@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; }