Search in sources :

Example 16 with ProjectState

use of org.gradle.api.internal.project.ProjectState in project gradle by gradle.

the class EclipseModelAwareUniqueProjectNameProvider method getUniqueName.

@Override
public String getUniqueName(Project project) {
    ProjectState state = projectRegistry.stateFor(project);
    String uniqueName = getDeduplicatedNames().get(state);
    if (uniqueName != null) {
        return uniqueName;
    }
    // ProjectStateWrapper might contain the configured eclipse project name
    ProjectStateWrapper information = projectToInformationMap.get(state);
    if (information != null) {
        return information.name;
    }
    return state.getName();
}
Also used : ProjectState(org.gradle.api.internal.project.ProjectState)

Example 17 with ProjectState

use of org.gradle.api.internal.project.ProjectState 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)

Example 18 with ProjectState

use of org.gradle.api.internal.project.ProjectState in project gradle by gradle.

the class AbstractCompositeParticipantBuildState method getAvailableModules.

@Override
public synchronized Set<Pair<ModuleVersionIdentifier, ProjectComponentIdentifier>> getAvailableModules() {
    if (availableModules == null) {
        ensureChildBuildConfigured();
        availableModules = new LinkedHashSet<>();
        for (ProjectState project : getProjects().getAllProjects()) {
            registerProject(availableModules, project.getMutableModel());
        }
    }
    return availableModules;
}
Also used : ProjectState(org.gradle.api.internal.project.ProjectState)

Example 19 with ProjectState

use of org.gradle.api.internal.project.ProjectState in project gradle by gradle.

the class InstantiatingBuildLoader method attachDefaultProject.

private void attachDefaultProject(GradleInternal gradle, DefaultProjectDescriptor defaultProjectDescriptor) {
    ProjectState defaultProject = gradle.getOwner().getProjects().getProject(defaultProjectDescriptor.path());
    gradle.setDefaultProject(defaultProject.getMutableModel());
}
Also used : ProjectState(org.gradle.api.internal.project.ProjectState)

Example 20 with ProjectState

use of org.gradle.api.internal.project.ProjectState in project gradle by gradle.

the class InstantiatingBuildLoader method createProjects.

private void createProjects(GradleInternal gradle, DefaultProjectDescriptor rootProjectDescriptor) {
    ClassLoaderScope baseProjectClassLoaderScope = gradle.baseProjectClassLoaderScope();
    ClassLoaderScope rootProjectClassLoaderScope = baseProjectClassLoaderScope.createChild("root-project[" + gradle.getIdentityPath() + "]");
    ProjectState projectState = gradle.getOwner().getProjects().getProject(rootProjectDescriptor.path());
    projectState.createMutableModel(rootProjectClassLoaderScope, baseProjectClassLoaderScope);
    ProjectInternal rootProject = projectState.getMutableModel();
    gradle.setRootProject(rootProject);
    createChildProjectsRecursively(gradle.getOwner(), rootProjectDescriptor, rootProjectClassLoaderScope, baseProjectClassLoaderScope);
}
Also used : ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) ProjectState(org.gradle.api.internal.project.ProjectState)

Aggregations

ProjectState (org.gradle.api.internal.project.ProjectState)20 ProjectInternal (org.gradle.api.internal.project.ProjectInternal)4 ProjectComponentIdentifier (org.gradle.api.artifacts.component.ProjectComponentIdentifier)3 ClassLoaderScope (org.gradle.api.internal.initialization.ClassLoaderScope)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 FileResolver (org.gradle.api.internal.file.FileResolver)2 ProjectStateRegistry (org.gradle.api.internal.project.ProjectStateRegistry)2 DefaultProjectDescriptor (org.gradle.initialization.DefaultProjectDescriptor)2 ProjectDescriptorRegistry (org.gradle.initialization.ProjectDescriptorRegistry)2 BuildState (org.gradle.internal.build.BuildState)2 DefaultResourceLockCoordinationService (org.gradle.internal.resources.DefaultResourceLockCoordinationService)2 ResourceLockCoordinationService (org.gradle.internal.resources.ResourceLockCoordinationService)2 BasicGradleProject (org.gradle.plugins.ide.internal.tooling.model.BasicGradleProject)2 LinkedHashMap (java.util.LinkedHashMap)1 ModuleVersionIdentifier (org.gradle.api.artifacts.ModuleVersionIdentifier)1 GradleInternal (org.gradle.api.internal.GradleInternal)1 StartParameterInternal (org.gradle.api.internal.StartParameterInternal)1 ResolvedProjectConfiguration (org.gradle.api.internal.artifacts.ivyservice.resolveengine.projectresult.ResolvedProjectConfiguration)1 AttributesSchemaInternal (org.gradle.api.internal.attributes.AttributesSchemaInternal)1