Search in sources :

Example 1 with DefaultProjectIdentifier

use of org.gradle.tooling.internal.gradle.DefaultProjectIdentifier in project gradle by gradle.

the class GradleBuildBuilder method convert.

private BasicGradleProject convert(Project project, Map<Project, BasicGradleProject> convertedProjects) {
    DefaultProjectIdentifier id = new DefaultProjectIdentifier(project.getRootDir(), project.getPath());
    BasicGradleProject converted = new BasicGradleProject().setName(project.getName()).setProjectIdentifier(id);
    converted.setProjectDirectory(project.getProjectDir());
    if (project.getParent() != null) {
        converted.setParent(convertedProjects.get(project.getParent()));
    }
    convertedProjects.put(project, converted);
    for (Project child : project.getChildProjects().values()) {
        converted.addChild(convert(child, convertedProjects));
    }
    return converted;
}
Also used : Project(org.gradle.api.Project) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Example 2 with DefaultProjectIdentifier

use of org.gradle.tooling.internal.gradle.DefaultProjectIdentifier in project gradle by gradle.

the class GradleBuildConverter method toPartialGradleProject.

private PartialBasicGradleProject toPartialGradleProject(GradleProject childProject) {
    PartialBasicGradleProject basicGradleProject = new PartialBasicGradleProject();
    basicGradleProject.setName(childProject.getName());
    ProjectIdentifier id = childProject.getProjectIdentifier();
    basicGradleProject.setProjectIdentifier(new DefaultProjectIdentifier(id.getBuildIdentifier().getRootDir(), id.getProjectPath()));
    return basicGradleProject;
}
Also used : ProjectIdentifier(org.gradle.tooling.model.ProjectIdentifier) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier) PartialBasicGradleProject(org.gradle.tooling.internal.gradle.PartialBasicGradleProject) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Example 3 with DefaultProjectIdentifier

use of org.gradle.tooling.internal.gradle.DefaultProjectIdentifier in project gradle by gradle.

the class CppModelBuilder method buildAll.

@Override
public Object buildAll(String modelName, Project project) {
    DefaultProjectIdentifier projectIdentifier = new DefaultProjectIdentifier(project.getRootDir(), project.getPath());
    CompilerOutputFileNamingSchemeFactory namingSchemeFactory = new CompilerOutputFileNamingSchemeFactory(((ProjectInternal) project).getFileResolver());
    DefaultCppComponentModel mainComponent = null;
    CppApplication application = project.getComponents().withType(CppApplication.class).findByName("main");
    if (application != null) {
        mainComponent = new DefaultCppApplicationModel(application.getName(), application.getBaseName().get(), binariesFor(application, application.getPrivateHeaderDirs(), projectIdentifier, namingSchemeFactory));
    } else {
        DefaultCppLibrary library = (DefaultCppLibrary) project.getComponents().withType(CppLibrary.class).findByName("main");
        if (library != null) {
            mainComponent = new DefaultCppLibraryModel(library.getName(), library.getBaseName().get(), binariesFor(library, library.getAllHeaderDirs(), projectIdentifier, namingSchemeFactory));
        }
    }
    DefaultCppComponentModel testComponent = null;
    CppTestSuite testSuite = project.getComponents().withType(CppTestSuite.class).findByName("test");
    if (testSuite != null) {
        testComponent = new DefaultCppTestSuiteModel(testSuite.getName(), testSuite.getBaseName().get(), binariesFor(testSuite, testSuite.getPrivateHeaderDirs(), projectIdentifier, namingSchemeFactory));
    }
    return new DefaultCppProjectModel(projectIdentifier, mainComponent, testComponent);
}
Also used : CompilerOutputFileNamingSchemeFactory(org.gradle.nativeplatform.internal.CompilerOutputFileNamingSchemeFactory) CppTestSuite(org.gradle.nativeplatform.test.cpp.CppTestSuite) CppApplication(org.gradle.language.cpp.CppApplication) DefaultCppLibrary(org.gradle.language.cpp.internal.DefaultCppLibrary) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Example 4 with DefaultProjectIdentifier

use of org.gradle.tooling.internal.gradle.DefaultProjectIdentifier in project gradle by gradle.

the class GradleBuildBuilder method convert.

private BasicGradleProject convert(BuildState owner, ProjectState project, Map<ProjectState, BasicGradleProject> convertedProjects) {
    DefaultProjectIdentifier id = new DefaultProjectIdentifier(owner.getBuildRootDir(), project.getProjectPath().getPath());
    BasicGradleProject converted = new BasicGradleProject().setName(project.getName()).setProjectIdentifier(id);
    converted.setProjectDirectory(project.getProjectDir());
    if (project.getBuildParent() != null) {
        converted.setParent(convertedProjects.get(project.getBuildParent()));
    }
    convertedProjects.put(project, converted);
    for (ProjectState child : project.getChildProjects()) {
        converted.addChild(convert(owner, child, convertedProjects));
    }
    return converted;
}
Also used : BasicGradleProject(org.gradle.plugins.ide.internal.tooling.model.BasicGradleProject) ProjectState(org.gradle.api.internal.project.ProjectState) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Example 5 with DefaultProjectIdentifier

use of org.gradle.tooling.internal.gradle.DefaultProjectIdentifier 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

DefaultProjectIdentifier (org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)10 Project (org.gradle.api.Project)3 InternalUnsupportedModelException (org.gradle.tooling.internal.protocol.InternalUnsupportedModelException)3 ModelIdentifier (org.gradle.tooling.internal.protocol.ModelIdentifier)3 LaunchableGradleTask (org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask)2 ArrayList (java.util.ArrayList)1 GradleException (org.gradle.api.GradleException)1 ProjectState (org.gradle.api.internal.project.ProjectState)1 CppApplication (org.gradle.language.cpp.CppApplication)1 DefaultCppLibrary (org.gradle.language.cpp.internal.DefaultCppLibrary)1 CompilerOutputFileNamingSchemeFactory (org.gradle.nativeplatform.internal.CompilerOutputFileNamingSchemeFactory)1 CppTestSuite (org.gradle.nativeplatform.test.cpp.CppTestSuite)1 BasicGradleProject (org.gradle.plugins.ide.internal.tooling.model.BasicGradleProject)1 DefaultBuildInvocations (org.gradle.plugins.ide.internal.tooling.model.DefaultBuildInvocations)1 DefaultGradleProject (org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject)1 LaunchableGradleTaskSelector (org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTaskSelector)1 BasicGradleProject (org.gradle.tooling.internal.gradle.BasicGradleProject)1 PartialBasicGradleProject (org.gradle.tooling.internal.gradle.PartialBasicGradleProject)1 ProjectIdentifier (org.gradle.tooling.model.ProjectIdentifier)1