Search in sources :

Example 1 with ProjectRegistry

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();
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) DirectorySensitivity(org.gradle.internal.fingerprint.DirectorySensitivity) CurrentFileCollectionFingerprint(org.gradle.internal.fingerprint.CurrentFileCollectionFingerprint) Hashing(org.gradle.internal.hash.Hashing) SettingsInternal(org.gradle.api.internal.SettingsInternal) FileValueSupplier(org.gradle.internal.execution.fingerprint.InputFingerprinter.FileValueSupplier) ExecutionResult(org.gradle.internal.execution.ExecutionResult) InputFingerprinter(org.gradle.internal.execution.fingerprint.InputFingerprinter) IncubationLogger(org.gradle.util.internal.IncubationLogger) VersionCatalogBuilder(org.gradle.api.initialization.dsl.VersionCatalogBuilder) DependencyResolutionManagementInternal(org.gradle.internal.management.DependencyResolutionManagementInternal) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) Map(java.util.Map) ExtensionContainer(org.gradle.api.plugins.ExtensionContainer) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) InputVisitor(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputVisitor) Set(java.util.Set) InputPropertyType(org.gradle.internal.execution.fingerprint.InputFingerprinter.InputPropertyType) ValueSnapshot(org.gradle.internal.snapshot.ValueSnapshot) Hasher(org.gradle.internal.hash.Hasher) Settings(org.gradle.api.initialization.Settings) Collectors(java.util.stream.Collectors) List(java.util.List) ProjectRegistry(org.gradle.api.internal.project.ProjectRegistry) DefaultClassPath(org.gradle.internal.classpath.DefaultClassPath) DefaultProjectDependencyFactory(org.gradle.api.internal.artifacts.DefaultProjectDependencyFactory) TreeFormatter(org.gradle.internal.logging.text.TreeFormatter) Optional(java.util.Optional) ClassPath(org.gradle.internal.classpath.ClassPath) Pattern(java.util.regex.Pattern) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) Inject(javax.inject.Inject) ExecutionEngine(org.gradle.internal.execution.ExecutionEngine) Lists(com.google.common.collect.Lists) FeaturePreviews(org.gradle.api.internal.FeaturePreviews) TreeType(org.gradle.internal.file.TreeType) ProjectDescriptor(org.gradle.api.initialization.ProjectDescriptor) FileCollectionFactory(org.gradle.api.internal.file.FileCollectionFactory) WorkspaceProvider(org.gradle.internal.execution.workspace.WorkspaceProvider) DependenciesAccessors(org.gradle.initialization.DependenciesAccessors) VersionCatalogsExtension(org.gradle.api.artifacts.VersionCatalogsExtension) Nullable(javax.annotation.Nullable) UnitOfWork(org.gradle.internal.execution.UnitOfWork) ClassPathRegistry(org.gradle.api.internal.ClassPathRegistry) ClasspathNormalizer(org.gradle.api.tasks.ClasspathNormalizer) Iterator(java.util.Iterator) ProjectFinder(org.gradle.api.internal.artifacts.dsl.dependencies.ProjectFinder) StringWriter(java.io.StringWriter) ClassLoaderScope(org.gradle.api.internal.initialization.ClassLoaderScope) LineEndingSensitivity(org.gradle.internal.fingerprint.LineEndingSensitivity) VersionCatalogBuilderInternal(org.gradle.internal.management.VersionCatalogBuilderInternal) Cast(org.gradle.internal.Cast) Maps(com.google.common.collect.Maps) File(java.io.File) ProviderFactory(org.gradle.api.provider.ProviderFactory) VersionCatalog(org.gradle.api.artifacts.VersionCatalog) Property(org.gradle.api.provider.Property) InvalidUserDataException(org.gradle.api.InvalidUserDataException) Collections(java.util.Collections) ProjectDescriptor(org.gradle.api.initialization.ProjectDescriptor) TreeFormatter(org.gradle.internal.logging.text.TreeFormatter) InvalidUserDataException(org.gradle.api.InvalidUserDataException)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 File (java.io.File)1 StringWriter (java.io.StringWriter)1 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1 Nullable (javax.annotation.Nullable)1 Inject (javax.inject.Inject)1 StringUtils (org.apache.commons.lang.StringUtils)1 InvalidUserDataException (org.gradle.api.InvalidUserDataException)1 VersionCatalog (org.gradle.api.artifacts.VersionCatalog)1 VersionCatalogsExtension (org.gradle.api.artifacts.VersionCatalogsExtension)1