Search in sources :

Example 1 with IdeExtendedRepoFileDependency

use of org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency in project gradle by gradle.

the class WtpClasspathAttributeSupport method collectFilesFromConfigs.

private static Set<File> collectFilesFromConfigs(Set<Configuration> configs, Set<Configuration> minusConfigs) {
    Set<File> resultFiles = Sets.newHashSet();
    IdeDependenciesExtractor extractor = new IdeDependenciesExtractor();
    Collection<IdeExtendedRepoFileDependency> dependencies = extractor.resolvedExternalDependencies(configs, minusConfigs);
    for (IdeExtendedRepoFileDependency dependency : dependencies) {
        resultFiles.add(dependency.getFile());
    }
    Collection<IdeLocalFileDependency> localDependencies = extractor.extractLocalFileDependencies(configs, minusConfigs);
    for (IdeLocalFileDependency dependency : localDependencies) {
        resultFiles.add(dependency.getFile());
    }
    return resultFiles;
}
Also used : IdeLocalFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeLocalFileDependency) IdeExtendedRepoFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency) File(java.io.File) IdeDependenciesExtractor(org.gradle.plugins.ide.internal.IdeDependenciesExtractor)

Example 2 with IdeExtendedRepoFileDependency

use of org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency in project gradle by gradle.

the class WtpComponentFactory method getEntriesFromLibraries.

private List<WbDependentModule> getEntriesFromLibraries(Set<Configuration> plusConfigurations, Set<Configuration> minusConfigurations, EclipseWtpComponent wtp, String deployPath) {
    IdeDependenciesExtractor extractor = new IdeDependenciesExtractor();
    //below is not perfect because we're skipping the unresolved dependencies completely
    //however, it should be better anyway. Sometime soon we will hopefully change the wtp component stuff
    Collection<IdeExtendedRepoFileDependency> externals = extractor.resolvedExternalDependencies(plusConfigurations, minusConfigurations);
    Collection<IdeLocalFileDependency> locals = extractor.extractLocalFileDependencies(plusConfigurations, minusConfigurations);
    Collection<File> libFiles = Lists.newArrayList();
    for (IdeExtendedRepoFileDependency dependency : externals) {
        libFiles.add(dependency.getFile());
    }
    for (IdeLocalFileDependency dependency : locals) {
        libFiles.add(dependency.getFile());
    }
    List<WbDependentModule> libraryEntries = Lists.newArrayList();
    for (File file : libFiles) {
        libraryEntries.add(createWbDependentModuleEntry(file, wtp.getFileReferenceFactory(), deployPath));
    }
    return libraryEntries;
}
Also used : IdeLocalFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeLocalFileDependency) IdeExtendedRepoFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency) WbDependentModule(org.gradle.plugins.ide.eclipse.model.WbDependentModule) File(java.io.File) IdeDependenciesExtractor(org.gradle.plugins.ide.internal.IdeDependenciesExtractor)

Example 3 with IdeExtendedRepoFileDependency

use of org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency in project gradle by gradle.

the class EclipseDependenciesCreator method createLibraryDependencies.

private List<AbstractClasspathEntry> createLibraryDependencies() {
    ArrayList<AbstractClasspathEntry> libraries = Lists.newArrayList();
    boolean downloadSources = classpath.isDownloadSources();
    boolean downloadJavadoc = classpath.isDownloadJavadoc();
    Collection<IdeExtendedRepoFileDependency> repoFileDependencies = dependenciesExtractor.extractRepoFileDependencies(classpath.getProject().getDependencies(), classpath.getPlusConfigurations(), classpath.getMinusConfigurations(), downloadSources, downloadJavadoc);
    for (IdeExtendedRepoFileDependency dependency : repoFileDependencies) {
        libraries.add(createLibraryEntry(dependency.getFile(), dependency.getSourceFile(), dependency.getJavadocFile(), classpath, dependency.getId()));
    }
    Collection<IdeLocalFileDependency> localFileDependencies = dependenciesExtractor.extractLocalFileDependencies(classpath.getPlusConfigurations(), classpath.getMinusConfigurations());
    for (IdeLocalFileDependency it : localFileDependencies) {
        libraries.add(createLibraryEntry(it.getFile(), null, null, classpath, null));
    }
    return libraries;
}
Also used : IdeLocalFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeLocalFileDependency) IdeExtendedRepoFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency) AbstractClasspathEntry(org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry)

