use of org.gradle.api.internal.project.ProjectRegistry in project gradle by gradle.
the class DefaultDependenciesAccessors method assertCanGenerateAccessors.
private static boolean assertCanGenerateAccessors(ProjectRegistry<? extends ProjectDescriptor> projectRegistry) {
List<String> errors = Lists.newArrayList();
projectRegistry.getAllProjects().stream().map(ProjectDescriptor::getName).filter(p -> !SUPPORTED_PATTERN.matcher(p).matches()).map(name -> "project '" + name + "' doesn't follow the naming convention: " + SUPPORTED_PROJECT_NAMES).forEach(errors::add);
for (ProjectDescriptor project : projectRegistry.getAllProjects()) {
project.getChildren().stream().map(ProjectDescriptor::getName).collect(Collectors.groupingBy(AbstractSourceGenerator::toJavaName)).entrySet().stream().filter(e -> e.getValue().size() > 1).forEachOrdered(e -> {
String javaName = e.getKey();
List<String> names = e.getValue();
errors.add("subprojects " + names + " of project " + project.getPath() + " map to the same method name get" + javaName + "()");
});
}
if (!errors.isEmpty()) {
TreeFormatter formatter = new TreeFormatter();
formatter.node("Cannot generate project dependency accessors");
formatter.startChildren();
for (String error : errors) {
formatter.node("Cannot generate project dependency accessors because " + error);
}
formatter.endChildren();
throw new InvalidUserDataException(formatter.toString());
}
return errors.isEmpty();
}
Aggregations