Added COMPONENT() and ACCEPT_CONTEXT() support
[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
40=item ACTION_install
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
67sub ACTION_install {
68 my $self = shift;
69 $self->SUPER::ACTION_install;
70 $self->ACTION_install_extras;
71}
72
73=item ACTION_fakeinstall
74
75=cut
76
77sub ACTION_fakeinstall {
78 my $self = shift;
79 $self->SUPER::ACTION_fakeinstall;
80 local $FAKE = 1;
81 $self->ACTION_install_extras;
82}
83
84=item ACTION_install_extras
85
86=cut
87
88sub ACTION_install_extras {
89 my $self = shift;
90 my $prefix = $self->{properties}{destdir} || undef;
91 my $sitelib = $self->install_destination('lib');
92 my @path = defined $prefix ? ( $prefix, $sitelib ) : ($sitelib);
93 my $path = dir( @path, split( '::', $self->{properties}{module_name} ) );
94 my @files = $self->_find_extras;
95 print "Installing extras to $path\n";
96 for (@files) {
97 $FAKE
98 ? print "$_ -> $path (FAKE)\n"
99 : $self->copy_if_modified( $_, $path );
100 }
101}
102
103sub _find_extras {
104 my $self = shift;
105 my @all = glob '*';
106 my @files;
107 for my $file (@all) {
108 next if $file =~ /$ignore/;
109 if ( -d $file ) {
110 find(
111 sub {
112 return if -d;
113 push @files, $File::Find::name;
114 },
115 $file
116 );
117 }
118 else { push @files, $file }
119 }
120 return @files;
121}
122
123=back
124
125=head1 AUTHOR
126
127Sebastian Riedel, C<sri@oook.de>
128
129=head1 LICENSE
130
131This library is free software, you can redistribute it and/or modify it under
132the same terms as Perl itself.
133
134=cut
135
1361;