Sam's Blog

Setting your repository in META.yml with Module::Build

Date: Thursday, 3 January 2013, 14:49.

Categories: perl, ironman, module-authoring, module-build.

I've apparently had this blog sat in my out-bound queue since September 2010 and completely forgot to publish it. Meanwhile over on Perl 5 Maven, Gabor Szabo has raised the subject with his "How to convince Meta CPAN to show a link to the version control system of a distribution?" article.

Edit: turns out I'd left it unpublished for a reason, the sample code was actually broken. Just go and read Gabor's article instead - and thank him for testing my broken code! I've removed the broken code from the article below.

Whilst I was making some changes to Template::Sandbox and Template::Benchmark as part of my move to using git and GitHub, I noticed that there wasn't any documentation on how to set your source code respository for the META.yml when using Module::Build.

I thought a quick how-to would be handy.

Simple URI Case

If you just have a simple URI for your repository, you'll want to add this to the Module::Build constructor in your Build.PL:

    meta_merge => {
        'resources' => {
            'repository' => 'http://github.com/illusori/Perl-Template-Benchmark',
            },
        },

This should give you a a Build.PL looking something like:

#!/usr/bin/perl -w

use strict;
use warnings;

use Module::Build;

my $build = Module::Build->new(
    module_name  => 'Template::Sandbox',
    license      => 'perl',
    dist_author  => 'BLAH BLAH BLAH',
    build_requires => {
        },
    requires => {
        },
    recommends => {
        },
    meta_merge => {
        'resources' => {
            'repository' => 'http://github.com/illusori/Perl-Template-Sandbox',
            },
        },
    sign => 1,
    dynamic_config => 0,
    );
$build->create_build_script;

I'm not sure how many tools make use of this information, but at the very least search.cpan.org parses the information and displays it nicely as part of the distribution meta-information on the distro's main page.

Browse Sam's Blog Subscribe to Sam's Blog

By day of January: 03.

By month of 2013: January.

By year: 2010, 2011, 2012, 2013.

Or by: category or series.

Comments

blog comments powered by Disqus
© 2009-2013 Sam Graham, unless otherwise noted. All rights reserved.