Search in sources :

Example 1 with DefaultEclipseProject

use of org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject in project gradle by gradle.

the class EclipseModelBuilder method populate.

private void populate(Project project) {
    ((ProjectInternal) project).getModel().applyToMutableState(state -> {
        EclipseModel eclipseModel = project.getExtensions().getByType(EclipseModel.class);
        boolean projectDependenciesOnly = this.projectDependenciesOnly;
        ClasspathElements classpathElements = gatherClasspathElements(projectOpenStatus, eclipseModel.getClasspath(), projectDependenciesOnly);
        DefaultEclipseProject eclipseProject = findEclipseProject(project);
        eclipseProject.setClasspath(classpathElements.getExternalDependencies());
        eclipseProject.setProjectDependencies(classpathElements.getProjectDependencies());
        eclipseProject.setSourceDirectories(classpathElements.getSourceDirectories());
        eclipseProject.setClasspathContainers(classpathElements.getClasspathContainers());
        eclipseProject.setOutputLocation(classpathElements.getEclipseOutputLocation() != null ? classpathElements.getEclipseOutputLocation() : new DefaultEclipseOutputLocation("bin"));
        eclipseProject.setAutoBuildTasks(!eclipseModel.getAutoBuildTasks().getDependencies(null).isEmpty());
        org.gradle.plugins.ide.eclipse.model.Project xmlProject = new org.gradle.plugins.ide.eclipse.model.Project(new XmlTransformer());
        XmlFileContentMerger projectFile = eclipseModel.getProject().getFile();
        if (projectFile == null) {
            xmlProject.configure(eclipseModel.getProject());
        } else {
            eclipseModel.getProject().mergeXmlProject(xmlProject);
        }
        populateEclipseProjectTasks(eclipseProject, tasksFactory.getTasks(project));
        populateEclipseProject(eclipseProject, xmlProject);
        populateEclipseProjectJdt(eclipseProject, eclipseModel.getJdt());
    });
    for (Project childProject : project.getChildProjects().values()) {
        populate(childProject);
    }
}
Also used : XmlFileContentMerger(org.gradle.plugins.ide.api.XmlFileContentMerger) Project(org.gradle.api.Project) EclipseWorkspaceProject(org.gradle.tooling.model.eclipse.EclipseWorkspaceProject) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) DefaultEclipseProject(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject) XmlTransformer(org.gradle.internal.xml.XmlTransformer) DefaultEclipseOutputLocation(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseOutputLocation) EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel) DefaultEclipseProject(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject)

Example 2 with DefaultEclipseProject

use of org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject in project gradle by gradle.

the class EclipseModelBuilder method buildHierarchy.

private DefaultEclipseProject buildHierarchy(Project project) {
    List<DefaultEclipseProject> children = new ArrayList<>();
    for (Project child : project.getChildProjects().values()) {
        children.add(buildHierarchy(child));
    }
    EclipseModel eclipseModel = project.getExtensions().getByType(EclipseModel.class);
    org.gradle.plugins.ide.eclipse.model.EclipseProject internalProject = eclipseModel.getProject();
    String name = internalProject.getName();
    String description = GUtil.elvis(internalProject.getComment(), null);
    DefaultEclipseProject eclipseProject = new DefaultEclipseProject(name, project.getPath(), description, project.getProjectDir(), children).setGradleProject(rootGradleProject.findByPath(project.getPath()));
    for (DefaultEclipseProject child : children) {
        child.setParent(eclipseProject);
    }
    addProject(project, eclipseProject);
    return eclipseProject;
}
Also used : Project(org.gradle.api.Project) EclipseWorkspaceProject(org.gradle.tooling.model.eclipse.EclipseWorkspaceProject) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) DefaultEclipseProject(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject) ArrayList(java.util.ArrayList) EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel) DefaultEclipseProject(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject)

Aggregations

Project (org.gradle.api.Project)2 EclipseModel (org.gradle.plugins.ide.eclipse.model.EclipseModel)2 DefaultEclipseProject (org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject)2 DefaultGradleProject (org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject)2 EclipseWorkspaceProject (org.gradle.tooling.model.eclipse.EclipseWorkspaceProject)2 ArrayList (java.util.ArrayList)1 XmlTransformer (org.gradle.internal.xml.XmlTransformer)1 XmlFileContentMerger (org.gradle.plugins.ide.api.XmlFileContentMerger)1 DefaultEclipseOutputLocation (org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseOutputLocation)1