alef 0.82.0

Opinionated polyglot binding generator for Rust libraries
Documentation
//! `AndroidManifest.xml` emitter — minimal manifest, namespace-only.

use crate::core::config::ResolvedCrateConfig;

/// Emit `src/main/AndroidManifest.xml`. The Android library namespace is set via
/// `android { namespace = ... }` in the generated `build.gradle.kts` (see
/// `gen_build_gradle::emit`); the manifest's `package` attribute is a removed legacy
/// path for the same value ("Setting the namespace via the package attribute is no
/// longer supported" under current AGP) and must not be emitted alongside it. ~keep
///
/// `config` is accepted for signature symmetry with the other `gen_*::emit` scaffolders
/// in this module (all keyed off the same `ResolvedCrateConfig`) even though this
/// manifest carries no config-derived content.
pub fn emit(_config: &ResolvedCrateConfig) -> String {
    r#"<?xml version="1.0" encoding="utf-8"?>
<!-- Generated by alef. Do not edit by hand. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
"#
    .to_string()
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::core::config::new_config::NewAlefConfig;

    fn test_config() -> ResolvedCrateConfig {
        let toml_str = r#"
[workspace]
languages = ["kotlin_android"]

[[crates]]
name = "test-lib"
sources = ["src/lib.rs"]

[crates.kotlin_android]
package = "dev.example"

[crates.jni]
"#;
        let cfg: NewAlefConfig = toml::from_str(toml_str).unwrap();
        cfg.resolve().unwrap().into_iter().next().unwrap()
    }

    /// Regression: current AGP ("Setting the namespace via the package attribute is no
    /// longer supported") rejects a manifest `package` attribute now that the namespace is
    /// set in `android { namespace = ... }` (see `gen_build_gradle` tests for that half).
    #[test]
    fn manifest_carries_no_package_attribute() {
        let manifest = emit(&test_config());

        assert!(
            !manifest.contains("package="),
            "manifest must not set the namespace via the deprecated package attribute: {manifest}"
        );
        assert_eq!(
            manifest,
            "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\
             <!-- Generated by alef. Do not edit by hand. -->\n\
             <manifest xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\
             </manifest>\n",
            "manifest content must be exactly the namespace-less shell"
        );
    }
}