File Coverage

blib/lib/Dist/Zilla/Plugin/MakeMaker/SkipInstall.pm
Criterion Covered Total %
statement 2 4 50.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 4 6 66.6


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::MakeMaker::SkipInstall;
2             BEGIN {
3 1     1   842 $Dist::Zilla::Plugin::MakeMaker::SkipInstall::VERSION = '1.100';
4             }
5              
6 1     1   542 use Moose;
  0            
  0            
7              
8             with 'Dist::Zilla::Role::AfterBuild';
9              
10             has filename => (
11             isa => 'Str',
12             is => 'ro',
13             default => 'Makefile.PL',
14             );
15              
16             sub after_build {
17             my ($self, $args) = @_;
18             my $build_root = $args->{build_root};
19             my $filename = $build_root->file($self->filename);
20            
21             my $content = $filename->slurp;
22            
23             my ($pre, $post) = split(/^\s*WriteMakefile[(]/sm, $content);
24             $content = $pre
25             . q{
26              
27             exit 0 if $ENV{AUTOMATED_TESTING};
28             sub MY::install { "install ::\n" }
29              
30             }
31             . "\nWriteMakefile("
32             . $post;
33            
34             my $fh = $filename->openw;
35             $fh->print($content) or Carp::croak("error writing to $filename: $!");
36             $fh->close or Carp::croak("error closing $filename: $!");
37             }
38              
39             __PACKAGE__->meta->make_immutable;
40             no Moose;
41             1;
42              
43             __END__
44              
45             =head1 NAME
46              
47             Dist::Zilla::Plugin::MakeMaker::SkipInstall - skip the install rule of MakeMaker
48              
49             =head1 VERSION
50              
51             version 1.100
52              
53             =head1 SYNOPSIS
54              
55             In your C<dist.ini> file:
56              
57             [MakeMaker::SkipInstall]
58              
59             =head1 DESCRIPTION
60              
61             This small plugin will edit the C<Makefile.PL> file, and override the
62             install target to become a no-op.
63              
64             This will make your module fail the install phase. It will be built, and
65             tested but will never be installed.
66              
67             The most common use for this techinique is for L<Task> modules. Without
68             a proper install phase, you can install your Task module repetedly.
69              
70              
71             =head1 CREDITS
72              
73             The technique was described by Marcel Gruenauer (hanekomu) in his
74             article "Repeatedly installing Task::* distributions":
75              
76             L<http://hanekomu.at/blog/dev/20091005-1227-repeatedly_installing_task_distributions.html>
77              
78             The author just wrapped the concept into a L<Dist::Zilla> plugin.
79              
80              
81             =head1 SEE ALSO
82              
83             L<Dist::Zilla>.
84              
85              
86             =head1 AUTHOR
87              
88             Pedro Melo, C<< <melo at cpan.org> >>
89              
90              
91             =head1 COPYRIGHT & LICENSE
92              
93             Copyright 2009 Pedro Melo.
94              
95             This program is free software; you can redistribute it and/or modify it
96             under the same terms as Perl itself.
97              
98              
99             =begin make-pod-coverage-happy
100              
101             =over 4
102              
103             =item after_build()
104              
105             Edits the C<Makefile.PL> in place, searches for C<WriteMakefile> and
106             prepends our override.
107              
108             =back
109              
110             =end make-pod-coverage-happy
111              
112             =cut