File Coverage

blib/lib/Dist/Zilla/Plugin/CopyMakefilePLFromBuild.pm
Criterion Covered Total %
statement 10 22 45.4
branch 0 8 0.0
condition 0 5 0.0
subroutine 4 5 80.0
pod 0 1 0.0
total 14 41 34.1


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::CopyMakefilePLFromBuild;
2             BEGIN {
3 1     1   65736 $Dist::Zilla::Plugin::CopyMakefilePLFromBuild::VERSION = '0.0019';
4             }
5             # ABSTRACT: Copy Makefile.PL after building (for SCM inclusion, etc.)
6              
7              
8 1     1   12 use Moose;
  1         3  
  1         8  
9             with 'Dist::Zilla::Role::AfterBuild';
10              
11 1     1   5824 use File::Copy qw/ copy /;
  1         2  
  1         225  
12              
13             sub after_build {
14 0     0 0   my $self = shift;
15 0           my $data = shift;
16              
17 0 0 0       if ( $ENV{ DZIL_RELEASING} || $ENV{ DZIL_CopyFromBuildAfterBuild } ) {}
18 0           else { return }
19              
20 0           my $build_root = $data->{build_root};
21 0           my $src;
22 0           for(qw/ Makefile.PL /) {
23 0           my $file = $build_root->file( $_ );
24 0 0 0       $src = $file and last if -e $file;
25             }
26              
27 0 0         die "Missing Makefile.PL file in ", $build_root unless $src;
28              
29 0           my $dest = $self->zilla->root->file( $src->basename );
30              
31 0 0         copy "$src", "$dest" or die "Unable to copy $src to $dest: $!";
32             }
33              
34             __PACKAGE__->meta->make_immutable;
35 1     1   4 no Moose;
  1         2  
  1         6  
36             1;
37              
38             __END__
39             =pod
40              
41             =head1 NAME
42              
43             Dist::Zilla::Plugin::CopyMakefilePLFromBuild - Copy Makefile.PL after building (for SCM inclusion, etc.)
44              
45             =head1 VERSION
46              
47             version 0.0019
48              
49             =head1 SYNOPSIS
50              
51             In your L<Dist::Zilla> C<dist.ini>:
52              
53             [CopyMakefilePLFromBuild]
54              
55             =head1 DESCRIPTION
56              
57             CopyMakefilePLFromBuild will automatically copy the Makefile.PL from
58             the build directory into the distribution directory. This is so you
59             can commit the Makefile.PL to version control. When building directly
60             from GitHub (via cpanm, for example) you would need a Makefile.PL
61              
62             Dist::Zilla will not like it if you already have a Makefile.PL, so
63             you'll want to prune that file, an example of which is:
64              
65             [GatherDir] ; gathers files - including Makefile.PL
66             [PruneFiles] ; removes some files
67             filenames = Makefile.PL
68             [MakeMaker] ; generates your Makefile.PL for the build dir
69             [CopyMakefilePLFromBuild] ; copies the generated Makefile.PL back
70              
71             =head1 AfterBuild/AfterRelease
72              
73             With the release of 0.0016, this plugin changed to performing the copy during the AfterRelease stage instead of the AfterBuild stage.
74             To enable the old behavior, set the environment variable DZIL_CopyFromBuildAfterBuild to 1:
75              
76             $ DZIL_CopyFromBuildAfterBuild=1 dzil build
77              
78             =head1 AUTHOR
79              
80             Robert Krimen <robertkrimen@gmail.com>
81              
82             =head1 COPYRIGHT AND LICENSE
83              
84             This software is copyright (c) 2011 by Robert Krimen.
85              
86             This is free software; you can redistribute it and/or modify it under
87             the same terms as the Perl 5 programming language system itself.
88              
89             =cut
90