Dist::Zilla::Plugin::MakeMaker::SkipInstall - skip the install rule of MakeMaker


Dist-Zilla-Plugin-MakeMaker-SkipInstall documentation Contained in the Dist-Zilla-Plugin-MakeMaker-SkipInstall distribution.

Index


Code Index:

NAME

Top

Dist::Zilla::Plugin::MakeMaker::SkipInstall - skip the install rule of MakeMaker

VERSION

Top

version 1.100

SYNOPSIS

Top

In your dist.ini file:

    [MakeMaker::SkipInstall]

DESCRIPTION

Top

This small plugin will edit the Makefile.PL file, and override the install target to become a no-op.

This will make your module fail the install phase. It will be built, and tested but will never be installed.

The most common use for this techinique is for Task modules. Without a proper install phase, you can install your Task module repetedly.

CREDITS

Top

The technique was described by Marcel Gruenauer (hanekomu) in his article "Repeatedly installing Task::* distributions":

http://hanekomu.at/blog/dev/20091005-1227-repeatedly_installing_task_distributions.html

The author just wrapped the concept into a Dist::Zilla plugin.

SEE ALSO

Top

Dist::Zilla.

AUTHOR

Top

Pedro Melo, <melo at cpan.org>

COPYRIGHT & LICENSE

Top


Dist-Zilla-Plugin-MakeMaker-SkipInstall documentation Contained in the Dist-Zilla-Plugin-MakeMaker-SkipInstall distribution.

package Dist::Zilla::Plugin::MakeMaker::SkipInstall;
BEGIN {
  $Dist::Zilla::Plugin::MakeMaker::SkipInstall::VERSION = '1.100';
}

use Moose;

with 'Dist::Zilla::Role::AfterBuild';

has filename => (
  isa => 'Str',
  is  => 'ro',
  default =>  'Makefile.PL',
);

sub after_build {
  my ($self, $args) = @_;
  my $build_root = $args->{build_root};
  my $filename = $build_root->file($self->filename);
  
  my $content = $filename->slurp;
  
  my ($pre, $post) = split(/^\s*WriteMakefile[(]/sm, $content);
  $content = $pre
           . q{

exit 0 if $ENV{AUTOMATED_TESTING};
sub MY::install { "install ::\n" }

                      }
           . "\nWriteMakefile("
           . $post;
  
  my $fh = $filename->openw;
  $fh->print($content) or Carp::croak("error writing to $filename: $!");
  $fh->close or Carp::croak("error closing $filename: $!");
}

__PACKAGE__->meta->make_immutable;
no Moose;
1;

__END__