Commit | Line | Data |
354ce5a6 |
1 | package inc::MMPackageStash; |
2 | use Moose; |
3 | |
4 | extends 'Dist::Zilla::Plugin::MakeMaker::Awesome'; |
5 | |
6 | # XXX: this is pretty gross, it should be possible to clean this up later |
7 | around _build_MakeFile_PL_template => sub { |
8 | my $orig = shift; |
9 | my $self = shift; |
10 | my $template = $self->$orig(@_); |
11 | |
12 | $template =~ s/(use ExtUtils::MakeMaker.*)/$1\n\ncheck_conflicts();/; |
13 | |
14 | $template .= <<'CHECK_CONFLICTS'; |
15 | sub check_conflicts { |
16 | my %conflicts = ( |
17 | 'Class::MOP' => '1.09', |
18 | ); |
19 | my $found = 0; |
20 | for my $mod ( sort keys %conflicts ) { |
21 | eval "require $mod"; |
22 | next if $@; |
23 | |
24 | my $installed = $mod->VERSION(); |
25 | if ( $installed le $conflicts{$mod} ) { |
26 | |
27 | print <<"EOF"; |
28 | |
29 | *** |
30 | This version of Package::Stash conflicts with the version of |
31 | $mod ($installed) you have installed. |
32 | |
33 | You will need to upgrade $mod after installing |
34 | this version of Package::Stash. |
35 | *** |
36 | |
37 | EOF |
38 | |
39 | $found = 1; |
40 | } |
41 | } |
42 | |
43 | return unless $found; |
44 | |
45 | # More or less copied from Module::Build |
46 | return if $ENV{PERL_MM_USE_DEFAULT}; |
47 | return unless -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)); |
48 | |
49 | sleep 4; |
50 | } |
51 | CHECK_CONFLICTS |
52 | |
53 | return $template; |
54 | }; |
55 | |
56 | __PACKAGE__->meta->make_immutable; |
57 | no Moose; |
58 | |
59 | 1; |