Search in sources :

Example 1 with DependenciesAccessors

use of org.gradle.initialization.DependenciesAccessors 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);
}
Also used : VersionCatalogBuilder(org.gradle.api.initialization.dsl.VersionCatalogBuilder) DependenciesAccessors(org.gradle.initialization.DependenciesAccessors) DependencyResolutionManagementInternal(org.gradle.internal.management.DependencyResolutionManagementInternal) File(java.io.File)

Aggregations

File (java.io.File)1 VersionCatalogBuilder (org.gradle.api.initialization.dsl.VersionCatalogBuilder)1 DependenciesAccessors (org.gradle.initialization.DependenciesAccessors)1 DependencyResolutionManagementInternal (org.gradle.internal.management.DependencyResolutionManagementInternal)1