Search in sources :

Example 6 with EclipseModel

use of org.gradle.plugins.ide.eclipse.model.EclipseModel in project spring-boot by spring-projects.

the class SystemTestPlugin method configureSystemTesting.

private void configureSystemTesting(Project project) {
    SourceSet systemTestSourceSet = createSourceSet(project);
    createTestTask(project, systemTestSourceSet);
    project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin) -> {
        EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class);
        eclipse.classpath((classpath) -> classpath.getPlusConfigurations().add(project.getConfigurations().getByName(systemTestSourceSet.getRuntimeClasspathConfigurationName())));
    });
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel)

Example 7 with EclipseModel

use of org.gradle.plugins.ide.eclipse.model.EclipseModel in project spring-boot by spring-projects.

the class IntegrationTestPlugin method configureIntegrationTesting.

private void configureIntegrationTesting(Project project) {
    SourceSet intTestSourceSet = createSourceSet(project);
    Test intTest = createTestTask(project, intTestSourceSet);
    project.getTasks().getByName(LifecycleBasePlugin.CHECK_TASK_NAME).dependsOn(intTest);
    project.getPlugins().withType(EclipsePlugin.class, (eclipsePlugin) -> {
        EclipseModel eclipse = project.getExtensions().getByType(EclipseModel.class);
        eclipse.classpath((classpath) -> classpath.getPlusConfigurations().add(project.getConfigurations().getByName(intTestSourceSet.getRuntimeClasspathConfigurationName())));
    });
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) Test(org.gradle.api.tasks.testing.Test) EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel)

Example 8 with EclipseModel

use of org.gradle.plugins.ide.eclipse.model.EclipseModel in project gradle by gradle.

the class EclipseWtpPlugin method onApply.

@Override
protected void onApply(Project project) {
    project.getPluginManager().apply(EclipsePlugin.class);
    getLifecycleTask().configure(withDescription("Generates Eclipse wtp configuration files."));
    getCleanTask().configure(withDescription("Cleans Eclipse wtp configuration files."));
    project.getTasks().named(EclipsePlugin.ECLIPSE_TASK_NAME, dependsOn(getLifecycleTask()));
    project.getTasks().named(cleanName(EclipsePlugin.ECLIPSE_TASK_NAME), dependsOn(getCleanTask()));
    EclipseModel model = project.getExtensions().getByType(EclipseModel.class);
    configureEclipseProject(project, model);
    configureEclipseWtpComponent(project, model);
    configureEclipseWtpFacet(project, model);
    // do this after wtp is configured because wtp config is required to update classpath properly
    configureEclipseClasspath(project, model);
}
Also used : EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel)

Example 9 with EclipseModel

use of org.gradle.plugins.ide.eclipse.model.EclipseModel 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 10 with EclipseModel

use of org.gradle.plugins.ide.eclipse.model.EclipseModel in project gradle by gradle.

the class EclipseModelAwareUniqueProjectNameProvider method getDeduplicatedNames.

private synchronized Map<ProjectState, String> getDeduplicatedNames() {
    if (deduplicated == null) {
        projectToInformationMap = new HashMap<>();
        for (ProjectState state : projectRegistry.getAllProjects()) {
            // try to get the name from EclipseProject.name
            state.getOwner().ensureProjectsConfigured();
            EclipseModel model = state.getMutableModel().getExtensions().findByType(EclipseModel.class);
            if (model != null && model.getProject().getName() != null) {
                projectToInformationMap.put(state, new ProjectStateWrapper(model.getProject().getName(), state, state.getParent()));
                continue;
            }
            // fallback: take the name from the ProjectState
            projectToInformationMap.put(state, new ProjectStateWrapper(state.getName(), state, state.getParent()));
        }
        HierarchicalElementDeduplicator<ProjectStateWrapper> deduplicator = new HierarchicalElementDeduplicator<>(new ProjectPathDeduplicationAdapter(projectToInformationMap));
        List<ProjectStateWrapper> allElements = new ArrayList<>();
        allElements.addAll(reservedNames);
        allElements.addAll(projectToInformationMap.values());
        this.deduplicated = deduplicator.deduplicate(allElements).entrySet().stream().collect(Collectors.toMap(e -> e.getKey().project, Map.Entry::getValue));
    }
    return deduplicated;
}
Also used : EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel) ArrayList(java.util.ArrayList) ProjectState(org.gradle.api.internal.project.ProjectState)

Aggregations

EclipseModel (org.gradle.plugins.ide.eclipse.model.EclipseModel)11 ArrayList (java.util.ArrayList)6 Project (org.gradle.api.Project)6 Properties (java.util.Properties)2 Task (org.gradle.api.Task)2 Delete (org.gradle.api.tasks.Delete)2 SourceSet (org.gradle.api.tasks.SourceSet)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 IdlOptions (com.linkedin.pegasus.gradle.PegasusOptions.IdlOptions)1 CompatibilityLogChecker (com.linkedin.pegasus.gradle.internal.CompatibilityLogChecker)1 ChangedFileReportTask (com.linkedin.pegasus.gradle.tasks.ChangedFileReportTask)1 CheckIdlTask (com.linkedin.pegasus.gradle.tasks.CheckIdlTask)1 CheckPegasusSnapshotTask (com.linkedin.pegasus.gradle.tasks.CheckPegasusSnapshotTask)1 CheckRestModelTask (com.linkedin.pegasus.gradle.tasks.CheckRestModelTask)1 CheckSnapshotTask (com.linkedin.pegasus.gradle.tasks.CheckSnapshotTask)1 GenerateAvroSchemaTask (com.linkedin.pegasus.gradle.tasks.GenerateAvroSchemaTask)1 GenerateDataTemplateTask (com.linkedin.pegasus.gradle.tasks.GenerateDataTemplateTask)1 GeneratePegasusSnapshotTask (com.linkedin.pegasus.gradle.tasks.GeneratePegasusSnapshotTask)1