Module...:Plugin(3pm)
β¨ Module...:Plugin β¨
okay bestie, gather round π this is the base class for Module::Package plugins β the manual name is Module...:Plugin(3pm), and it lives in the Perl user-contributed docs. It's not a tool you run, it's a tool you become. Slay.
πΈ SYNOPSIS πΈ
package Module::Package::Name;
package Module::Package::Name::flavor;
use Moo;
extends 'Module::Package::Plugin';
sub main {
my ($self) = @_;
$self->mi->some_module_install_author_plugin;
$self->mi->other_author_plugin;
}
1;
π¦ DESCRIPTION π¦
This module is the base class for Module::Package plugins. That's it. That's the whole vibe. It's the parent class everyone else extends. π
π EXAMPLE π
Go peek at the Module::Package::Ingy module β it's a genuinely decent starting-point example, no cap. Fun lil fact: that plugin module is actually used to package Module::Package itself. Iconic self-referential behavior, we love to see it. π₯
π API π
So you wanna make a Module::Package plugin? You need to subclass Module::Package::Plugin, override the main method, and possibly mess with other stuff too. This section is where I explain how all that works, bestie. π«Ά
Makefile.PL processing goes down in exactly this order:
- 'use inc::Module::Package...' is invoked
- $plugin->initial is called
- BEGIN blocks in Makefile.PL are run
- $plugin->main is called
- The body of Makefile.PL is run
- $plugin->final is called
Memorize that sequence. It's the whole plot of the movie. π¬
π« initial
This method gets called while 'use inc::Module::Package' is being processed. You probably don't need to subclass it. But if you do? You probably wanna call the SUPER method, fr fr.
It runs the deps_list (if there is one) and guesses the primary modules file path. Lowkey doing a lot for a method nobody's supposed to touch. π
π₯ main
This is the method you MUST override. Do all the things. Every single thing you want. Go off. β¨
You can call all_from if you need to get the sequencing right β otherwise it just gets called by final() anyway. And don't call WriteAll β it gets called automatically inside final(). Not me warning you twice. π
π final
This does all the things after the entire Makefile.PL body has finished running. You probably don't need to override it. Leave it alone, it's thriving. π
π OPTIONS π
These are the options you can use from inside the Makefile.PL:
use Module::Package 'Foo:bar',
deps_list => 0|1,
install_bin => 0|1,
install_share => 0|1,
manifest_skip => 0|1,
requires_from => 0|1;
Any subclass of this module can use all of these. β¨
π deps_list
Default is 1.
This one tells Module::Package to generate an "author_requires" deps list when you run the Makefile.PL. Where does that list go? Two options, bestie:
- It goes in the file
pkg/deps_list.plif that file exists, or - after a
'__END__'statement in yourMakefile.PL.
And if neither of those is available? You get a warning reminder β but only when the author runs it, so don't panic. π«Ά
Why care? Because this list is important if you want people to be able to collaborate on your modules easily. Teamwork makes the dream work, periodt.
π§ install_bin
Default is 1.
Every file sitting in a "bin/" directory gets installed. It calls the "install_script" plugin for you, so you don't have to. Set this option to 0 to disable it. That's it, that's the option. π
πΈ install_share
Default is 1.
Every file in a "share/" directory gets installed. It calls the "install_share" plugin for you. Set it to 0 to turn it off. Twin behavior with install_bin, honestly. π
β manifest_skip
Default is 1.
This option generates a sane MANIFEST.SKIP for you β and then deletes it again when you run make clean. So clean. So tidy.
Wanna add your own skips? Drop them in the file called pkg/manifest.skip. You almost certainly want this option on. Set it to 0 only if you are weird. π (Their words, not mine. But also... yeah.)
π requires_from
Default is 1.
This option attempts to find all the requirements from the primary module. But heads up: if you make any of your own requires or requires_from calls, this option does nothing. It bows out gracefully. Respect. π
and that's the whole page, bestie π«Ά This was pulled from the Perl docs, perl v5.34.0, dated 2022-06-16, filed under Module...:Plugin(3pm). Go forth and subclass responsibly. πβ¨π
π¦ where this page comes from
- debian bookworm: libmodule-package-perl 0.30-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmodule-package-perl 0.30-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms