org.gradle.jvm.JvmLibrary Java Examples

The following examples show how to use org.gradle.jvm.JvmLibrary. 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: 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 #2
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 #3
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 #4
Source File: JvmPluginServiceRegistry.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void configure(ServiceRegistration registration, ComponentTypeRegistry componentTypeRegistry) {
    // TODO There should be a more explicit way to execute an action against existing services
    // TODO:DAZ Dependency Management should be able to extract this from the plugin, without explicit registration
    componentTypeRegistry.maybeRegisterComponentType(JvmLibrary.class)
            .registerArtifactType(SourcesArtifact.class, ArtifactType.SOURCES);
}
 
Example #5
Source File: JavaLanguagePluginServiceRegistry.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void configure(ServiceRegistration registration, ComponentTypeRegistry componentTypeRegistry) {
    // TODO There should be a more explicit way to execute an action against existing services
    // TODO:DAZ Dependency Management should be able to extract this from the plugin, without explicit registration
    componentTypeRegistry.maybeRegisterComponentType(JvmLibrary.class)
            .registerArtifactType(JavadocArtifact.class, ArtifactType.JAVADOC);
}
 
Example #6
Source File: JvmPluginServiceRegistry.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void configure(ServiceRegistration registration, ComponentTypeRegistry componentTypeRegistry) {
    // TODO There should be a more explicit way to execute an action against existing services
    // TODO:DAZ Dependency Management should be able to extract this from the plugin, without explicit registration
    componentTypeRegistry.maybeRegisterComponentType(JvmLibrary.class)
            .registerArtifactType(SourcesArtifact.class, ArtifactType.SOURCES);
}
 
Example #7
Source File: JavaLanguagePluginServiceRegistry.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void configure(ServiceRegistration registration, ComponentTypeRegistry componentTypeRegistry) {
    // TODO There should be a more explicit way to execute an action against existing services
    // TODO:DAZ Dependency Management should be able to extract this from the plugin, without explicit registration
    componentTypeRegistry.maybeRegisterComponentType(JvmLibrary.class)
            .registerArtifactType(JavadocArtifact.class, ArtifactType.JAVADOC);
}