org.gradle.api.artifacts.query.ArtifactResolutionQuery Java Examples

The following examples show how to use org.gradle.api.artifacts.query.ArtifactResolutionQuery. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultArtifactResolutionQuery.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ArtifactResolutionQuery withArtifacts(Class<? extends Component> componentType, Class<? extends Artifact>... artifactTypes) {
    if (this.componentType != null) {
        throw new IllegalStateException("Cannot specify component type multiple times.");
    }
    this.componentType = componentType;
    this.artifactTypes.addAll(Arrays.asList(artifactTypes));
    return this;
}
 
Example #2
Source File: IdeDependenciesExtractor.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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());
                }
            }
        }
    }
}
 
Example #3
Source File: IdeDependenciesExtractor.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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());
                }
            }
        }
    }
}
 
Example #4
Source File: DefaultArtifactResolutionQuery.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ArtifactResolutionQuery withArtifacts(Class<? extends Component> componentType, Class<? extends Artifact>... artifactTypes) {
    if (this.componentType != null) {
        throw new IllegalStateException("Cannot specify component type multiple times.");
    }
    this.componentType = componentType;
    this.artifactTypes.addAll(Arrays.asList(artifactTypes));
    return this;
}
 
Example #5
Source File: AtlasDependencyGraph.java    From atlas with Apache License 2.0 5 votes vote down vote up
private static void handleSources(
        @NonNull Project project,
        @NonNull Set<ComponentIdentifier> artifacts,
        @NonNull Consumer<SyncIssue> failureConsumer) {
    final DependencyHandler dependencies = project.getDependencies();

    try {
        ArtifactResolutionQuery query = dependencies.createArtifactResolutionQuery();
        query.forComponents(artifacts);

        @SuppressWarnings("unchecked")
        Class<? extends Artifact>[] artifactTypesArray =
                (Class<? extends Artifact>[]) new Class<?>[] {SourcesArtifact.class};
        query.withArtifacts(JvmLibrary.class, artifactTypesArray);
        query.execute().getResolvedComponents();
    } catch (Throwable t) {
        DependencyFailureHandlerKt.processDependencyThrowable(
                t,
                s -> null,
                (data, messages) ->
                        failureConsumer.accept(
                                new SyncIssueImpl(
                                        SyncIssue.TYPE_GENERIC,
                                        SyncIssue.SEVERITY_WARNING,
                                        null,
                                        String.format(
                                                "Unable to download sources: %s",
                                                messages.get(0)),
                                        messages)));
    }
}
 
Example #6
Source File: DefaultArtifactResolutionQuery.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ArtifactResolutionQuery forComponents(ComponentIdentifier... componentIds) {
    CollectionUtils.addAll(this.componentIds, componentIds);
    return this;
}
 
Example #7
Source File: DefaultDependencyHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ArtifactResolutionQuery createArtifactResolutionQuery() {
    return resolutionQueryFactory.createArtifactResolutionQuery();
}
 
Example #8
Source File: DefaultArtifactResolutionQueryFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ArtifactResolutionQuery createArtifactResolutionQuery() {
    return new DefaultArtifactResolutionQuery(configurationContainer, repositoryHandler, ivyFactory, metadataHandler, cacheLockingManager, componentTypeRegistry);
}
 
Example #9
Source File: DefaultArtifactResolutionQuery.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ArtifactResolutionQuery forComponents(ComponentIdentifier... componentIds) {
    CollectionUtils.addAll(this.componentIds, componentIds);
    return this;
}
 
Example #10
Source File: DefaultArtifactResolutionQuery.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ArtifactResolutionQuery forComponents(Iterable<? extends ComponentIdentifier> componentIds) {
    CollectionUtils.addAll(this.componentIds, componentIds);
    return this;
}
 
Example #11
Source File: DefaultDependencyHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ArtifactResolutionQuery createArtifactResolutionQuery() {
    return resolutionQueryFactory.createArtifactResolutionQuery();
}
 
Example #12
Source File: DefaultArtifactResolutionQueryFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ArtifactResolutionQuery createArtifactResolutionQuery() {
    return new DefaultArtifactResolutionQuery(configurationContainer, repositoryHandler, ivyFactory, metadataHandler, cacheLockingManager, componentTypeRegistry);
}
 
Example #13
Source File: DefaultArtifactResolutionQuery.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ArtifactResolutionQuery forComponents(Iterable<? extends ComponentIdentifier> componentIds) {
    CollectionUtils.addAll(this.componentIds, componentIds);
    return this;
}
 
Example #14
Source File: DependencyHandler.java    From pushfish-android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Creates an artifact resolution query.
 *
 * @since 2.0
 */
@Incubating
ArtifactResolutionQuery createArtifactResolutionQuery();
 
Example #15
Source File: DependencyHandler.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Creates an artifact resolution query.
 *
 * @since 2.0
 */
@Incubating
ArtifactResolutionQuery createArtifactResolutionQuery();
 
Example #16
Source File: ArtifactResolutionQueryFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License votes vote down vote up
ArtifactResolutionQuery createArtifactResolutionQuery(); 
Example #17
Source File: ArtifactResolutionQueryFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License votes vote down vote up
ArtifactResolutionQuery createArtifactResolutionQuery();