/** * 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; }
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()); } }); }
if ( !eq( artifact1.getArtifactId(), artifact2.getArtifactId() ) ) if ( !eq( artifact1.getGroupId(), artifact2.getGroupId() ) ) if ( !eq( artifact1.getExtension(), artifact2.getExtension() ) ) if ( !eq( artifact1.getClassifier(), artifact2.getClassifier() ) ) if ( !eq( artifact1.getBaseVersion(), artifact2.getBaseVersion() ) )
/** * Creates an artifact identifier of the form {@code <groupId>:<artifactId>:<extension>[:<classifier>]}. * * @param groupId The group id, may be {@code null}. * @param artifactId The artifact id, may be {@code null}. * @param extension The file extensiion, may be {@code null}. * @param classifier The classifier, may be {@code null}. * @return The artifact identifier, never {@code null}. */ public static String toVersionlessId( String groupId, String artifactId, String extension, String classifier ) { return concat( groupId, artifactId, extension, classifier ).toString(); }
try { return new ArtifactUrlClassification(ArtifactIdUtils .toId(pluginSharedLibDependency.getArtifact()), pluginSharedLibDependency.getArtifact() .getArtifactId(), Lists.newArrayList(dependencyResolver .resolveArtifact(pluginSharedLibDependency.getArtifact(),
/** * Creates an artifact identifier of the form {@code <groupId>:<artifactId>:<extension>[:<classifier>]}. * * @param groupId The group id, may be {@code null}. * @param artifactId The artifact id, may be {@code null}. * @param extension The file extensiion, may be {@code null}. * @param classifier The classifier, may be {@code null}. * @return The artifact identifier, never {@code null}. */ public static String toVersionlessId( String groupId, String artifactId, String extension, String classifier ) { return concat( groupId, artifactId, extension, classifier ).toString(); }
ArtifactIdUtils.toVersionlessId( dependency.getGroupId(), dependency.getArtifactId(), dependency.getType(), classifier ); dependencies.put( key, dependency );
if (winner != null && !ArtifactIdUtils.equalsId(a, winner.getArtifact())) { Artifact w = winner.getArtifact(); buffer.append(" (conflicts with "); if (ArtifactIdUtils.toVersionlessId(a).equals(ArtifactIdUtils.toVersionlessId(w))) { buffer.append(w.getVersion()); } else {
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);
if ( !eq( artifact1.getArtifactId(), artifact2.getArtifactId() ) ) if ( !eq( artifact1.getGroupId(), artifact2.getGroupId() ) ) if ( !eq( artifact1.getExtension(), artifact2.getExtension() ) ) if ( !eq( artifact1.getClassifier(), artifact2.getClassifier() ) ) if ( !eq( artifact1.getVersion(), artifact2.getVersion() ) )
/** * Creates an artifact identifier of the form {@code <groupId>:<artifactId>:<extension>[:<classifier>]:<version>}. * * @param groupId The group id, may be {@code null}. * @param artifactId The artifact id, may be {@code null}. * @param extension The file extensiion, may be {@code null}. * @param classifier The classifier, may be {@code null}. * @param version The version, may be {@code null}. * @return The artifact identifier, never {@code null}. */ public static String toId( String groupId, String artifactId, String extension, String classifier, String version ) { StringBuilder buffer = concat( groupId, artifactId, extension, classifier ); buffer.append( SEP ); if ( version != null ) { buffer.append( version ); } return buffer.toString(); }
/** * 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()); }
if (winner != null && !ArtifactIdUtils.equalsId(a, winner.getArtifact())) { Artifact w = winner.getArtifact(); buffer.append(" (conflicts with "); if (ArtifactIdUtils.toVersionlessId(a) .equals(ArtifactIdUtils.toVersionlessId(w))) { buffer.append(w.getVersion()); } else {
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; }
/** * Creates an artifact identifier of the form {@code <groupId>:<artifactId>:<extension>[:<classifier>]:<version>}. * * @param groupId The group id, may be {@code null}. * @param artifactId The artifact id, may be {@code null}. * @param extension The file extensiion, may be {@code null}. * @param classifier The classifier, may be {@code null}. * @param version The version, may be {@code null}. * @return The artifact identifier, never {@code null}. */ public static String toId( String groupId, String artifactId, String extension, String classifier, String version ) { StringBuilder buffer = concat( groupId, artifactId, extension, classifier ); buffer.append( SEP ); if ( version != null ) { buffer.append( version ); } return buffer.toString(); }
.map(dependency -> toVersionlessId(dependency.getArtifact())) .collect(toList()); final String versionLessId = toVersionlessId(node.getArtifact()); final PluginUrlClassification pluginUrlClassification = pluginResourcesResolver.resolvePluginResourcesFor(