use of org.gradle.api.initialization.dsl.VersionCatalogBuilder in project gradle by gradle.
the class DefaultDependenciesAccessors method generateAccessors.
@Override
public void generateAccessors(List<VersionCatalogBuilder> builders, ClassLoaderScope classLoaderScope, Settings settings) {
try {
this.classLoaderScope = classLoaderScope;
// this is used in tests only, shouldn't happen in real context
this.models.clear();
for (VersionCatalogBuilder builder : builders) {
DefaultVersionCatalog model = ((VersionCatalogBuilderInternal) builder).build();
models.add(model);
}
if (models.stream().anyMatch(DefaultVersionCatalog::isNotEmpty)) {
for (DefaultVersionCatalog model : models) {
if (model.isNotEmpty()) {
writeDependenciesAccessors(model);
}
}
}
if (featurePreviews.isFeatureEnabled(FeaturePreviews.Feature.TYPESAFE_PROJECT_ACCESSORS)) {
IncubationLogger.incubatingFeatureUsed("Type-safe project accessors");
writeProjectAccessors(((SettingsInternal) settings).getProjectRegistry());
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.gradle.api.initialization.dsl.VersionCatalogBuilder in project gradle by gradle.
the class BuildTreePreparingProjectsPreparer method generateDependenciesAccessorsAndAssignPluginVersions.
private void generateDependenciesAccessorsAndAssignPluginVersions(ServiceRegistry services, SettingsInternal settings, ClassLoaderScope classLoaderScope) {
DependenciesAccessors accessors = services.get(DependenciesAccessors.class);
DependencyResolutionManagementInternal dm = services.get(DependencyResolutionManagementInternal.class);
dm.getDefaultLibrariesExtensionName().finalizeValue();
String defaultLibrary = dm.getDefaultLibrariesExtensionName().get();
File dependenciesFile = new File(settings.getSettingsDir(), "gradle/libs.versions.toml");
if (dependenciesFile.exists()) {
dm.versionCatalogs(catalogs -> {
VersionCatalogBuilder builder = catalogs.findByName(defaultLibrary);
if (builder == null) {
builder = catalogs.create(defaultLibrary);
}
builder.from(services.get(FileCollectionFactory.class).fixed(dependenciesFile));
});
}
accessors.generateAccessors(dm.getDependenciesModelBuilders(), classLoaderScope, settings);
}
Aggregations