private Set<String> getCompileArtifactsForAgp2x() { Set<String> compileLibs = new HashSet<>(); Configuration configuration = project.getConfigurations().getByName("compile"); if (configuration.isCanBeResolved()) { ResolvableDependencies incoming = configuration.getIncoming(); ResolutionResult resolutionResult = incoming.getResolutionResult(); Set<ResolvedComponentResult> components = resolutionResult.getAllComponents(); for (ResolvedComponentResult result : components) { ModuleVersionIdentifier identifier = result.getModuleVersion(); if (identifier != null && !"unspecified".equals(identifier.getVersion())) { compileLibs.add( String.join(":", identifier.getGroup(), identifier.getName(), identifier.getVersion())); } } } return compileLibs; }
static Set<String> getResolvedModuleIdentifiers(Project project) { return project.getConfigurations().stream() .filter(Configuration::isCanBeResolved) .flatMap(configuration -> { try { ResolutionResult resolutionResult = configuration.getIncoming().getResolutionResult(); return resolutionResult .getAllComponents() .stream() .map(result -> result.getId()) .filter(cid -> !cid.equals(resolutionResult.getRoot().getId())) // remove the project .filter(cid -> cid instanceof ModuleComponentIdentifier) .map(mcid -> ((ModuleComponentIdentifier) mcid).getModuleIdentifier()) .map(mid -> mid.getGroup() + ":" + mid.getName()); } catch (Exception e) { throw new RuntimeException(String.format("Error during resolution of the dependency graph of " + "configuration %s", configuration), e); } }) .collect(Collectors.toSet()); } }
resolutionResult.getAllComponents()) { ArtifactVersion version = ArtifactVersion.Companion.fromGradleRefOrNull( resolvedComponentResult.getId().toString());
resolutionResult.getAllComponents()) { ArtifactVersion version = ArtifactVersion.Companion.fromGradleRefOrNull( resolvedComponentResult.getId().toString());
this.exclusionResolver.resolveExclusions(resolutionResult.getAllComponents())); excludedDependencies.removeAll(includedDependencies); return excludedDependencies;