I have added:
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
to my pom file and the Apache license neatly appears in each new source file I create. However, the license text appears as:
/*
* Copyright 2013 MyUserName.
*
* Licensed under the Apache License, Version 2.0 (the "License");
...
*/
I want it to be
/*
* Copyright 2013 OldCurmudgeon <--- Note the new name.
*
* Licensed under the Apache License, Version 2.0 (the "License");
...
*/
this field looks like it comes from a {user}
property, or so the template suggests. Is there any way I can change that on a per-project basis?
The answer after some experimenting with the offered options below.
I was right about the pom file change.
I chose the Apache-2.0 License. You will obviously need to make adjustments for your choice of license.
Add to your pom file:
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>
Change the Java templates (Tools/Templates/Java/Java Class(and any others as you wish)/Open In Editor(button)):
Change:
...
* @author ${user}
...
to
...
* @author ${project.property.user}
...
Then change the license file (Tools/Templates/Licences/The license you chose/Open In Editor(button)):
...
${licensePrefix}Copyright ${date?date?string("yyyy")} ${project.organization!user}.
...
to
...
${licensePrefix}Copyright ${date?date?string("yyyy")} ${project.property.user}.
...
Then add to your pom file:
<properties>
<!-- For the License -->
<user>OldCurmudgeon</user>
</properties>
And you're done. Shame I had to change the license file. Perhaps in a later release of NetBeans this won't be necessary.