perldist-zilla

Exclude a directory from Perl module release using Dist::Zilla


I have a subdirectory in my Perl Module root directory that I don't want to release.

I tried using "prune_directory" or "exclude_file" properties of https://metacpan.org/pod/Dist::Zilla::Plugin::GatherDir

I tried to specify the [GatherDir] section, but this conflicted as duplicate with @Basic, so in my dist.ini now I have (full file: https://github.com/telatin/FASTQ-Parser/blob/master/dist.ini):

[@Basic]
prune_directory = experimental

When building with dzil build --verbose i have all the lines like:

[@Basic/GatherDir] adding file experimental/scripts/my.pl

so the directory I wanted to prune is indeed added.

What should I do?


Solution

  • The @Basic plugin bundle cannot pass through options to the plugins it uses. So you must first remove the GatherDir plugin from it using the @Filter bundle, and then use GatherDir yourself with the extra options.

    [GatherDir]
    prune_directory = experimental
    
    [@Filter]
    -bundle = @Basic
    -remove = GatherDir
    

    Another option is to use the @ConfigSlicer bundle to modify the plugin @Basic uses directly.

    [@ConfigSlicer]
    -bundle = @Basic
    GatherDir.prune_directory[] = experimental
    

    (The [] in this case is because setting multi-value options through Config::Slicer requires the indication that it's multi-value. See the docs for details.)

    Consider the @Starter bundle, a modernized version of @Basic that allows -remove and config slicing options by default, as well as many other improvements and options based on modern Dist::Zilla practices.