Search in sources :

Example 1 with EclipseWorkspaceProject

use of org.gradle.tooling.model.eclipse.EclipseWorkspaceProject in project gradle by gradle.

the class RunBuildDependenciesTaskBuilder method buildAll.

@Override
public RunClosedProjectBuildDependencies buildAll(String modelName, EclipseRuntime eclipseRuntime, Project project) {
    this.projectOpenStatus = eclipseRuntime.getWorkspace().getProjects().stream().collect(Collectors.toMap(EclipseWorkspaceProject::getName, EclipseModelBuilder::isProjectOpen, (a, b) -> a | b));
    List<TaskDependency> buildDependencies = populate(project.getRootProject());
    if (!buildDependencies.isEmpty()) {
        Gradle rootGradle = getRootGradle(project.getGradle());
        Project rootProject = rootGradle.getRootProject();
        StartParameter startParameter = rootGradle.getStartParameter();
        List<String> taskPaths = new ArrayList<>(startParameter.getTaskNames());
        String parentTaskName = parentTaskName(rootProject, "eclipseClosedDependencies");
        Task task = rootProject.task(parentTaskName);
        task.dependsOn(buildDependencies.toArray(new Object[0]));
        taskPaths.add(parentTaskName);
        startParameter.setTaskNames(taskPaths);
    }
    return DefaultRunClosedProjectBuildDependencies.INSTANCE;
}
Also used : TaskDependency(org.gradle.api.tasks.TaskDependency) Project(org.gradle.api.Project) EclipseWorkspaceProject(org.gradle.tooling.model.eclipse.EclipseWorkspaceProject) StartParameter(org.gradle.StartParameter) Task(org.gradle.api.Task) EclipseWorkspaceProject(org.gradle.tooling.model.eclipse.EclipseWorkspaceProject) ArrayList(java.util.ArrayList) Gradle(org.gradle.api.invocation.Gradle)

Example 2 with EclipseWorkspaceProject

use of org.gradle.tooling.model.eclipse.EclipseWorkspaceProject in project gradle by gradle.

the class EclipseModelBuilder method calculateReservedProjectNames.

private List<String> calculateReservedProjectNames(ProjectInternal rootProject, EclipseRuntime parameter) {
    if (parameter == null) {
        return Collections.emptyList();
    }
    EclipseWorkspace workspace = parameter.getWorkspace();
    if (workspace == null) {
        return Collections.emptyList();
    }
    List<EclipseWorkspaceProject> projects = workspace.getProjects();
    if (projects == null) {
        return Collections.emptyList();
    }
    List<String> reservedProjectNames = new ArrayList<>();
    List<EclipseWorkspaceProject> externalProjects = gatherExternalProjects(rootProject, projects);
    for (EclipseWorkspaceProject externalProject : externalProjects) {
        reservedProjectNames.add(externalProject.getName());
    }
    return reservedProjectNames;
}
Also used : EclipseWorkspaceProject(org.gradle.tooling.model.eclipse.EclipseWorkspaceProject) ArrayList(java.util.ArrayList) EclipseWorkspace(org.gradle.tooling.model.eclipse.EclipseWorkspace)

Example 3 with EclipseWorkspaceProject

use of org.gradle.tooling.model.eclipse.EclipseWorkspaceProject in project gradle by gradle.

the class EclipseModelBuilder method gatherExternalProjects.

