//! `settings.gradle.kts` emitter — wires the Android Gradle plugin
//! repositories at the build-script and project-resolution levels so a clean
//! checkout can resolve `com.android.library` without manual scaffolding.

use alef_core::config::ResolvedCrateConfig;

use crate::naming::aar_artifact_id;

/// Emit `settings.gradle.kts`. Hand-written `settings.gradle.kts` in the
/// emitted tree are unsupported — this file is rewritten on every
/// `alef generate`.
pub fn emit(config: &ResolvedCrateConfig) -> String {
    let artifact_id = aar_artifact_id(config);
    format!(
        r#"// Generated by alef. Do not edit by hand.

pluginManagement {{
    repositories {{
        google()
        mavenCentral()
        gradlePluginPortal()
    }}
}}

dependencyResolutionManagement {{
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {{
        google()
        mavenCentral()
    }}
}}

rootProject.name = "{artifact_id}"
"#
    )
}
