GradleProjectTree rootTree,
Map<String, GradleProjectTree> projects) {
String projectPath = entry.getKey();
ModelQueryOutput modelOutput = customInfos.get(projectPath);
if (modelOutput == null) {
throw new IllegalStateException("Missing ModelQueryOutput for project " + projectPath);
}
GradleProjectTree projectTree = projects.get(projectPath);
if (projectTree == null) {
throw new IllegalStateException("Missing GradleProjectTree for project " + projectPath);
}
Map<Class<?>, Object> toolingModels;
if (modelClasses.isEmpty()) {
toolingModels = Collections.emptyMap();
}
else {
ModelGetter modelGetter = projectModelGetter(controller, entry.getValue());
toolingModels = new IdentityHashMap<Class<?>, Object>(2 * modelClasses.size());
for (Class<?> modelClass: modelClasses) {
Object modelValue = modelGetter.findModel(modelClass);
if (modelValue != null) {
toolingModels.put(modelClass, modelValue);
}
}
}
return new ActionFetchedProjectModels(
new GradleMultiProjectDef(rootTree, projectTree),
modelOutput.getProjectInfoResults(),
toolingModels,
modelOutput.getIssue());
}