private List<EclipseWorkspaceProject> gatherExternalProjects(ProjectInternal rootProject, List<EclipseWorkspaceProject> projects) {
    // The eclipse workspace contains projects from root and included builds. Check projects from all builds
    // so that models built for included builds do not consider projects from parent builds as external.
    Set<File> gradleProjectLocations = collectAllProjects(new ArrayList<>(), getRootBuild(rootProject.getGradle()), new HashSet<>()).stream().map(p -> p.getProjectDir().getAbsoluteFile()).collect(Collectors.toSet());
    List<EclipseWorkspaceProject> externalProjects = new ArrayList<>();
    for (EclipseWorkspaceProject project : projects) {
        if (project == null || project.getLocation() == null || project.getName() == null || project.getLocation() == null) {
            continue;
        }
        if (!gradleProjectLocations.contains(project.getLocation().getAbsoluteFile())) {
            externalProjects.add(project);
        }
    }
    return externalProjects;
}
Also used : TaskDependency(org.gradle.api.tasks.TaskDependency) CollectionUtils(org.gradle.util.internal.CollectionUtils) StringUtils(org.apache.commons.lang.StringUtils) DefaultEclipseOutputLocation(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseOutputLocation) ProjectStateRegistry(org.gradle.api.internal.project.ProjectStateRegistry) BuildState(org.gradle.internal.build.BuildState) Link(org.gradle.plugins.ide.eclipse.model.Link) DefaultAccessRule(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultAccessRule) EclipsePlugin(org.gradle.plugins.ide.eclipse.EclipsePlugin) GUtil(org.gradle.util.internal.GUtil) Task(org.gradle.api.Task) Container(org.gradle.plugins.ide.eclipse.model.Container) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Map(java.util.Map) XmlTransformer(org.gradle.internal.xml.XmlTransformer) DefaultEclipseSourceDirectory(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseSourceDirectory) DefaultEclipseExternalDependency(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseExternalDependency) EclipseJdt(org.gradle.plugins.ide.eclipse.model.EclipseJdt) EclipseClasspath(org.gradle.plugins.ide.eclipse.model.EclipseClasspath) DefaultEclipseProjectNature(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProjectNature) Project(org.gradle.api.Project) Classpath(org.gradle.plugins.ide.eclipse.model.Classpath) DefaultClasspathAttribute(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultClasspathAttribute) Set(java.util.Set) Collectors(java.util.stream.Collectors) Gradle(org.gradle.api.invocation.Gradle) SourceFolder(org.gradle.plugins.ide.eclipse.model.SourceFolder) XmlFileContentMerger(org.gradle.plugins.ide.api.XmlFileContentMerger) List(java.util.List) Spec(org.gradle.api.specs.Spec) ParameterizedToolingModelBuilder(org.gradle.tooling.provider.model.ParameterizedToolingModelBuilder) DefaultEclipseTask(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseTask) EclipseRuntime(org.gradle.tooling.model.eclipse.EclipseRuntime) AbstractClasspathEntry(org.gradle.plugins.ide.eclipse.model.AbstractClasspathEntry) EclipseModelAwareUniqueProjectNameProvider(org.gradle.plugins.ide.internal.configurer.EclipseModelAwareUniqueProjectNameProvider) DefaultEclipseBuildCommand(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseBuildCommand) IncludedBuildInternal(org.gradle.internal.composite.IncludedBuildInternal) Library(org.gradle.plugins.ide.eclipse.model.Library) HashMap(java.util.HashMap) DefaultEclipseClasspathContainer(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseClasspathContainer) ArrayList(java.util.ArrayList) AbstractLibrary(org.gradle.plugins.ide.eclipse.model.AbstractLibrary) DefaultEclipseLinkedResource(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseLinkedResource) HashSet(java.util.HashSet) EclipseWorkspaceProject(org.gradle.tooling.model.eclipse.EclipseWorkspaceProject) Lists(com.google.common.collect.Lists) AccessRule(org.gradle.plugins.ide.eclipse.model.AccessRule) UnsupportedMethodException(org.gradle.tooling.model.UnsupportedMethodException) LinkedList(java.util.LinkedList) GradleInternal(org.gradle.api.internal.GradleInternal) EclipseWorkspace(org.gradle.tooling.model.eclipse.EclipseWorkspace) EclipseModel(org.gradle.plugins.ide.eclipse.model.EclipseModel) DefaultEclipseProjectDependency(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProjectDependency) Maps(com.google.common.collect.Maps) ClasspathEntry(org.gradle.plugins.ide.eclipse.model.ClasspathEntry) File(java.io.File) UnresolvedLibrary(org.gradle.plugins.ide.eclipse.model.UnresolvedLibrary) DefaultGradleProject(org.gradle.plugins.ide.internal.tooling.model.DefaultGradleProject) Output(org.gradle.plugins.ide.eclipse.model.Output) DefaultEclipseProject(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject) DefaultInstalledJdk(org.gradle.plugins.ide.internal.tooling.java.DefaultInstalledJdk) ProjectDependency(org.gradle.plugins.ide.eclipse.model.ProjectDependency) BuildCommand(org.gradle.plugins.ide.eclipse.model.BuildCommand) DefaultEclipseJavaSourceSettings(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseJavaSourceSettings) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Collections(java.util.Collections) IncludedBuildState(org.gradle.internal.build.IncludedBuildState) EclipseWorkspaceProject(org.gradle.tooling.model.eclipse.EclipseWorkspaceProject) ArrayList(java.util.ArrayList) File(java.io.File) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)3 EclipseWorkspaceProject (org.gradle.tooling.model.eclipse.EclipseWorkspaceProject)3 Project (org.gradle.api.Project)2 Task (org.gradle.api.Task)2 Gradle (org.gradle.api.invocation.Gradle)2 TaskDependency (org.gradle.api.tasks.TaskDependency)2 EclipseWorkspace (org.gradle.tooling.model.eclipse.EclipseWorkspace)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 File (java.io.File)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 StringUtils (org.apache.commons.lang.StringUtils)1