Java 类org.gradle.api.artifacts.result.ResolvedArtifactResult 实例源码

项目:Reer    文件:IdeDependenciesExtractor.java   
private static void downloadAuxiliaryArtifacts(DependencyHandler dependencyHandler, Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> dependencies, List<Class<? extends Artifact>> artifactTypes) {
    if (artifactTypes.isEmpty()) {
        return;
    }

    ArtifactResolutionQuery query = dependencyHandler.createArtifactResolutionQuery();
    query.forComponents(dependencies.keySet());

    @SuppressWarnings("unchecked") Class<? extends Artifact>[] artifactTypesArray = (Class<? extends Artifact>[]) artifactTypes.toArray(new Class<?>[0]);
    query.withArtifacts(JvmLibrary.class, artifactTypesArray);
    Set<ComponentArtifactsResult> componentResults = query.execute().getResolvedComponents();
    for (ComponentArtifactsResult componentResult : componentResults) {
        for (IdeExtendedRepoFileDependency dependency : dependencies.get(componentResult.getId())) {
            for (ArtifactResult sourcesResult : componentResult.getArtifacts(SourcesArtifact.class)) {
                if (sourcesResult instanceof ResolvedArtifactResult) {
                    dependency.addSourceFile(((ResolvedArtifactResult) sourcesResult).getFile());
                }
            }

            for (ArtifactResult javadocResult : componentResult.getArtifacts(JavadocArtifact.class)) {
                if (javadocResult instanceof ResolvedArtifactResult) {
                    dependency.addJavadocFile(((ResolvedArtifactResult) javadocResult).getFile());
                }
            }
        }
    }
}
项目:Pushjet-Android    文件:IdeDependenciesExtractor.java   
private static void downloadAuxiliaryArtifacts(DependencyHandler dependencyHandler, Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> dependencies, List<Class<? extends Artifact>> artifactTypes) {
    if (artifactTypes.isEmpty()) {
        return;
    }

    ArtifactResolutionQuery query = dependencyHandler.createArtifactResolutionQuery();
    query.forComponents(dependencies.keySet());

    @SuppressWarnings("unchecked") Class<? extends Artifact>[] artifactTypesArray = (Class<? extends Artifact>[]) new Class<?>[artifactTypes.size()];
    query.withArtifacts(JvmLibrary.class, artifactTypes.toArray(artifactTypesArray));
    Set<ComponentArtifactsResult> componentResults = query.execute().getResolvedComponents();
    for (ComponentArtifactsResult componentResult : componentResults) {
        for (IdeExtendedRepoFileDependency dependency : dependencies.get(componentResult.getId())) {
            for (ArtifactResult sourcesResult : componentResult.getArtifacts(SourcesArtifact.class)) {
                if (sourcesResult instanceof ResolvedArtifactResult) {
                    dependency.setSourceFile(((ResolvedArtifactResult) sourcesResult).getFile());
                }
            }

            for (ArtifactResult javadocResult : componentResult.getArtifacts(JavadocArtifact.class)) {
                if (javadocResult instanceof ResolvedArtifactResult) {
                    dependency.setJavadocFile(((ResolvedArtifactResult) javadocResult).getFile());
                }
            }
        }
    }
}
项目:okbuck    文件:ProguardUtil.java   
@Nullable
public static String getProguardJarPath(Project project) {
    String proguardVersion = ProjectUtil.findVersionInClasspath(project, PROGUARD_GROUP, PROGUARD_MODULE);
    Configuration proguardConfiguration = project.getConfigurations().detachedConfiguration(
            new DefaultExternalModuleDependency(PROGUARD_GROUP, PROGUARD_MODULE, proguardVersion));
    DependencyCache proguardCache = new DependencyCache(project,
            DependencyUtils.createCacheDir(project, PROGUARD_DEPS_CACHE));
    proguardCache.build(proguardConfiguration);
    String proguardJarPath = null;
    try {
        Optional<ResolvedArtifactResult> artifactResult = proguardConfiguration.getIncoming().getArtifacts()
                .getArtifacts()
                .stream()
                .filter(artifact -> {
                    ComponentIdentifier identifier = artifact.getId().getComponentIdentifier();
                    return identifier instanceof ModuleComponentIdentifier
                            && ((ModuleComponentIdentifier) identifier).getGroup().equals(PROGUARD_GROUP)
                            && ((ModuleComponentIdentifier) identifier).getModule().equals(PROGUARD_MODULE);
                }).findFirst();

        if (artifactResult.isPresent()) {
            proguardJarPath = proguardCache.get(
                    new ExternalDependency(
                            PROGUARD_GROUP,
                            PROGUARD_MODULE,
                            proguardVersion,
                            artifactResult.get().getFile()), true, false);
        }
    } catch (IllegalStateException ignored) {}
    return proguardJarPath;
}
项目:okbuck    文件:ProguardUtil.java   
@Nullable
public static String getProguardJarPath(Project project) {
    String proguardVersion = ProjectUtil.findVersionInClasspath(project, PROGUARD_GROUP, PROGUARD_MODULE);
    Configuration proguardConfiguration = project.getConfigurations().detachedConfiguration(
            new DefaultExternalModuleDependency(PROGUARD_GROUP, PROGUARD_MODULE, proguardVersion));
    DependencyCache proguardCache = new DependencyCache(project,
            DependencyUtils.createCacheDir(project, PROGUARD_DEPS_CACHE));
    proguardCache.build(proguardConfiguration);
    String proguardJarPath = null;
    try {
        Optional<ResolvedArtifactResult> artifactResult = proguardConfiguration.getIncoming().getArtifacts()
                .getArtifacts()
                .stream()
                .filter(artifact -> {
                    ComponentIdentifier identifier = artifact.getId().getComponentIdentifier();
                    return identifier instanceof ModuleComponentIdentifier
                            && ((ModuleComponentIdentifier) identifier).getGroup().equals(PROGUARD_GROUP)
                            && ((ModuleComponentIdentifier) identifier).getModule().equals(PROGUARD_MODULE);
                }).findFirst();

        if (artifactResult.isPresent()) {
            proguardJarPath = proguardCache.get(
                    new ExternalDependency(
                            PROGUARD_GROUP,
                            PROGUARD_MODULE,
                            proguardVersion,
                            artifactResult.get().getFile()), true, false);
        }
    } catch (IllegalStateException ignored) {}
    return proguardJarPath;
}
项目:Reer    文件:DefaultLenientConfiguration.java   
ResolvedArtifactCollectingVisitor(Collection<? super ResolvedArtifactResult> artifacts) {
    this.artifacts = artifacts;
}
项目:Reer    文件:ShortCircuitEmptyConfigurationResolver.java   
@Override
public <T extends Collection<? super ResolvedArtifactResult>> T collectArtifacts(T dest) throws ResolveException {
    return dest;
}
项目:Reer    文件:ErrorHandlingConfigurationResolver.java   
@Override
public <T extends Collection<? super ResolvedArtifactResult>> T collectArtifacts(T dest) throws ResolveException {
    throw wrapException(e, configuration);
}
项目:Reer    文件:BuildDependenciesOnlyVisitedArtifactSet.java   
@Override
public <T extends Collection<? super ResolvedArtifactResult>> T collectArtifacts(T dest) throws ResolveException {
    throw new UnsupportedOperationException("Artifacts have not been resolved.");
}
项目:Reer    文件:DefaultConfiguration.java   
public Set<ResolvedArtifactResult> getArtifacts() {
    resolveToStateOrLater(ARTIFACTS_RESOLVED);
    return cachedResolverResults.getVisitedArtifacts().select(Specs.<Dependency>satisfyAll(), configurationAttributes).collectArtifacts(new LinkedHashSet<ResolvedArtifactResult>());
}
项目:Reer    文件:SelectedArtifactSet.java   
/**
 * Collects all artifacts into the given collection. Fails when any artifact cannot be resolved.
 *
 * @return the collection
 * @throws ResolveException On any failure.
 */
<T extends Collection<? super ResolvedArtifactResult>> T collectArtifacts(T dest) throws ResolveException;