This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 211644 - support for more licenses in maven
Summary: support for more licenses in maven
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.1.1
Hardware: All All
: P3 normal (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks: 204221
  Show dependency tree
 
Reported: 2012-04-24 14:08 UTC by Golthiryus
Modified: 2012-09-22 02:19 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Example of EPL license notice template (652 bytes, text/plain)
2012-04-24 18:10 UTC, Jesse Glick
Details
Corresponding attributes (478 bytes, text/plain)
2012-04-24 18:10 UTC, Jesse Glick
Details
LGPL header template (1.10 KB, text/plain)
2012-06-05 07:51 UTC, Golthiryus
Details
LGPL 3.0 header template (1021 bytes, text/plain)
2012-06-05 10:23 UTC, Golthiryus
Details
LGPL 2.1 header template (1.10 KB, text/plain)
2012-06-05 10:24 UTC, Golthiryus
Details
Suggested license-bsd.txt (1.81 KB, text/plain)
2012-09-20 15:23 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Golthiryus 2012-04-24 14:08:06 UTC
When pom.xml defines the project licese (with standard maven element <license>) with some urls, Netbeans Maven Support picks the correct license headers automatically (at least for new Java classes)

It would be great that with other licenses the same thing happen. At present, only the following license urls are accepted.

http://www.apache.org/licenses/LICENSE-2.0.txt
http://www.opensource.org/licenses/mit-license.php
http://www.gnu.org/licenses/gpl-2.0.html
http://www.gnu.org/licenses/gpl-3.0.html
Comment 1 Milos Kleint 2012-04-24 14:20:54 UTC
what license + url combinations are you suggesting?
Comment 2 Golthiryus 2012-04-24 14:50:35 UTC
I was thinking in LGPL license. Maven is great to make libraries ;)
Comment 3 Jesse Glick 2012-04-24 17:24:50 UTC
Actually as a user it is possible to add support for other licenses, though not via the GUI: create the license in Template Manager normally, then edit $userdir/config/Templates/Licenses/.nbattrs and add

        <attr name="mavenLicenseURL" stringvalue="http://..."/>

But of course it would be nice if the most commonly-used licenses were predefined in the IDE - at least LGPL 2.1 and 3.0, and maybe EPL, GPL w/ "Classpath Exception" (cf. OpenJDK), CDDL. And for user expansion it would be nice if Template Manager let you set the URL.

