forked from szabgab/perlmaven.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhow-to-add-the-license-field-to-meta-files-on-cpan.tt
More file actions
88 lines (59 loc) · 3.01 KB
/
how-to-add-the-license-field-to-meta-files-on-cpan.tt
File metadata and controls
88 lines (59 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
=title How to add the license field to the META.yml and META.json files on CPAN?
=timestamp 2012-12-28T16:45:56
=indexes license, Perl, Perl 5, CPAN, META, ExtUtils::MakeMaker, Module::Build, Module::Install, Dist::Zilla, CPAN::Meta::Spec
=status show
=author szabgab
=index 1
=archive 1
=feed 1
=comments 1
=social 1
=abstract start
Every distribution on CPAN can include a META.yml and a META.json file.
They should hold the same information, META.json is just the newer format.
So you'll find a lot more distributions with only META.yml and you'll find
a few, probably very old distribution with no META file at all.
The META files can both have a field indicating the <b>license</b> of the distribution.
Having the license information in the META files makes it very easy for automated tools
to check if a set of modules have a certain set of licenses.
=abstract end
As the META files are usually generated automatically when the distribution is released
by the author, I am going to show you how you can tell the 4 main packaging systems
to include the license field.
In the examples I'll use the most common, so called, <b>Perl</b> license:
<h2>ExtUtils::MakeMaker</h2>
If you are using <a href="https://metacpan.org/module/ExtUtils::MakeMaker">ExtUtils::MakeMaker</a> add the following to your Makefile.PL
as parameter in the <b>WriteMakefile</b> function:
<code lang="perl">
'LICENSE' => 'perl',
</code>
If you want to make sure older versions of ExtUtils::MakeMaker won't give warnings on
unknown LICENSE field, you can use the following code:
<code lang="perl">
($ExtUtils::MakeMaker::VERSION >= 6.3002 ? ('LICENSE' => 'perl', ) : ()),
</code>
<a href="http://search.cpan.org/src/NWCLARK/perl-5.8.8/lib/ExtUtils/MakeMaker.pm">The version distributed with perl 5.8.8 is 6.30</a>
thus it does not yet contain this feature. The best if you could upgrade ExtUtils::MakeMaker.
<h2>Module::Build</h2>
If you are using <a href="https://metacpan.org/module/Module::Build">Module::Build</a>, add the following to Build.PL,
in the Module::Build->new call:
<code lang="perl">
license => 'perl',
</code>
<h2>Module::Install</h2>
If you are using <a href="https://metacpan.org/module/Module::Install">Module::Install</a> add the following to Makefile.PL:
<code lang="perl">
license 'perl';
</code>
<h2>Dist::Zilla</h2>
If you are using <a href="http://dzil.org/">Dist::Zilla</a>, just add the following entry to the dist.ini file:
<code lang="perl">
license = Perl_5
</code>
<h2>META specification</h2>
In order to check the current list of valid options for the license field,
check the <a href="https://metacpan.org/module/CPAN::Meta::Spec">CPAN::Meta specification</a>.
<h2>Copyright and Licensing</h2>
According to the <a href="http://www.perlfoundation.org/cpan_licensing_guidelines">CPAN Licensing Guidelines</a>
of The Perl Foundation, it is <b>required</b> to have the license information in the META files.
There are of course other required elements of the licensing. This article only focuses on the entry in the META files.