private Set<String> getMavenArtifacts(Set<ArtifactDependencyGraph.HashableResolvedArtifactResult> allArtifacts) { Set<String> deps = new HashSet<>(); for (ArtifactDependencyGraph.HashableResolvedArtifactResult result : allArtifacts) { ComponentIdentifier id = result.getId().getComponentIdentifier(); if (id instanceof ModuleComponentIdentifier) { ModuleComponentIdentifier module = (ModuleComponentIdentifier) id; deps.add(String.join(":", module.getGroup(), module.getModule(), module.getVersion())); } } return deps; } }
@Nullable public static String findVersionInClasspath(Project project, String group, String module) { return project .getBuildscript() .getConfigurations() .getByName("classpath") .getIncoming() .getArtifacts() .getArtifacts() .stream() .flatMap( artifactResult -> artifactResult.getId().getComponentIdentifier() instanceof ModuleComponentIdentifier ? Stream.of( (ModuleComponentIdentifier) artifactResult.getId().getComponentIdentifier()) : Stream.empty()) .filter( identifier -> (group.equals(identifier.getGroup()) && module.equals(identifier.getModule()))) .findFirst() .map(ModuleComponentIdentifier::getVersion) .orElse(null); }
return DependencyFactory.from( moduleIdentifier.getGroup(), moduleIdentifier.getModule(), moduleIdentifier.getVersion(), artifact.getFile(),
DependencyFactory.from( moduleIdentifier.getGroup(), moduleIdentifier.getModule(), moduleIdentifier.getVersion(), artifact.getFile(),
private ArtifactVersionId getCandidateArtifactVersionId(ModuleComponentIdentifier candidate) { return new ArtifactVersionId(candidate.getGroup(), candidate.getModule(), candidate.getVersion()); }