Search in sources :

Example 1 with DefaultIdeaModuleDependency

use of org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModuleDependency in project gradle by gradle.

the class IdeaModelBuilder method buildDependencies.

private void buildDependencies(Map<String, DefaultIdeaModule> modules, IdeaModule ideaModule) {
    ideaModule.setOffline(offlineDependencyResolution);
    Set<Dependency> resolved = ideaModule.resolveDependencies();
    List<DefaultIdeaDependency> dependencies = new LinkedList<DefaultIdeaDependency>();
    for (Dependency dependency : resolved) {
        if (dependency instanceof SingleEntryModuleLibrary) {
            SingleEntryModuleLibrary d = (SingleEntryModuleLibrary) dependency;
            DefaultIdeaSingleEntryLibraryDependency defaultDependency = new DefaultIdeaSingleEntryLibraryDependency().setFile(d.getLibraryFile()).setSource(d.getSourceFile()).setJavadoc(d.getJavadocFile()).setScope(new DefaultIdeaDependencyScope(d.getScope())).setExported(d.isExported());
            if (d.getModuleVersion() != null) {
                defaultDependency.setGradleModuleVersion(new DefaultGradleModuleVersion(d.getModuleVersion()));
            }
            dependencies.add(defaultDependency);
        } else if (dependency instanceof ModuleDependency) {
            ModuleDependency moduleDependency = (ModuleDependency) dependency;
            DefaultIdeaModuleDependency ideaModuleDependency = new DefaultIdeaModuleDependency(moduleDependency.getName()).setExported(moduleDependency.isExported()).setScope(new DefaultIdeaDependencyScope(moduleDependency.getScope()));
            // Find IdeaModule model for dependency within same build: may be null
            DefaultIdeaModule targetModule = modules.get(moduleDependency.getName());
            ideaModuleDependency.setDependencyModule(targetModule);
            dependencies.add(ideaModuleDependency);
        }
    }
    modules.get(ideaModule.getName()).setDependencies(dependencies);
}
Also used : DefaultIdeaSingleEntryLibraryDependency(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaSingleEntryLibraryDependency) SingleEntryModuleLibrary(org.gradle.plugins.ide.idea.model.SingleEntryModuleLibrary) DefaultIdeaModule(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule) DefaultGradleModuleVersion(org.gradle.tooling.internal.gradle.DefaultGradleModuleVersion) DefaultIdeaModuleDependency(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModuleDependency) ModuleDependency(org.gradle.plugins.ide.idea.model.ModuleDependency) DefaultIdeaDependencyScope(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaDependencyScope) DefaultIdeaModuleDependency(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModuleDependency) DefaultIdeaModuleDependency(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModuleDependency) Dependency(org.gradle.plugins.ide.idea.model.Dependency) DefaultIdeaSingleEntryLibraryDependency(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaSingleEntryLibraryDependency) ModuleDependency(org.gradle.plugins.ide.idea.model.ModuleDependency) DefaultIdeaDependency(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaDependency) DefaultIdeaDependency(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaDependency) LinkedList(java.util.LinkedList)

Aggregations

LinkedList (java.util.LinkedList)1 Dependency (org.gradle.plugins.ide.idea.model.Dependency)1 ModuleDependency (org.gradle.plugins.ide.idea.model.ModuleDependency)1 SingleEntryModuleLibrary (org.gradle.plugins.ide.idea.model.SingleEntryModuleLibrary)1 DefaultIdeaDependency (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaDependency)1 DefaultIdeaDependencyScope (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaDependencyScope)1 DefaultIdeaModule (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule)1 DefaultIdeaModuleDependency (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModuleDependency)1 DefaultIdeaSingleEntryLibraryDependency (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaSingleEntryLibraryDependency)1 DefaultGradleModuleVersion (org.gradle.tooling.internal.gradle.DefaultGradleModuleVersion)1