Search in sources :

Example 1 with VersionCatalog

use of org.gradle.api.artifacts.VersionCatalog in project gradle by gradle.

the class DefaultDependenciesAccessors method createExtensions.

@Override
public void createExtensions(ProjectInternal project) {
    ExtensionContainer container = project.getExtensions();
    ProviderFactory providerFactory = project.getProviders();
    try {
        if (!models.isEmpty()) {
            ImmutableMap.Builder<String, VersionCatalog> catalogs = ImmutableMap.builderWithExpectedSize(models.size());
            for (DefaultVersionCatalog model : models) {
                if (model.isNotEmpty()) {
                    Class<? extends ExternalModuleDependencyFactory> factory;
                    synchronized (this) {
                        factory = factories.computeIfAbsent(model.getName(), n -> loadFactory(classLoaderScope, ACCESSORS_PACKAGE + "." + ACCESSORS_CLASSNAME_PREFIX + StringUtils.capitalize(n)));
                    }
                    if (factory != null) {
                        container.create(model.getName(), factory, model);
                        catalogs.put(model.getName(), new VersionCatalogView(model, providerFactory));
                    }
                }
            }
            container.create(VersionCatalogsExtension.class, "versionCatalogs", DefaultVersionCatalogsExtension.class, catalogs.build());
        }
    } finally {
        if (featurePreviews.isFeatureEnabled(FeaturePreviews.Feature.TYPESAFE_PROJECT_ACCESSORS)) {
            ServiceRegistry services = project.getServices();
            DependencyResolutionManagementInternal drm = services.get(DependencyResolutionManagementInternal.class);
            ProjectFinder projectFinder = services.get(ProjectFinder.class);
            createProjectsExtension(container, drm, projectFinder);
        }
    }
}
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) ProjectFinder(org.gradle.api.internal.artifacts.dsl.dependencies.ProjectFinder) ExtensionContainer(org.gradle.api.plugins.ExtensionContainer) ImmutableMap(com.google.common.collect.ImmutableMap) VersionCatalog(org.gradle.api.artifacts.VersionCatalog) ProviderFactory(org.gradle.api.provider.ProviderFactory) ServiceRegistry(org.gradle.internal.service.ServiceRegistry) DependencyResolutionManagementInternal(org.gradle.internal.management.DependencyResolutionManagementInternal)

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