Optionally update conflicting modules by adding them to requires. This is disabled...
[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 # NOTE - This is the version number which the user must upgrade to to be ok,
44 my %conflicts = (
45     'Catalyst::Plugin::ConfigLoader'   => '0.23', # Older versions work but
46                                                   # throw Data::Visitor warns
47     'Catalyst::Devel'                  => '0.10',
48     'Catalyst::Plugin::SmartURI'       => '0.030',
49     'CatalystX::CRUD'                  => '0.38',
50     'Catalyst::Action::RenderView'     => '0.08',
51     'Catalyst::Plugin::DebugCookie'    => '0.999003',
52     'Catalyst::Plugin::Authentication' => '0.100092',
53     'CatalystX::Imports'               => '0.04',
54     'Catalyst::Plugin::HashedCookies'  => '1.04',
55     'Catalyst::Action::REST'           => '0.68',
56 );
57 check_conflicts(%conflicts);
58
59 # Run aggregate tests if AGGREGATE_TESTS environment = 1, but not if it = 0
60 # Otherwise default to using Test::Aggregate if installed, but not requiring it.
61 if (   ( exists $ENV{AGGREGATE_TESTS} && !$ENV{AGGREGATE_TESTS})
62     || (!exists $ENV{AGGREGATE_TESTS} && !can_use('Test::Aggregate', '0.34_01'))) {
63     tests join q{ },
64         grep { $_ ne 't/aggregate.t' }
65         map  { glob } qw[t/*.t t/aggregate/*.t];
66 }
67 else {
68     test_requires('Test::Aggregate', '0.34_01');
69 }
70 my @force_build_requires_if_author = qw(
71   Test::NoTabs
72   Test::Pod
73   Test::Pod::Coverage
74   Pod::Coverage
75 );
76
77 if ($Module::Install::AUTHOR) {
78     foreach my $module (@force_build_requires_if_author) {
79         build_requires $module;
80     }
81     darwin_check_no_resource_forks();
82 }
83
84 install_script glob('script/*.pl');
85 auto_install;
86 WriteAll;
87
88 if ($Module::Install::AUTHOR) {
89
90   # Strip out the author only build_requires from META.yml
91   # Need to do this _after_ WriteAll else it looses track of them
92   strip_build_requires(@force_build_requires_if_author);
93
94   # Strip out any conflicts, so that even if the author has a conflicting
95   # module installed, we don't end up with META.fail
96   strip_requires(keys %conflicts);
97
98   Meta->{values}{resources} = [
99     [ 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst' ],
100     [ 'IRC'         => 'irc://irc.perl.org/#catalyst' ],
101     [ 'license',    => 'http://dev.perl.org/licenses/' ],
102     [ 'homepage',   => 'http://dev.catalyst.perl.org/'],
103     [ 'repository', => 'http://dev.catalyst.perl.org/repos/Catalyst/Catalyst-Runtime/' ],
104   ];
105
106   Meta->write;
107 }
108
109 print <<"EOF";
110
111  Important:
112
113     This library is for running Catalyst applications.
114
115     For development and use of catalyst.pl and myapp_create.pl, make sure
116     you also install the development tools package Catalyst::Devel.
117
118         perl -MCPANPLUS -e 'install Catalyst::Devel' # or
119         perl -MCPAN -e 'install Catalyst::Devel'
120
121     To get some commonly used plugins, as well as the TT view and DBIC 
122     model, install Task::Catalyst in the same way.
123
124  Have fun!
125 EOF
126
127 # End of script, helper functions below.
128
129 sub darwin_check_no_resource_forks {
130     if ($^O eq 'darwin') {
131         my $osx_ver = `/usr/bin/sw_vers -productVersion`;
132         chomp $osx_ver;
133
134         # TAR on 10.4 wants COPY_EXTENDED_ATTRIBUTES_DISABLE
135         # On 10.5 (Leopard) it wants COPYFILE_DISABLE
136         my $attr = $osx_ver eq '10.5' ? 'COPYFILE_DISABLE' : 'COPY_EXTENDED_ATTRIBUTES_DISABLE';
137
138         makemaker_args(dist => { PREOP => qq{\@if [ "\$\$$attr" != "true" ]; then}.
139                                           qq{ echo "You must set the ENV variable $attr to true,"; }.
140                                           ' echo "to avoid getting resource forks in your dist."; exit 255; fi' });
141         }
142 }
143
144 sub strip_build_requires {
145     _strip_a_requires('build_requires', @_);
146 }
147 sub strip_requires {
148     _strip_a_requires('requires', @_);
149 }
150 sub _strip_a_requires {
151     my ($type, @to_strip) = @_;
152     Meta->{values}{$type} = [ grep {
153       my $ok = 1;
154       foreach my $module (@to_strip) {
155         if ($_->[0] =~ /$module/) {
156           $ok = 0;
157           last;
158         }
159       }
160       $ok;
161     } @{Meta->{values}{$type}} ];
162 }
163
164 sub check_conflicts {
165     my %conflicts = @_;
166
167     my %conflicts_found;
168     for my $mod ( sort keys %conflicts ) {
169         eval "require($mod)";
170         next if $@;
171
172         my $installed = $mod->VERSION();
173         $conflicts_found{$mod} = $installed
174             if ( $installed lt $conflicts{$mod} );
175     }
176
177     return unless scalar keys %conflicts_found;
178
179     print <<"EOF";
180
181  WARNING:
182
183     This version of Catalyst conflicts with the versions of
184     some components you have installed.
185
186     You will need to upgrade these modules after installing
187     this version of Catalyst.
188
189     List of the conflicting components and their installed versions:
190
191 EOF
192
193     foreach my $mod (keys %conflicts_found) {
194         print sprintf("    %s => %s\n", $mod, $conflicts_found{$mod});
195     }
196     print "\n\n";
197     return unless prompt("Would you like to upgrade these modules as part of this install?", 'N') =~ /Y/i;
198
199     foreach my $mod (keys %conflicts_found) {
200         requires($mod, $conflicts{$mod})
201             if prompt("Install $mod?", 'Y') =~ /Y/i;
202     }
203 }