Search in sources :

Example 1 with DefaultIdeaModule

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

the class IdeaModelBuilder method appendModule.

private void appendModule(Map<String, DefaultIdeaModule> modules, IdeaModule ideaModule, DefaultIdeaProject ideaProject, DefaultGradleProject rootGradleProject) {
    DefaultIdeaContentRoot contentRoot = new DefaultIdeaContentRoot().setRootDirectory(ideaModule.getContentRoot()).setSourceDirectories(srcDirs(ideaModule.getSourceDirs(), ideaModule.getGeneratedSourceDirs())).setTestDirectories(srcDirs(ideaModule.getTestSourceDirs(), ideaModule.getGeneratedSourceDirs())).setExcludeDirectories(ideaModule.getExcludeDirs());
    Project project = ideaModule.getProject();
    DefaultIdeaModule defaultIdeaModule = new DefaultIdeaModule().setName(ideaModule.getName()).setParent(ideaProject).setGradleProject(rootGradleProject.findByPath(ideaModule.getProject().getPath())).setContentRoots(Collections.singletonList(contentRoot)).setJdkName(ideaModule.getJdkName()).setCompilerOutput(new DefaultIdeaCompilerOutput().setInheritOutputDirs(ideaModule.getInheritOutputDirs() != null ? ideaModule.getInheritOutputDirs() : false).setOutputDir(ideaModule.getOutputDir()).setTestOutputDir(ideaModule.getTestOutputDir()));
    JavaPluginConvention javaPluginConvention = project.getConvention().findPlugin(JavaPluginConvention.class);
    if (javaPluginConvention != null) {
        final IdeaLanguageLevel ideaModuleLanguageLevel = ideaModule.getLanguageLevel();
        JavaVersion moduleSourceLanguageLevel = convertIdeaLanguageLevelToJavaVersion(ideaModuleLanguageLevel);
        JavaVersion moduleTargetBytecodeVersion = ideaModule.getTargetBytecodeVersion();
        defaultIdeaModule.setJavaLanguageSettings(new DefaultIdeaJavaLanguageSettings().setSourceLanguageLevel(moduleSourceLanguageLevel).setTargetBytecodeVersion(moduleTargetBytecodeVersion));
    }
    modules.put(ideaModule.getName(), defaultIdeaModule);
}
Also used : DefaultIdeaContentRoot(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaContentRoot) IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) DefaultGradleProject(org.gradle.tooling.internal.gradle.DefaultGradleProject) Project(org.gradle.api.Project) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject) DefaultIdeaModule(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) DefaultIdeaJavaLanguageSettings(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaJavaLanguageSettings) DefaultIdeaLanguageLevel(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaLanguageLevel) IdeaLanguageLevel(org.gradle.plugins.ide.idea.model.IdeaLanguageLevel) JavaVersion(org.gradle.api.JavaVersion) DefaultIdeaCompilerOutput(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaCompilerOutput)

Example 2 with DefaultIdeaModule

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

the class IdeaModelBuilder method build.

private DefaultIdeaProject build(Project project, DefaultGradleProject rootGradleProject) {
    IdeaModel ideaModel = ideaPluginFor(project).getModel();
    IdeaProject projectModel = ideaModel.getProject();
    JavaVersion projectSourceLanguageLevel = convertIdeaLanguageLevelToJavaVersion(projectModel.getLanguageLevel());
    JavaVersion projectTargetBytecodeLevel = projectModel.getTargetBytecodeVersion();
    DefaultIdeaProject out = new DefaultIdeaProject().setName(projectModel.getName()).setJdkName(projectModel.getJdkName()).setLanguageLevel(new DefaultIdeaLanguageLevel(projectModel.getLanguageLevel().getLevel())).setJavaLanguageSettings(new DefaultIdeaJavaLanguageSettings().setSourceLanguageLevel(projectSourceLanguageLevel).setTargetBytecodeVersion(projectTargetBytecodeLevel).setJdk(DefaultInstalledJdk.current()));
    Map<String, DefaultIdeaModule> modules = new LinkedHashMap<String, DefaultIdeaModule>();
    for (IdeaModule module : projectModel.getModules()) {
        appendModule(modules, module, out, rootGradleProject);
    }
    for (IdeaModule module : projectModel.getModules()) {
        buildDependencies(modules, module);
    }
    final Collection<DefaultIdeaModule> ideaModules = modules.values();
    out.setChildren(new LinkedList<DefaultIdeaModule>(ideaModules));
    return out;
}
Also used : DefaultIdeaModule(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule) IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject) JavaVersion(org.gradle.api.JavaVersion) LinkedHashMap(java.util.LinkedHashMap) IdeaModule(org.gradle.plugins.ide.idea.model.IdeaModule) DefaultIdeaModule(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule) IdeaModel(org.gradle.plugins.ide.idea.model.IdeaModel) DefaultIdeaJavaLanguageSettings(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaJavaLanguageSettings) DefaultIdeaLanguageLevel(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaLanguageLevel)

Example 3 with DefaultIdeaModule

use of org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule 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

DefaultIdeaModule (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule)3 JavaVersion (org.gradle.api.JavaVersion)2 IdeaProject (org.gradle.plugins.ide.idea.model.IdeaProject)2 DefaultIdeaJavaLanguageSettings (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaJavaLanguageSettings)2 DefaultIdeaLanguageLevel (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaLanguageLevel)2 DefaultIdeaProject (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject)2 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 Project (org.gradle.api.Project)1 JavaPluginConvention (org.gradle.api.plugins.JavaPluginConvention)1 Dependency (org.gradle.plugins.ide.idea.model.Dependency)1 IdeaLanguageLevel (org.gradle.plugins.ide.idea.model.IdeaLanguageLevel)1 IdeaModel (org.gradle.plugins.ide.idea.model.IdeaModel)1 IdeaModule (org.gradle.plugins.ide.idea.model.IdeaModule)1 ModuleDependency (org.gradle.plugins.ide.idea.model.ModuleDependency)1 SingleEntryModuleLibrary (org.gradle.plugins.ide.idea.model.SingleEntryModuleLibrary)1 DefaultIdeaCompilerOutput (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaCompilerOutput)1 DefaultIdeaContentRoot (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaContentRoot)1 DefaultIdeaDependency (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaDependency)1 DefaultIdeaDependencyScope (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaDependencyScope)1