#license #retrieve #cargo-toml #licence #retriever

build license-retriever

Retrieves licenses of all Rust dependencies

6 stable releases

1.1.0 Sep 19, 2024
1.0.4 Aug 14, 2024
1.0.2 Aug 1, 2024
1.0.1 Jul 31, 2024

#242 in Build Utils

34 downloads per month

LGPL-3.0-only

18KB
290 lines

license-retriever

Crates.io Version Github Version Crates.io MSRV docs.rs GitHub License

GitHub code size GitHub repo size GitHub last commit (branch) GitHub commits since latest release (branch) GitHub Release Date Libraries.io dependency status for GitHub repo

Crates.io Downloads (recent) Crates.io Total Downloads

Retrieves licenses of all Rust dependencies. Originally written for stencil2 but is now separated into its own project.

How

Licenses are retrieved by searching in the following order:

  • Folder that Cargo.toml is in
  • Crate cache in ~/.cargo
  • GitHub repository
  • Text from spdx with identifier in Cargo.toml

Usage

Cargo

cargo add license-retriever
cargo add --build license-retriever

build.rs

use license_retriever::{Config, LicenseRetriever};

fn main() {
    let config = Config {
        // options...
        ..Config::default()
    };
    LicenseRetriever::from_config(&config).unwrap().save_in_out_dir("LICENSE-3RD-PARTY").unwrap();
}

main.rs

use license_retriever;

fn main() {
    let licenses = license_retriever::license_retriever_data!("LICENSE-3RD-PARTY").unwrap();
    println!("{}", licenses);
}

Dependencies

~14MB
~307K SLoC