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