/** * 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()); } }); }
try { return new ArtifactUrlClassification(ArtifactIdUtils .toId(pluginSharedLibDependency.getArtifact()), pluginSharedLibDependency.getArtifact() .getArtifactId(), Lists.newArrayList(dependencyResolver .resolveArtifact(pluginSharedLibDependency.getArtifact(),
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);
.filter(dependency -> { Artifact artifact = dependency.getArtifact(); String artifactId = toId(artifact); return (!serviceUrlClassifications.stream()
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; }
/** * @return true if artifacts are initialized, false if not and the analysis should not proceed */ private boolean initializeComparisonArtifacts() { if (oldArtifacts == null) { return initializeComparisonGavs(); } else { String coords = Analyzer.getProjectArtifactCoordinates(project, null); boolean projectInOlds = Stream.of(oldArtifacts).anyMatch(a -> ArtifactIdUtils.toId(a).equals(coords)); boolean projectInNews = Stream.of(newArtifacts).anyMatch(a -> ArtifactIdUtils.toId(a).equals(coords)); if ((projectInOlds || projectInNews) && !project.getArtifact().getArtifactHandler().isAddedToClasspath()) { return false; } return true; } }
/** * 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 classifierLessId = toId(node.getArtifact()); return serviceResourcesResolver .resolveServiceResourcesFor(new ArtifactUrlClassification(classifierLessId, node.getArtifact().getArtifactId(), node.getUrls())); }).collect(toList()); }
/** * 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()); } }); }
Artifact artifact = dependency.getArtifact(); return (!serviceUrlClassifications.stream() .filter(artifactUrlClassification -> artifactUrlClassification.getArtifactId().equals(toId(artifact))).findAny() .isPresent() && !pluginUrlClassifications.stream() .filter(artifactUrlClassification -> artifactUrlClassification.getArtifactId().equals(toId(artifact))).findAny() .isPresent()); })
orFilter(new PatternExclusionsDependencyFilter("*:*:*:" + MULE_PLUGIN_CLASSIFIER + ":*"), new PatternInclusionsDependencyFilter(toId(artifactToClassify)))); urls = toUrl(dependencyResolver.resolveDependencies(new Dependency(artifactToClassify, COMPILE), emptyList(), emptyList(), pluginArtifactDependencies.stream() .map(artifact -> { String artifactClassifierLessId = toId(artifact); if (!artifactsClassified.containsKey(artifactClassifierLessId)) { buildPluginUrlClassification(artifact, context, directDependenciesFilter, artifactsClassified, artifactDependencies); artifactsClassified.put(toId(artifactToClassify), artifactUrlClassification);
/** * Creates an artifact identifier of the form {@code <groupId>:<artifactId>:<extension>[:<classifier>]:<version>}. * * @param artifact The artifact to create an identifer for, may be {@code null}. * @return The artifact identifier or {@code null} if the input was {@code null}. */ public static String toId( Artifact artifact ) { String id = null; if ( artifact != null ) { id = toId( artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), artifact.getClassifier(), artifact.getVersion() ); } return id; }
/** * Creates an artifact identifier of the form * {@code <groupId>:<artifactId>:<extension>[:<classifier>]:<baseVersion>}. * * @param artifact The artifact to create an identifer for, may be {@code null}. * @return The artifact identifier or {@code null} if the input was {@code null}. */ public static String toBaseId( Artifact artifact ) { String id = null; if ( artifact != null ) { id = toId( artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), artifact.getClassifier(), artifact.getBaseVersion() ); } return id; }
/** * Creates an artifact identifier of the form * {@code <groupId>:<artifactId>:<extension>[:<classifier>]:<baseVersion>}. * * @param artifact The artifact to create an identifer for, may be {@code null}. * @return The artifact identifier or {@code null} if the input was {@code null}. */ public static String toBaseId( Artifact artifact ) { String id = null; if ( artifact != null ) { id = toId( artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), artifact.getClassifier(), artifact.getBaseVersion() ); } return id; }
/** * Creates an artifact identifier of the form {@code <groupId>:<artifactId>:<extension>[:<classifier>]:<version>}. * * @param artifact The artifact to create an identifer for, may be {@code null}. * @return The artifact identifier or {@code null} if the input was {@code null}. */ public static String toId( Artifact artifact ) { String id = null; if ( artifact != null ) { id = toId( artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), artifact.getClassifier(), artifact.getVersion() ); } return id; }