Example 4 with IdeExtendedRepoFileDependency

use of org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency in project gradle by gradle.

the class IdeaDependenciesProvider method getExternalDependencies.

private Set<Dependency> getExternalDependencies(IdeaModule ideaModule, GeneratedIdeaScope scope) {
    if (ideaModule.isOffline()) {
        return Collections.emptySet();
    }
    Collection<Configuration> plusConfigurations = getPlusConfigurations(ideaModule, scope);
    Collection<Configuration> minusConfigurations = getMinusConfigurations(ideaModule, scope);
    Set<Dependency> dependencies = Sets.newLinkedHashSet();
    Collection<IdeExtendedRepoFileDependency> ideRepoFileDependencies = dependenciesExtractor.extractRepoFileDependencies(ideaModule.getProject().getDependencies(), plusConfigurations, minusConfigurations, ideaModule.isDownloadSources(), ideaModule.isDownloadJavadoc());
    for (IdeExtendedRepoFileDependency dependency : ideRepoFileDependencies) {
        dependencies.add(toLibraryDependency(dependency, ideaModule, scope));
    }
    return dependencies;
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) IdeExtendedRepoFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency) UnresolvedIdeRepoFileDependency(org.gradle.plugins.ide.internal.resolver.model.UnresolvedIdeRepoFileDependency) IdeLocalFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeLocalFileDependency) IdeProjectDependency(org.gradle.plugins.ide.internal.resolver.model.IdeProjectDependency) Dependency(org.gradle.plugins.ide.idea.model.Dependency) IdeExtendedRepoFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency)

Example 5 with IdeExtendedRepoFileDependency

use of org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency in project gradle by gradle.

the class IdeDependenciesExtractor method downloadAuxiliaryArtifacts.

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());
                }
            }
        }
    }
}
Also used : ComponentArtifactsResult(org.gradle.api.artifacts.result.ComponentArtifactsResult) IdeExtendedRepoFileDependency(org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency) ArtifactResolutionQuery(org.gradle.api.artifacts.query.ArtifactResolutionQuery) ResolvedArtifactResult(org.gradle.api.artifacts.result.ResolvedArtifactResult) JavadocArtifact(org.gradle.language.java.artifact.JavadocArtifact) SourcesArtifact(org.gradle.language.base.artifact.SourcesArtifact) Artifact(org.gradle.api.component.Artifact) ArtifactResult(org.gradle.api.artifacts.result.ArtifactResult) ResolvedArtifactResult(org.gradle.api.artifacts.result.ResolvedArtifactResult)

Aggregations

IdeExtendedRepoFileDependency (org.gradle.plugins.ide.internal.resolver.model.IdeExtendedRepoFileDependency)7 IdeLocalFileDependency (org.gradle.plugins.ide.internal.resolver.model.IdeLocalFileDependency)4 File (java.io.File)2 ArrayList (java.util.ArrayList)2 ModuleComponentIdentifier (org.gradle.api.artifacts.component.ModuleComponentIdentifier)2 ResolvedArtifactResult (org.gradle.api.artifacts.result.ResolvedArtifactResult)2 Artifact (org.gradle.api.component.Artifact)2 SourcesArtifact (org.gradle.language.base.artifact.SourcesArtifact)2 JavadocArtifact (org.gradle.language.java.artifact.JavadocArtifact)2 IdeDependenciesExtractor (org.gradle.plugins.ide.internal.IdeDependenciesExtractor)2 UnresolvedIdeRepoFileDependency (org.gradle.plugins.ide.internal.resolver.model.UnresolvedIdeRepoFileDependency)2 ArtifactView (org.gradle.api.artifacts.ArtifactView)1 Configuration (org.gradle.api.artifacts.Configuration)1 ComponentIdentifier (org.gradle.api.artifacts.component.ComponentIdentifier)1 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)1 ArtifactResolutionQuery (org.gradle.api.artifacts.query.ArtifactResolutionQuery)1 ArtifactResult (org.gradle.api.artifacts.result.ArtifactResult)1 ComponentArtifactsResult (org.gradle.api.artifacts.result.ComponentArtifactsResult)1 DefaultModuleComponentIdentifier (org.gradle.internal.component.external.model.DefaultModuleComponentIdentifier)1 AbstractClasspathEntry (org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry)1