perlcpanmakemaker

How to populate 'provides' field in META files using ExtUtils::MakeMaker


One of my modules is failing the CPANTS policy meta_yml_has_provides

The documentation states:

Add all modules contained in this distribution to the META.yml field 'provides'. Module::Build or Dist::Zilla::Plugin::MetaProvides do this automatically for you.

How can I to apply this to my CPAN module while using ExtUtils::MakeMaker?


Solution

  • You could do something like this:

    use ExtUtils::MakeMaker;
    use Module::Metadata;
    WriteMakefile(
        ...
        META_ADD => {
            provides => Module::Metadata->provides(version => '1.4', dir => 'lib'),
        },
        ...
    );
    

    But then your end users also need to depend on Module::Metadata. You may want to add some author only logic to that for production use. YMMV.

    I'm not sure it's really worth it in that regard. Possibly MakeMaker should have built-in support for this instead.