pass replace_constructor when making app immutable to force installation
[catagits/Catalyst-Runtime.git] / Makefile.PL
1 use inc::Module::Install 0.64;
2
3 perl_version '5.008001';
4
5 name 'Catalyst-Runtime';
6 all_from 'lib/Catalyst/Runtime.pm';
7
8 requires 'namespace::clean';
9 requires 'Scope::Upper' => '0.06';
10 requires 'MooseX::Emulate::Class::Accessor::Fast' => '0.00801';
11 requires 'Moose' => '0.73';
12 requires 'MooseX::MethodAttributes::Inheritable' => '0.06';
13 requires 'Carp';
14 requires 'Class::C3::Adopt::NEXT' => '0.07';
15 requires 'Class::MOP' => '0.79';
16 requires 'CGI::Simple::Cookie';
17 requires 'Data::Dump';
18 requires 'File::Modified';
19 requires 'HTML::Entities';
20 requires 'HTTP::Body'    => '1.04'; # makes uploadtmp work
21 requires 'HTTP::Headers' => '1.64';
22 requires 'HTTP::Request';
23 requires 'HTTP::Response';
24 requires 'HTTP::Request::AsCGI' => '0.5';
25 requires 'LWP::UserAgent';
26 requires 'Module::Pluggable' => '3.01';
27 requires 'Path::Class' => '0.09';
28 requires 'Scalar::Util';
29 requires 'Sub::Exporter';
30 requires 'Text::SimpleTable' => '0.03';
31 requires 'Time::HiRes';
32 requires 'Tree::Simple' => '1.15';
33 requires 'Tree::Simple::Visitor::FindByPath';
34 requires 'URI' => '1.35';
35 requires 'Text::Balanced'; # core in 5.8.x but mentioned for completeness
36 requires 'MRO::Compat';
37
38 recommends 'B::Hooks::OP::Check::StashChange';
39
40 test_requires 'Class::Data::Inheritable';
41 test_requires 'Test::MockObject';
42
43 # Run aggregate tests if AGGREGATE_TESTS environment = 1, but not if it = 0
44 # Otherwise default to using Test::Aggregate if installed, but not requiring it.
45 if (   ( exists $ENV{AGGREGATE_TESTS} && !$ENV{AGGREGATE_TESTS})
46     || (!exists $ENV{AGGREGATE_TESTS} && !can_use('Test::Aggregate', '0.34_01'))) {
47     tests join q{ },
48         grep { $_ ne 't/aggregate.t' }
49         map  { glob } qw[t/*.t t/aggregate/*.t];
50 }
51 else {
52     test_requires('Test::Aggregate', '0.34_01');
53 }
54 my @force_build_requires_if_author = qw(
55   Test::NoTabs
56   Test::Pod
57   Test::Pod::Coverage
58   Pod::Coverage
59 );
60
61 if ($Module::Install::AUTHOR) {
62     foreach my $module (@force_build_requires_if_author) {
63         build_requires $module;
64     }
65     darwin_check_no_resource_forks();
66 }
67
68 install_script glob('script/*.pl');
69 auto_install;
70 WriteAll;
71
72 if ($Module::Install::AUTHOR) {
73
74   # Strip out the author only build_requires from META.yml
75   # Need to do this _after_ WriteAll else it looses track of them
76   strip_author_only_build_requires(@force_build_requires_if_author);
77
78   Meta->{values}{resources} = [
79     [ 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst' ],
80     [ 'IRC'         => 'irc://irc.perl.org/#catalyst' ],
81     [ 'license',    => 'http://dev.perl.org/licenses/' ],
82     [ 'homepage',   => 'http://dev.catalyst.perl.org/'],
83     [ 'repository', => 'http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Runtime/' ],
84   ];
85
86   Meta->write;
87 }
88
89 print <<"EOF";
90
91  Important:
92
93     This library is for running Catalyst applications.
94
95     For development and use of catalyst.pl and myapp_create.pl, make sure
96     you also install the development tools package Catalyst::Devel.
97
98         perl -MCPANPLUS -e 'install Catalyst::Devel' # or
99         perl -MCPAN -e 'install Catalyst::Devel'
100
101     To get some commonly used plugins, as well as the TT view and DBIC 
102     model, install Task::Catalyst in the same way.
103
104  Have fun!
105 EOF
106
107 # NOTE - This is the version number of the _incompatible_ code,
108 #        not the version number of the fixed version.
109 my %conflicts = (
110     'Catalyst::Plugin::ConfigLoader'   => '0.22', # Older versions work but
111                                                   # throw Data::Visitor warns
112     'Catalyst::Devel'                  => '0.09',
113     'Catalyst::Plugin::SmartURI'       => '0.029',
114     'CatalystX::CRUD'                  => '0.37',
115     'Catalyst::Action::RenderView'     => '0.07',
116     'Catalyst::Plugin::DebugCookie'    => '0.999002',
117     'Catalyst::Plugin::Authentication' => '0.100091',
118     'CatalystX::Imports'               => '0.03',
119     'Catalyst::Plugin::HashedCookies'  => '1.03',
120     'Catalyst::Action::REST'           => '0.67',
121 );
122 check_conflicts(%conflicts);
123
124 # End of script, helper functions below.
125
126 sub darwin_check_no_resource_forks {
127     if ($^O eq 'darwin') {
128         my $osx_ver = `/usr/bin/sw_vers -productVersion`;
129         chomp $osx_ver;
130
131         # TAR on 10.4 wants COPY_EXTENDED_ATTRIBUTES_DISABLE
132         # On 10.5 (Leopard) it wants COPYFILE_DISABLE
133         my $attr = $osx_ver eq '10.5' ? 'COPYFILE_DISABLE' : 'COPY_EXTENDED_ATTRIBUTES_DISABLE';
134
135         makemaker_args(dist => { PREOP => qq{\@if [ "\$\$$attr" != "true" ]; then}.
136                                           qq{ echo "You must set the ENV variable $attr to true,"; }.
137                                           ' echo "to avoid getting resource forks in your dist."; exit 255; fi' });
138         }
139 }
140
141 sub strip_author_only_build_requires {
142     my @build_requires_to_strip = @_;
143     Meta->{values}{build_requires} = [ grep {
144       my $ok = 1;
145       foreach my $module (@build_requires_to_strip) {
146         if ($_->[0] =~ /$module/) {
147           $ok = 0;
148           last;
149         }
150       }
151       $ok;
152     } @{Meta->{values}{build_requires}} ];
153 }
154
155 sub check_conflicts {
156     my %conflicts = @_;
157
158     my %conflicts_found;
159     for my $mod ( sort keys %conflicts ) {
160         eval "require($mod)";
161         next if $@;
162
163         my $installed = $mod->VERSION();
164         $conflicts_found{$mod} = $installed if ( $installed le $conflicts{$mod} );
165     }
166
167     return unless scalar keys %conflicts_found;
168
169     print <<"EOF";
170
171  WARNING:
172
173     This version of Catalyst conflicts with the versions of
174     some components you have installed.
175
176     You will need to upgrade these modules after installing
177     this version of Catalyst.
178
179     List of the conflicting components and their installed versions:
180
181 EOF
182
183     foreach my $mod (keys %conflicts_found) {
184         print sprintf("    %s => %s\n", $mod, $conflicts_found{$mod});
185     }
186     print "\n";
187
188     # More or less copied from Module::Build, via Moose
189     return if $ENV{PERL_MM_USE_DEFAULT};
190     return unless -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT));
191
192     sleep 4;
193 }