/** * Tries to resolve the specified artifact from the artifacts of the given project. * * @param project The project to try to resolve the artifact from, must not be <code>null</code>. * @param requestedArtifact The artifact to resolve, must not be <code>null</code>. * @return The matching artifact from the project or <code>null</code> if not found. Note that this */ private Artifact findMatchingArtifact( MavenProject project, Artifact requestedArtifact ) { String requestedRepositoryConflictId = ArtifactIdUtils.toVersionlessId( requestedArtifact ); Artifact mainArtifact = RepositoryUtils.toArtifact( project.getArtifact() ); if ( requestedRepositoryConflictId.equals( ArtifactIdUtils.toVersionlessId( mainArtifact ) ) ) { return mainArtifact; } for ( Artifact attachedArtifact : RepositoryUtils.toArtifacts( project.getAttachedArtifacts() ) ) { if ( attachedArtifactComparison( requestedArtifact, attachedArtifact ) ) { return attachedArtifact; } } return null; }
session.setDependencyGraphTransformer( transformer ); DefaultArtifactTypeRegistry stereotypes = new DefaultArtifactTypeRegistry(); stereotypes.add( new DefaultArtifactType( "pom" ) ); stereotypes.add( new DefaultArtifactType( "maven-plugin", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "jar", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "ejb", "jar", "", "java" ) ); stereotypes.add( new DefaultArtifactType( "ejb-client", "jar", "client", "java" ) ); stereotypes.add( new DefaultArtifactType( "test-jar", "jar", "tests", "java" ) ); stereotypes.add( new DefaultArtifactType( "javadoc", "jar", "javadoc", "java" ) ); stereotypes.add( new DefaultArtifactType( "java-source", "jar", "sources", "java", false, false ) ); stereotypes.add( new DefaultArtifactType( "war", "war", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "ear", "ear", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "rar", "rar", "", "java", false, true ) ); stereotypes.add( new DefaultArtifactType( "par", "par", "", "java", false, true ) ); session.setArtifactTypeRegistry( stereotypes );
org.eclipse.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" ); pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() ); request.addArtifact( pomArtifact );
if ( winner != null && !ArtifactIdUtils.equalsId( a, winner.getArtifact() ) ) if ( ArtifactIdUtils.toVersionlessId( a ).equals( ArtifactIdUtils.toVersionlessId( w ) ) )
.filter(dependency -> { Artifact artifact = dependency.getArtifact(); String artifactId = toId(artifact); return (!serviceUrlClassifications.stream() .equals(toVersionlessId(artifact))) && !pluginUrlClassifications.stream() .equals(toVersionlessId(artifact))) && !applicationSharedLibUrls.stream() .anyMatch(applicationSharedLibUrl -> applicationSharedLibUrl.getArtifactId().equals(artifactId)));
/** * Logs the paths for each dependency not found * * @param node root {@link DependencyNode}, can be a "null" root (imaginary root) * @param e {@link DependencyResolutionException} the error to collect paths. */ private void logUnresolvedArtifacts(DependencyNode node, DependencyResolutionException e) { List<ArtifactResult> artifactResults = e.getResult().getArtifactResults().stream() .filter(artifactResult -> !artifactResult.getExceptions().isEmpty()).collect(toList()); final List<String> patternInclusion = artifactResults.stream().map(artifactResult -> toId(artifactResult.getRequest().getArtifact())).collect(toList()); PathRecordingDependencyVisitor visitor = new PathRecordingDependencyVisitor(new PatternInclusionsDependencyFilter(patternInclusion), node.getArtifact() != null); node.accept(visitor); visitor.getPaths().stream().forEach(path -> { List<DependencyNode> unresolvedArtifactPath = path.stream().filter(dependencyNode -> dependencyNode.getArtifact() != null).collect(toList()); if (!unresolvedArtifactPath.isEmpty()) { logger.warn("Dependency path to not resolved artifacts -> {}", unresolvedArtifactPath.toString()); } }); }
/** * Adds the specified artifact type to the registry. * * @param type The artifact type to add, must not be {@code null}. * @return This registry for chaining, never {@code null}. */ public OverlayArtifactTypeRegistry add( ArtifactType type ) { super.add( type ); return this; }
public Artifact setVersion( String version ) { Artifact artifact = delegate.setVersion( version ); if ( artifact != delegate ) { return newInstance( artifact ); } return this; }
org.eclipse.aether.artifact.Artifact pomArtifact = new SubArtifact( mainArtifact, "", "pom" ); pomArtifact = pomArtifact.setFile( ( (ProjectArtifactMetadata) metadata ).getFile() ); request.addArtifact( pomArtifact );
/** * Transforms the {@link ArtifactClassificationNode} to {@link ArtifactsUrlClassification}. * * @param classificationNodes the fat object classified that needs to be transformed * @return {@link ArtifactsUrlClassification} */ private List<ArtifactUrlClassification> toServiceUrlClassification(Collection<ArtifactClassificationNode> classificationNodes) { return classificationNodes.stream().map(node -> { final String versionLessId = toVersionlessId(node.getArtifact()); return serviceResourcesResolver .resolveServiceResourcesFor(new ArtifactUrlClassification(versionLessId, node.getArtifact().getArtifactId(), node.getUrls())); }).collect(toList()); }
try { return new ArtifactUrlClassification(ArtifactIdUtils .toId(pluginSharedLibDependency.getArtifact()), pluginSharedLibDependency.getArtifact() .getArtifactId(), Lists.newArrayList(dependencyResolver .resolveArtifact(pluginSharedLibDependency.getArtifact(),
/** * Adds the specified artifact type to the registry. * * @param type The artifact type to add, must not be {@code null}. * @return This registry for chaining, never {@code null}. */ public DefaultArtifactTypeRegistry add( ArtifactType type ) { super.add( type ); return this; }
public Artifact setProperties( Map<String, String> properties ) { Artifact artifact = delegate.setProperties( properties ); if ( artifact != delegate ) { return newInstance( artifact ); } return this; }
ArtifactIdUtils.toVersionlessId( dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), classifier ); dependencies.put( key, dependency );
private List<ArtifactClassificationNode> resolveArtifactsUsingSemanticVersioning(List<ArtifactClassificationNode> artifactClassificationNodes) { List<ArtifactClassificationNode> resolved = newArrayList(); artifactClassificationNodes.forEach(artifactClassificationNode -> { if (findArtifactClassified(resolved, artifactClassificationNode.getArtifact()).isPresent()) { return; } Reference<ArtifactClassificationNode> highestArtifact = new Reference<>(artifactClassificationNode); artifactClassificationNodes.stream().forEach(candidate -> { if (candidate.getArtifact().getGroupId().equals(highestArtifact.get().getArtifact().getGroupId()) && candidate.getArtifact().getArtifactId().equals(highestArtifact.get().getArtifact().getArtifactId())) { if (!areCompatibleVersions(highestArtifact.get().getArtifact().getVersion(), candidate.getArtifact().getVersion())) { throw new IllegalStateException( format("Incompatible version of artifacts found: %s and %s", toId(highestArtifact.get().getArtifact()), toId(candidate.getArtifact()))); } logger.debug("Checking for highest version of artifact, already discovered: '{}' versus: '{}'", toId(highestArtifact.get().getArtifact()), toId(candidate.getArtifact())); if (isHighestVersion(candidate.getArtifact().getVersion(), highestArtifact.get().getArtifact().getVersion())) { logger.warn("Replacing artifact: '{}' for highest version: '{}'", toId(highestArtifact.get().getArtifact()), toId(candidate.getArtifact())); highestArtifact.set(candidate); } } }); resolved.add(highestArtifact.get()); }); return resolved; }
/** * Adds the specified artifact type to the registry. * * @param type The artifact type to add, must not be {@code null}. * @return This registry for chaining, never {@code null}. */ public OverlayArtifactTypeRegistry add( ArtifactType type ) { super.add( type ); return this; }
.map(dependency -> toVersionlessId(dependency.getArtifact())) .collect(toList()); final String versionLessId = toVersionlessId(node.getArtifact()); final PluginUrlClassification pluginUrlClassification = pluginResourcesResolver.resolvePluginResourcesFor(
orFilter(new PatternExclusionsDependencyFilter("*:*:*:" + MULE_PLUGIN_CLASSIFIER + ":*"), new PatternInclusionsDependencyFilter(toId(artifactToClassify)))); urls = toUrl(dependencyResolver.resolveDependencies(new Dependency(artifactToClassify, COMPILE), emptyList(), emptyList(), return findArtifactClassified(artifactsClassified, artifact) .orElseThrow(() -> new IllegalStateException(format("Should %s be already added to the list of artifacts classified", toId(artifact)))); }) .forEach(artifactDependencies::add); artifactDependencies); logger.debug("Artifact discovered: {}", toId(artifactUrlClassification.getArtifact())); artifactsClassified.add(artifactUrlClassification);
/** * Adds the specified artifact type to the registry. * * @param type The artifact type to add, must not be {@code null}. * @return This registry for chaining, never {@code null}. */ public DefaultArtifactTypeRegistry add( ArtifactType type ) { super.add( type ); return this; }
.flatMap(l -> l.stream()) .collect(Collectors.toCollection(() -> new TreeSet<>((d1, d2) -> { if (toVersionlessId(d1.getArtifact()).equals(toVersionlessId(d2.getArtifact()))) { try { return versionScheme.parseVersion(d1.getArtifact().getVersion())