Unfortunately while Maven has a rather strong system of defining artifacts themselves, the structure of license definitions is quite weak; there is no way for repositories to standardize on particular license names or URLs. http://opensource.org/licenses/alphabetical has the most authoritative list of (FLOSS) licenses, though not formatted well for machine use (no "raw mode" URLs that I know of).
Comment 4 Jesse Glick 2012-04-24 18:10:05 UTC
Created attachment 118704 [details]
Example of EPL license notice template
Comment 5 Jesse Glick 2012-04-24 18:10:29 UTC
Created attachment 118705 [details]
Corresponding attributes
Comment 6 Jesse Glick 2012-04-24 18:15:55 UTC
(In reply to comment #3)
> it would be nice if Template Manager let you set the URL

As of core-main #e158741ebfd5 you can select the Properties menu item on the newly created template (*) and edit the new "License URL" property.

Still I think it would be good for more common licenses to be included out of the box.

(*) Which must be named "license-SOMETHING", where "SOMETHING" would also be the value of ${project.license} for an Ant-based project. Otherwise you get an exception, reduced to warning in core-main #7196660695be.
Comment 7 Milos Kleint 2012-04-25 05:17:33 UTC
(In reply to comment #6)
> (In reply to comment #3)
> > it would be nice if Template Manager let you set the URL
> 
> Still I think it would be good for more common licenses to be included out of
> the box.
> 

The main challenge was always to know what the header template should look like and what url should be associated with it.
Comment 8 Golthiryus 2012-04-25 07:37:16 UTC
Standard Netbeans way to add licenses (Templates) are really bad to work in a team. Netbeans Maven Support way is better in this case, but is not "editable", ie, it is limited to a small set of licenses.

On the other hand, maven-license-plugin works really well.
Comment 9 Milos Kleint 2012-04-25 08:05:51 UTC
unfortunately we cannot simply reuse external license templates. it needs to be in freemarker format and in a way that supports adding the license header to other files than java files, eg. .properties or .xml files as wel..
Comment 10 Golthiryus 2012-04-25 09:20:34 UTC
@Milos I do not understand you. Translate the header of a license should be (in theory) fast and easy. If I may ask... How it was done with the other four?

I understand that is not a priority. If I can help with something (for example by adapting the headers) let me know.
Comment 11 Milos Kleint 2012-04-25 10:01:27 UTC
(In reply to comment #10)
> @Milos I do not understand you. Translate the header of a license should be (in
> theory) fast and easy. If I may ask... How it was done with the other four?

you need the canonical header (which is not equal to the license text and in some cases is hard to come by) and you need to add the processing expressions like:

<#if licenseFirst??>
${licenseFirst}
</#if>
${licensePrefix}

and then pick the canonical url that will most likely be used most users.. We also have a property "netbeans.hint.license" that can contain the license name (ideally in the parent pom). So the url is not really critical, having the right license template is.

And as you mentioned it's still suboptimal as one needs to add the license template to each and every developer's IDE installation.


> 
> I understand that is not a priority. If I can help with something (for example
> by adapting the headers) let me know.

sure, that would help a lot.
Comment 12 Golthiryus 2012-04-25 10:17:22 UTC
So I understand that when pom url license is GPL2, GPL3, MIT or Apache (which are supported by default by Netbeans), Maven Support uses Netbeans builtin template, so to support new licenses in Netbeans Maven Support is necessary that this licenses were supported by Netbeans before.

All right. When I have some time I will look for some license headers to adapt them to Netbeans Templates.
Comment 13 Jesse Glick 2012-04-25 16:12:55 UTC
Golthiryus, just look at the two attachments I produced for EPL - this should give you the idea of the required format, especially available FreeMarker variables.


The license header templates could probably use some further tweaking, BTW. For example, I noticed that in the Sonatype Aether case, the organization name "Sonatype, Inc." is substituted nicely in the "Contributors" section but looks ugly in the "Copyright" section:

/* Copyright (c) 2012 Sonatype, Inc..
                                   ^^

Presumably the template could be a little smarter and check for a trailing '.' in this case.


(In reply to comment #12)
> when pom url license is GPL2, GPL3, MIT or Apache (which
> are supported by default by Netbeans), Maven Support uses Netbeans builtin
> template

Generally, when creating a new file in a Maven project, the IDE first checks for ${netbeans.hint.license} among POM properties, including inherited ones. (For Ant-based projects, it would look for ${project.license} among Ant property definitions.) If Templates/Licenses/license-NAME.txt exists (whether a built-in license header, or a user-defined one), then that is processed with FreeMarker and inserted into the new file (*).

Else, if the POM (or again a parent POM acc. to usual model inheritance) specifies /project/license/url and there is a Templates/Licenses/license-*.txt with a matching mavenLicenseURL property (as editable in Template Manager after my recent fix, and defined for the built-in license headers), then that header is used.

Otherwise, the default placeholder header is used.


(*) Assuming the file template requests a license header, e.g.:

<#assign licenseFirst = "/*">
<#assign licensePrefix = " * ">
<#assign licenseLast = " */">
<#include "../Licenses/license-${project.license}.txt">
Comment 14 Jesse Glick 2012-04-25 16:15:05 UTC
BTW maven/src/org/netbeans/modules/maven/layer.xml is the location in NetBeans sources where most of the built-in licenses are defined. (There is the placeholder fallback license elsewhere, and apisupport.project defines CDDL+GPL2/CP used for NetBeans sources.)
Comment 15 Golthiryus 2012-04-26 07:55:37 UTC
Thanks for the info. I can not do anything until next Thursday, but I keep in mind.
Comment 16 Quality Engineering 2012-04-26 10:38:31 UTC
Integrated into 'main-golden', will be available in build *201204260400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/7196660695be
User: Jesse Glick <jglick@netbeans.org>
Log: SIOOBE encountered while experimenting with #211644.
Comment 17 Golthiryus 2012-06-05 07:51:38 UTC
Created attachment 120358 [details]
LGPL header template

This could be an LGPL3 example.
Comment 18 Golthiryus 2012-06-05 07:54:21 UTC
(In reply to comment #17)
> Created attachment 120358 [details]
> LGPL header template
> 
> This could be an LGPL3 example.

And url that identifies this license should be http://www.gnu.org/licenses/lgpl-3.0.html
Comment 19 Milos Kleint 2012-06-05 09:30:22 UTC
(In reply to comment #18)
> (In reply to comment #17)
> > Created attachment 120358 [details]
> > LGPL header template
> > 
> > This could be an LGPL3 example.
> 
> And url that identifies this license should be
> http://www.gnu.org/licenses/lgpl-3.0.html

add the the LGPL and EPL license templates to the IDE. However the LGPL is apparently version 2.1, not 3.0. (The header text is exactly the same as the one stated on http://www.gnu.org/licenses/lgpl-2.1.html
Comment 20 Golthiryus 2012-06-05 10:23:26 UTC
Created attachment 120364 [details]
LGPL 3.0 header template

I didn't find an oficial version of that header in GNU webpage, so I mixed LGPL2.1 header license with GPL 3.0 header license
Comment 21 Golthiryus 2012-06-05 10:24:18 UTC
Created attachment 120365 [details]
LGPL 2.1 header template
Comment 22 Quality Engineering 2012-06-06 05:54:55 UTC
Integrated into 'main-golden', will be available in build *201206060001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/ddf3127713e7
User: Milos Kleint <mkleint@netbeans.org>
Log: #211644 lgpl3.0 license header template - contributed by Golthiryus@netbeans.org
Comment 23 Jesse Glick 2012-09-20 15:23:42 UTC
Created attachment 124657 [details]
Suggested license-bsd.txt

displayName: BSD 2-Clause License
mavenLicenseURL: http://opensource.org/licenses/bsd-license.php
Comment 24 Milos Kleint 2012-09-21 11:17:31 UTC
bsd - http://hg.netbeans.org/core-main/rev/be5352f5944d

let's just consider this fixed, please file a separate issue for each template missing.
Comment 25 Jesse Glick 2012-09-21 13:07:38 UTC
Thanks.

BTW "General Public Licence 3.0" is spelled UK fashion whereas http://www.gnu.org/licenses/gpl-3.0.html as an American site uses "Licen_s_e".
Comment 26 Quality Engineering 2012-09-22 02:19:19 UTC
Integrated into 'main-golden', will be available in build *201209220001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/be5352f5944d
User: Milos Kleint <mkleint@netbeans.org>
Log: #211644 bsd license added