Search in sources :

Example 1 with IdeaModel

use of org.gradle.plugins.ide.idea.model.IdeaModel 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 2 with IdeaModel

use of org.gradle.plugins.ide.idea.model.IdeaModel in project intellij-community by JetBrains.

the class ModuleExtendedModelBuilderImpl method enrichDataFromIdeaPlugin.

private static void enrichDataFromIdeaPlugin(Project project, Set<File> excludeDirectories, Set<String> javaDirectories, Set<String> testDirectories, Set<String> ideaGeneratedDirectories) {
    IdeaPlugin ideaPlugin = project.getPlugins().findPlugin(IdeaPlugin.class);
    if (ideaPlugin == null)
        return;
    IdeaModel ideaModel = ideaPlugin.getModel();
    if (ideaModel == null || ideaModel.getModule() == null)
        return;
    for (File excludeDir : ideaModel.getModule().getExcludeDirs()) {
        excludeDirectories.add(excludeDir);
    }
    for (File file : ideaModel.getModule().getSourceDirs()) {
        javaDirectories.add(file.getPath());
    }
    for (File file : ideaModel.getModule().getTestSourceDirs()) {
        testDirectories.add(file.getPath());
    }
    if (GradleVersion.current().compareTo(GradleVersion.version("2.2")) >= 0) {
        for (File file : ideaModel.getModule().getGeneratedSourceDirs()) {
            ideaGeneratedDirectories.add(file.getPath());
        }
    }
}
Also used : IdeaPlugin(org.gradle.plugins.ide.idea.IdeaPlugin) IdeaModel(org.gradle.plugins.ide.idea.model.IdeaModel) File(java.io.File)

Aggregations

IdeaModel (org.gradle.plugins.ide.idea.model.IdeaModel)2 File (java.io.File)1 LinkedHashMap (java.util.LinkedHashMap)1 JavaVersion (org.gradle.api.JavaVersion)1 IdeaPlugin (org.gradle.plugins.ide.idea.IdeaPlugin)1 IdeaModule (org.gradle.plugins.ide.idea.model.IdeaModule)1 IdeaProject (org.gradle.plugins.ide.idea.model.IdeaProject)1 DefaultIdeaJavaLanguageSettings (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaJavaLanguageSettings)1 DefaultIdeaLanguageLevel (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaLanguageLevel)1 DefaultIdeaModule (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule)1 DefaultIdeaProject (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject)1