public boolean selectDependency( Dependency dependency ) { return !coreArtifact || !isWagonProvider( dependency.getArtifact() ); }
public boolean visitEnter( DependencyNode node ) { StringBuilder buffer = new StringBuilder( 128 ); buffer.append( indent ); org.eclipse.aether.graph.Dependency dep = node.getDependency(); if ( dep != null ) { Artifact art = dep.getArtifact(); buffer.append( art ); buffer.append( ':' ).append( dep.getScope() ); } logger.debug( buffer.toString() ); indent += " "; return true; }
public DependencySelector deriveChildSelector( DependencyCollectionContext context ) { if ( coreArtifact || !isLegacyCoreArtifact( context.getDependency().getArtifact() ) ) { return this; } else { return new WagonExcluder( true ); } }
public boolean accept( DependencyNode node, List<DependencyNode> parents ) { Dependency dependency = node.getDependency(); if ( dependency != null ) { org.eclipse.aether.artifact.Artifact a = dependency.getArtifact(); String key = ArtifactUtils.key( a.getGroupId(), a.getArtifactId(), a.getVersion() ); return !keys.contains( key ); } return false; }
private DependencyNode findPlexusUtils( DependencyNode node ) { Artifact artifact = node.getDependency().getArtifact(); if ( AID.equals( artifact.getArtifactId() ) && GID.equals( artifact.getGroupId() ) && EXT.equals( artifact.getExtension() ) && "".equals( artifact.getClassifier() ) ) { return node; } for ( DependencyNode child : node.getChildren() ) { DependencyNode result = findPlexusUtils( child ); if ( result != null ) { return result; } } return null; }
private boolean areAllDependenciesInReactor( Collection<MavenProject> projects, Collection<Dependency> dependencies ) { Set<String> projectKeys = getReactorProjectKeys( projects ); for ( Dependency dependency : dependencies ) { org.eclipse.aether.artifact.Artifact a = dependency.getArtifact(); String key = ArtifactUtils.key( a.getGroupId(), a.getArtifactId(), a.getVersion() ); if ( !projectKeys.contains( key ) ) { return false; } } return true; }
if ( dep != null ) org.eclipse.aether.artifact.Artifact art = dep.getArtifact();
private static org.apache.maven.artifact.Artifact toArtifact( Dependency dependency ) { if ( dependency == null ) { return null; } org.apache.maven.artifact.Artifact result = toArtifact( dependency.getArtifact() ); result.setScope( dependency.getScope() ); result.setOptional( dependency.isOptional() ); return result; }
/** * Finds a Maven-based plugin JAR with its "direct" dependencies. * * @see <a href="https://github.com/eclipse/aether-demo/blob/322fa556494335faaf3ad3b7dbe8f89aaaf6222d/aether-demo-snippets/src/main/java/org/eclipse/aether/examples/GetDirectDependencies.java">aether-demo's GetDirectDependencies.java</a> */ public final MavenPluginPaths findMavenPluginJarsWithDirectDependencies( final String groupId, final String artifactId, final String classifier, final String version) throws MavenArtifactNotFoundException { final ArtifactDescriptorResult result; try { result = this.describeMavenArtifact(groupId, artifactId, classifier, "jar", version); } catch (ArtifactDescriptorException ex) { throw new MavenArtifactNotFoundException(groupId, artifactId, classifier, version, this.givenLocalMavenRepositoryPath, this.absoluteLocalMavenRepositoryPath, ex); } final ArrayList<Path> dependencyPaths = new ArrayList<>(); for (final Dependency dependency : result.getDependencies()) { final Path dependencyPath = this.findMavenArtifact(dependency.getArtifact()); dependencyPaths.add(dependencyPath); } final Path artifactPath = this.findMavenArtifact(result.getArtifact()); return MavenPluginPaths.of(artifactPath, dependencyPaths); }
Collection<Exclusion> exclusions = dependency != null ? dependency.getExclusions() : null; org.eclipse.aether.graph.Dependency dep = RepositoryUtils.toDependency( artifact, exclusions ); if ( !JavaScopes.SYSTEM.equals( dep.getScope() ) && dep.getArtifact().getFile() != null ) org.eclipse.aether.artifact.Artifact art = dep.getArtifact(); art = art.setFile( null ).setVersion( art.getBaseVersion() ); dep = dep.setArtifact( art ); + child.getDependency().getArtifact() );
/** * Collects from the list of directDependencies {@link Dependency} those that are classified with classifier specified. * * @param directDependencies {@link List} of direct {@link Dependency} * @return {@link List} of {@link Artifact}s for those dependencies classified as with the give classifier, can be empty. */ private List<Artifact> filterArtifacts(List<Dependency> directDependencies, Predicate<Dependency> filter) { return directDependencies.stream() .filter(dependency -> filter.test(dependency)) .map(dependency -> dependency.getArtifact()) .collect(toList()); }
/** * Finds the direct {@link Dependency} from rootArtifact for the given groupId and artifactId. * * @param groupId of the artifact to be found * @param artifactId of the artifact to be found * @param classifier of the artifact to be found * @param directDependencies the rootArtifact direct {@link Dependency}s * @return {@link Optional} {@link Dependency} to the dependency. Could be empty it if not present in the list of direct * dependencies */ private Optional<Dependency> findDirectDependency(String groupId, String artifactId, Optional<String> classifier, List<Dependency> directDependencies) { return directDependencies.isEmpty() ? Optional.empty() : directDependencies.stream().filter( dependency -> dependency.getArtifact().getGroupId().equals(groupId) && dependency.getArtifact().getArtifactId().equals(artifactId) && ((classifier.isPresent() && dependency.getArtifact().getClassifier().equals(classifier.get()) || !classifier.isPresent()))) .findFirst(); }
/** * {@inheritDoc} */ @Override public boolean accept(final DependencyNode node, List<DependencyNode> parents) { final Dependency dependency = node.getDependency(); if (dependency == null) { return true; } return accept(dependency.getArtifact()); }
/** * Gets the direct dependencies filter to be used when collecting Container dependencies. If the rootArtifact is a * {@link ArtifactClassificationType#MODULE} it will include {@value org.eclipse.aether.util.artifact.JavaScopes#COMPILE} * dependencies too if not just {@value org.eclipse.aether.util.artifact.JavaScopes#PROVIDED}. * * @param rootArtifactType the {@link ArtifactClassificationType} for rootArtifact * @return {@link Predicate} for selecting direct dependencies for the Container. */ private Predicate<Dependency> getContainerDirectDependenciesFilter(ArtifactClassificationType rootArtifactType) { return rootArtifactType.equals(MODULE) ? directDep -> directDep.getScope().equals(PROVIDED) || directDep.getScope().equals(COMPILE) : directDep -> directDep.getScope().equals(PROVIDED) || directDep.getArtifact().getClassifier().equals(MULE_PLUGIN_CLASSIFIER); }
private List<URL> buildTestRunnerExportedLibUrlClassification(final ClassPathClassifierContext context, final List<Dependency> directDependencies, final List<RemoteRepository> rootArtifactRemoteRepositories) { List<URL> pluginSharedLibUrls = newArrayList(); List<Dependency> testRunnerExportedLibDependencies = context.getTestRunnerExportedLibCoordinates().stream() .map(sharedPluginLibCoords -> findTestRunnerExportedLibArtifact(sharedPluginLibCoords, context.getRootArtifact(), directDependencies)) .collect(toList()); logger.debug("Test runner exported lib artifacts matched with versions from direct dependencies declared: {}", testRunnerExportedLibDependencies); testRunnerExportedLibDependencies.stream() .map(testRunnerExportedLibDependency -> { try { return dependencyResolver .resolveArtifact(testRunnerExportedLibDependency.getArtifact(), rootArtifactRemoteRepositories) .getArtifact().getFile().toURI().toURL(); } catch (Exception e) { throw new IllegalStateException("Error while resolving dependency '" + testRunnerExportedLibDependency + "' as test runner exported lib", e); } }) .forEach(pluginSharedLibUrls::add); resolveSnapshotVersionsToTimestampedFromClassPath(pluginSharedLibUrls, context.getClassPathURLs()); logger.debug("Classified URLs as test runner exported libraries: '{}", pluginSharedLibUrls); return pluginSharedLibUrls; }
private List<URL> buildApplicationUrlClassification(final ClassPathClassifierContext context, final List<Dependency> directDependencies, final List<RemoteRepository> rootArtifactRemoteRepositories) { List<URL> applicationLibUrls = newArrayList(); List<Dependency> applicationLibDependencies = context.getApplicationLibCoordinates().stream() .map(applicationLibCoords -> findApplicationLibArtifact(applicationLibCoords, context.getRootArtifact(), directDependencies)) .collect(toList()); logger.debug("Application lib artifacts matched with versions from direct dependencies declared: {}", applicationLibDependencies); applicationLibDependencies.stream() .map(pluginSharedLibDependency -> { try { return dependencyResolver.resolveArtifact(pluginSharedLibDependency.getArtifact(), rootArtifactRemoteRepositories) .getArtifact().getFile().toURI().toURL(); } catch (Exception e) { throw new IllegalStateException("Error while resolving dependency '" + pluginSharedLibDependency + "' as application lib", e); } }) .forEach(applicationLibUrls::add); resolveSnapshotVersionsToTimestampedFromClassPath(applicationLibUrls, context.getClassPathURLs()); logger.debug("Classified URLs as application runtime libraries: '{}", applicationLibUrls); return applicationLibUrls; }
try { return new ArtifactUrlClassification(ArtifactIdUtils .toId(pluginSharedLibDependency.getArtifact()), pluginSharedLibDependency.getArtifact() .getArtifactId(), Lists.newArrayList(dependencyResolver .resolveArtifact(pluginSharedLibDependency.getArtifact(), rootArtifactRemoteRepositories) .getArtifact().getFile().toURI().toURL()));
/** * Finds direct dependencies declared with classifier {@value #MULE_SERVICE_CLASSIFIER}. Creates a List of * {@link ArtifactUrlClassification} for each service including their {@code compile} scope dependencies. * <p/> * Once identified and classified these Maven artifacts will be excluded from container classification. * * @param context {@link ClassPathClassifierContext} with settings for the classification process * @param directDependencies {@link List} of {@link Dependency} with direct dependencies for the rootArtifact * @param rootArtifactRemoteRepositories remote repositories defined at the rootArtifact. * @return a {@link List} of {@link ArtifactUrlClassification}s that would be the one used for the plugins class loaders. */ private List<ArtifactUrlClassification> buildServicesUrlClassification(final ClassPathClassifierContext context, final List<Dependency> directDependencies, final List<RemoteRepository> rootArtifactRemoteRepositories) { List<ArtifactClassificationNode> servicesClassified = newArrayList(); final Predicate<Dependency> muleServiceClassifiedDependencyFilter = dependency -> dependency.getArtifact().getClassifier().equals(MULE_SERVICE_CLASSIFIER); List<Artifact> serviceArtifactsDeclared = filterArtifacts(directDependencies, muleServiceClassifiedDependencyFilter); logger.debug("{} services defined to be classified", serviceArtifactsDeclared.size()); serviceArtifactsDeclared.stream() .forEach(serviceArtifact -> buildPluginUrlClassification(serviceArtifact, context, muleServiceClassifiedDependencyFilter, servicesClassified, rootArtifactRemoteRepositories)); return toServiceUrlClassification(resolveArtifactsUsingSemanticVersioning(servicesClassified)); }
DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(dependency.getArtifact().getVersion()); mavenPluginVersion.addDependency(new MavenDependency(dependency.getArtifact(), artifactVersion));
DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(dependency.getArtifact().getVersion()); mavenPluginVersion.addDependency(new MavenDependency(dependency.getArtifact(), artifactVersion));