Hack module install to ensure we _require_ the stuff for the optional tests if you...
Tomas Doran (t0m) [Sat, 23 May 2009 18:31:41 +0000 (19:31 +0100)]
Makefile.PL

index 6c70f1f..e5ca729 100644 (file)
@@ -20,6 +20,64 @@ test_requires 'Alien::ActiveMQ' => '0.00003';
 no_index package => 'StompTestApp';
 no_index package => 'StompTestApp::Controller::TestController';
 
+my @force_build_requires_if_author = qw(
+  Test::NoTabs
+  Test::Pod
+  Test::Pod::Coverage
+  Pod::Coverage
+);
+
+if ($Module::Install::AUTHOR) {
+    foreach my $module (@force_build_requires_if_author) {
+        build_requires $module;
+    }
+    darwin_check_no_resource_forks();
+}
+
+install_script glob('script/*.pl');
 auto_install;
 WriteAll;
 
+if ($Module::Install::AUTHOR) {
+
+  # Strip out the author only build_requires from META.yml
+  # Need to do this _after_ WriteAll else it looses track of them
+  strip_author_only_build_requires(@force_build_requires_if_author);
+
+  Meta->{values}{resources} = [
+    [ 'license',    => 'http://dev.perl.org/licenses/' ],
+    [ 'repository', => 'git://github.com/chrisa/catalyst-engine-stomp.git' ],
+  ];
+
+  Meta->write;
+}
+
+sub darwin_check_no_resource_forks {
+    if ($^O eq 'darwin') {
+        my $osx_ver = `/usr/bin/sw_vers -productVersion`;
+        chomp $osx_ver;
+
+        # TAR on 10.4 wants COPY_EXTENDED_ATTRIBUTES_DISABLE
+        # On 10.5 (Leopard) it wants COPYFILE_DISABLE
+        my $attr = $osx_ver eq '10.5' ? 'COPYFILE_DISABLE' : 'COPY_EXTENDED_ATTRIBUTES_DISABLE';
+
+        makemaker_args(dist => { PREOP => qq{\@if [ "\$\$$attr" != "true" ]; then}.
+                                          qq{ echo "You must set the ENV variable $attr to true,"; }.
+                                          ' echo "to avoid getting resource forks in your dist."; exit 255; fi' });
+        }
+}
+
+sub strip_author_only_build_requires {
+    my @build_requires_to_strip = @_;
+    Meta->{values}{build_requires} = [ grep {
+      my $ok = 1;
+      foreach my $module (@build_requires_to_strip) {
+        if ($_->[0] =~ /$module/) {
+          $ok = 0;
+          last;
+        }
+      }
+      $ok;
+    } @{Meta->{values}{build_requires}} ];
+}
+