introduction of conflicts checking for Moo
[gitmo/Moo.git] / Makefile.PL
index a865867..e8c7e61 100644 (file)
@@ -2,6 +2,8 @@ use strict;
 use warnings FATAL => 'all';
 use 5.008001;
 use ExtUtils::MakeMaker;
+
+check_conflicts();
 (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
 
 my %BUILD_DEPS = ();
@@ -43,10 +45,14 @@ my %extra_info = (
 WriteMakefile(
   NAME => 'Moo',
   VERSION_FROM => 'lib/Moo.pm',
+  CONFIGURE_REQUIRES => {
+    'Dist::CheckConflicts' => '0.02',
+  },
   PREREQ_PM => {
     %RUN_DEPS,
     ($] >= 5.010 ? () : ('MRO::Compat' => 0)),
     ($mymeta_works ? () : (%BUILD_DEPS)),
+    'Dist::CheckConflicts' => '0.02',
   },
   ($mymeta_works
     ? ( # BUILD_REQUIRES makes MYMETA right, requires stops META being wrong
@@ -70,5 +76,39 @@ WriteMakefile(
   },
   ($mymeta && !$mymeta_works ? (NO_MYMETA => 1) : ()),
   LICENSE => 'perl',
+  'EXE_FILES' => [
+    'bin/moo-outdated',
+  ],
 );
 
+
+# copied from Moose-2.0801/Makefile.PL
+sub check_conflicts {
+    if ( eval { require 'lib/Moo/Conflicts.pm'; 1; } ) {
+        if ( eval { Moo::Conflicts->check_conflicts; 1 } ) {
+            return;
+        }
+        else {
+            my $err = $@;
+            $err =~ s/^/    /mg;
+            warn "***\n$err***\n";
+        }
+    }
+    else {
+        print <<'EOF';
+***
+    Your toolchain doesn't support configure_requires, so
+    Dist::CheckConflicts hasn't been installed yet. You should check for
+    conflicting modules manually using the 'moo-outdated' script that is
+    installed with this distribution once the installation finishes.
+***
+EOF
+    }
+
+    # More or less copied from Module::Build
+    return if $ENV{PERL_MM_USE_DEFAULT};
+    return unless -t STDIN && ( -t STDOUT || !( -f STDOUT || -c STDOUT ) );
+
+    sleep 4;
+}
+