Skip to content

Commit 9e45241

Browse files
create Makefile.PL in filegatherer phase
This allows other plugins to not just see that this file exists (at early phases such as file munging, and generate files accordingly -- e.g. [InstallGuide]), but allow other plugins to add content earlier (e.g. Devel::CheckLib). The template will be evaluated at the normal time, once the prereq list is finalized. This change mirrors that in rjbs/Dist-Zilla#229, and live independently of that, but must release first.
1 parent a5e6384 commit 9e45241

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Revision history for {{ $dist->name }}
22

33
{{$NEXT}}
4+
- create Makefile.PL at filegatherer phase, to allow other plugins to see
5+
the file earlier
46

57
0.22 2014-07-29 04:51:13Z
68
- fix for Dist::Zilla::Plugin::MakeMaker 5.020 dropping a default required

lib/Dist/Zilla/Plugin/MakeMaker/Awesome.pm

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ use MooseX::Types::Stringlike 'Stringlike';
88
use Moose::Autobox;
99
use namespace::autoclean;
1010
use CPAN::Meta::Requirements 2.121; # requirements_for_module
11+
use List::Util 'first';
1112

1213
extends 'Dist::Zilla::Plugin::MakeMaker' => { -version => 5.001 };
14+
# avoid wiping out the method modifications to dump_config done by superclass
15+
with 'Dist::Zilla::Role::FileGatherer' => { -excludes => 'dump_config' };
1316

1417
sub mvp_multivalue_args { qw(WriteMakefile_arg_strs test_files exe_files) }
1518

@@ -253,7 +256,22 @@ sub register_prereqs {
253256
return {};
254257
}
255258

256-
sub setup_installer {
259+
sub gather_files
260+
{
261+
my $self = shift;
262+
263+
require Dist::Zilla::File::InMemory;
264+
my $file = Dist::Zilla::File::InMemory->new({
265+
name => 'Makefile.PL',
266+
content => $self->MakeFile_PL_template, # template evaluated later
267+
});
268+
269+
$self->add_file($file);
270+
return;
271+
}
272+
273+
sub setup_installer
274+
{
257275
my $self = shift;
258276

259277
## Sanity checks
@@ -262,8 +280,12 @@ sub setup_installer {
262280

263281
my $perl_prereq = $self->delete_WriteMakefile_arg('MIN_PERL_VERSION');
264282

283+
# file was already created; find it and fill in the content
284+
my $file = first { $_->name eq 'Makefile.PL' } @{$self->zilla->files};
285+
$self->log_debug([ 'updating contents of Makefile.PL in memory' ]);
286+
265287
my $content = $self->fill_in_string(
266-
$self->MakeFile_PL_template,
288+
$file->content,
267289
{
268290
dist => \($self->zilla),
269291
plugin => \$self,
@@ -275,13 +297,7 @@ sub setup_installer {
275297
extra_args => \($self->WriteMakefile_arg_strs),
276298
},
277299
);
278-
279-
my $file = Dist::Zilla::File::InMemory->new({
280-
name => 'Makefile.PL',
281-
content => $content,
282-
});
283-
284-
$self->add_file($file);
300+
$file->content($content);
285301
return;
286302
}
287303

@@ -508,6 +524,8 @@ Defaults to using data from C<:ExecDir> plugins.
508524
509525
=head3 register_prereqs
510526
527+
=head3 gather_files
528+
511529
=head3 setup_installer
512530
513531
=for stopwords dirs

0 commit comments

Comments
 (0)