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();
}
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;
}
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;
}
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());
}
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);
}
Aggregations