Search in sources :

Example 1 with DefaultGradleProject

use of org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject in project gradle by gradle.

the class IdeaModelBuilder method createModule.

private DefaultIdeaModule createModule(IdeaModule ideaModule, DefaultIdeaProject ideaProject, DefaultGradleProject rootGradleProject) {
    DefaultIdeaContentRoot contentRoot = new DefaultIdeaContentRoot().setRootDirectory(ideaModule.getContentRoot()).setSourceDirectories(srcDirs(ideaModule.getSourceDirs(), ideaModule.getGeneratedSourceDirs())).setTestDirectories(srcDirs(ideaModule.getTestSources().getFiles(), ideaModule.getGeneratedSourceDirs())).setResourceDirectories(srcDirs(ideaModule.getResourceDirs(), ideaModule.getGeneratedSourceDirs())).setTestResourceDirectories(srcDirs(ideaModule.getTestResources().getFiles(), 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()));
    JavaPluginExtension javaPluginExtension = project.getExtensions().findByType(JavaPluginExtension.class);
    if (javaPluginExtension != null) {
        final IdeaLanguageLevel ideaModuleLanguageLevel = ideaModule.getLanguageLevel();
        JavaVersion moduleSourceLanguageLevel = convertIdeaLanguageLevelToJavaVersion(ideaModuleLanguageLevel);
        JavaVersion moduleTargetBytecodeVersion = ideaModule.getTargetBytecodeVersion();
        defaultIdeaModule.setJavaLanguageSettings(new DefaultIdeaJavaLanguageSettings().setSourceLanguageLevel(moduleSourceLanguageLevel).setTargetBytecodeVersion(moduleTargetBytecodeVersion));
    }
    buildDependencies(defaultIdeaModule, ideaModule);
    return defaultIdeaModule;
}
Also used : DefaultIdeaContentRoot(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaContentRoot) IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) Project(org.gradle.api.Project) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) DefaultIdeaModule(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule) DefaultIdeaJavaLanguageSettings(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaJavaLanguageSettings) JavaPluginExtension(org.gradle.api.plugins.JavaPluginExtension) 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 DefaultGradleProject

use of org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject in project gradle by gradle.

the class IdeaModelBuilder method buildAll.

@Override
public DefaultIdeaProject buildAll(String modelName, Project project) {
    Project root = project.getRootProject();
    applyIdeaPlugin((ProjectInternal) root, new ArrayList<>());
    DefaultGradleProject rootGradleProject = gradleProjectBuilder.buildAll(project);
    return build(root, rootGradleProject);
}
Also used : IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) Project(org.gradle.api.Project) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject)

Example 3 with DefaultGradleProject

use of org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject in project gradle by gradle.

the class GradleProjectBuilder method buildHierarchy.

private DefaultGradleProject buildHierarchy(Project project) {
    List<DefaultGradleProject> children = new ArrayList<DefaultGradleProject>();
    for (Project child : project.getChildProjects().values()) {
        children.add(buildHierarchy(child));
    }
    DefaultGradleProject gradleProject = new DefaultGradleProject().setProjectIdentifier(new DefaultProjectIdentifier(project.getRootDir(), project.getPath())).setName(project.getName()).setDescription(project.getDescription()).setBuildDirectory(project.getBuildDir()).setProjectDirectory(project.getProjectDir()).setChildren(children);
    gradleProject.getBuildScript().setSourceFile(project.getBuildFile());
    /*
            Internal system property to investigate model loading performance in IDEA/Android Studio.
            The model loading can be altered with the following values:
              - "omit_all_tasks": The model builder won't realize the task graph. The returned model will contain an empty task list.
              - "skip_task_graph_realization":  The model builder won't realize the task graph. The returned model will contain artificial tasks created from the task names.
              - "skip_task_serialization":  The model builder will realize the task graph but won't send it to the client.
              - "unmodified" (or any other value): The model builder will run unchanged.
         */
    String projectOptions = System.getProperty("org.gradle.internal.GradleProjectBuilderOptions", "unmodified");
    List<LaunchableGradleTask> tasks = tasks(gradleProject, (TaskContainerInternal) project.getTasks(), projectOptions);
    if (!"skip_task_serialization".equals(projectOptions)) {
        gradleProject.setTasks(tasks);
    }
    for (DefaultGradleProject child : children) {
        child.setParent(gradleProject);
    }
    return gradleProject;
}
Also used : LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) Project(org.gradle.api.Project) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) ArrayList(java.util.ArrayList) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Aggregations

Project (org.gradle.api.Project)3 DefaultGradleProject (org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject)3 IdeaProject (org.gradle.plugins.ide.idea.model.IdeaProject)2 DefaultIdeaProject (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject)2 ArrayList (java.util.ArrayList)1 JavaVersion (org.gradle.api.JavaVersion)1 JavaPluginExtension (org.gradle.api.plugins.JavaPluginExtension)1 IdeaLanguageLevel (org.gradle.plugins.ide.idea.model.IdeaLanguageLevel)1 DefaultIdeaCompilerOutput (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaCompilerOutput)1 DefaultIdeaContentRoot (org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaContentRoot)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 LaunchableGradleTask (org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask)1 DefaultProjectIdentifier (org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)1