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