- Fixes for rt.cpan #17322 and #17331
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Build.pm
CommitLineData
10d487cb 1package Catalyst::Build;
2
3use strict;
4use Module::Build;
10d487cb 5use Path::Class;
6use File::Find 'find';
7
4a5e0a98 8our @ISA;
2e87863e 9eval "require Module::Build";
10die "Please install Module::Build\n" if $@;
11push @ISA, 'Module::Build';
12
10d487cb 13our @ignore =
14 qw/Build Build.PL Changes MANIFEST META.yml Makefile.PL Makefile README
15 _build blib lib script t/;
16
17our $FAKE;
18our $ignore = '^(' . join( '|', @ignore ) . ')$';
19
20=head1 NAME
21
22Catalyst::Build - Module::Build extension for Catalyst
23
24=head1 SYNOPSIS
25
26See L<Catalyst>
27
28=head1 DESCRIPTION
29
30L<Module::Build> extension for Catalyst.
31
32=head1 DEPRECATION NOTICE
33
34This module is deprecated in favor of L<Module::Install::Catalyst>.
35
36=head1 METHODS
37
38=over 4
39
7fb8754a 40=item new
10d487cb 41
42=cut
43
44sub new {
45 my $class = shift;
2e87863e 46 my $self = $class->SUPER::new(@_);
10d487cb 47
48 my $app_name = $self->{properties}{module_name};
49 warn <<"EOF";
50
51 Note:
52
53 The use of Build.PL for building and distributing Catalyst
54 applications is deprecated in Catalyst 5.58.
55
56 We recommend using the new Module::Install-based Makefile
57 system. You can generate a new Makefile.PL for your application
58 by running:
59
60 catalyst.pl -force -makefile $app_name
61
62EOF
63
64 return $self;
65}
66
7fb8754a 67=item ACTION_install
68
69=cut
70
10d487cb 71sub ACTION_install {
72 my $self = shift;
73 $self->SUPER::ACTION_install;
74 $self->ACTION_install_extras;
75}
76
77=item ACTION_fakeinstall
78
79=cut
80
81sub ACTION_fakeinstall {
82 my $self = shift;
83 $self->SUPER::ACTION_fakeinstall;
84 local $FAKE = 1;
85 $self->ACTION_install_extras;
86}
87
88=item ACTION_install_extras
89
90=cut
91
92sub ACTION_install_extras {
93 my $self = shift;
94 my $prefix = $self->{properties}{destdir} || undef;
95 my $sitelib = $self->install_destination('lib');
96 my @path = defined $prefix ? ( $prefix, $sitelib ) : ($sitelib);
97 my $path = dir( @path, split( '::', $self->{properties}{module_name} ) );
98 my @files = $self->_find_extras;
99 print "Installing extras to $path\n";
100 for (@files) {
101 $FAKE
102 ? print "$_ -> $path (FAKE)\n"
103 : $self->copy_if_modified( $_, $path );
104 }
105}
106
107sub _find_extras {
108 my $self = shift;
109 my @all = glob '*';
110 my @files;
111 for my $file (@all) {
112 next if $file =~ /$ignore/;
113 if ( -d $file ) {
114 find(
115 sub {
116 return if -d;
117 push @files, $File::Find::name;
118 },
119 $file
120 );
121 }
122 else { push @files, $file }
123 }
124 return @files;
125}
126
127=back
128
129=head1 AUTHOR
130
131Sebastian Riedel, C<sri@oook.de>
132
133=head1 LICENSE
134
135This library is free software, you can redistribute it and/or modify it under
136the same terms as Perl itself.
137
138=cut
139
1401;