top
logo


Home LAMP PHP NetBeans Custom Project License

NetBeans Custom Project License

PDF Print E-mail
(5 votes, average 5.00 out of 5)
Written by Alex Balyuk   
Sunday, 15 August 2010 16:06

Ever wondered how most professionally done projects have nice license block at the top of every source file?

This block is more important than you think. I provides a lot of useful information about the file, where it came from, when, why, and who... This information is very useful and will help you and other developers to understand reasoning behind the file's existence. It would be very annoying to copy and paste license block into every file and modify timestamps for @id property every time you edit the file. This block is generated automatically by an IDE such as NetBeansNetBeans, here is how it is done...

 

  1. Create new empty txt document somewhere on your computer. You can delete this file after Step 5. Name must be in following format license-YourLicenseName.txt
  2. license-boolcast.txt
  3. Run NetBeans IDE and open Template Manager (Tools -> Templates)
    20100815-nb-tools-templates
  4. Select/Highlight Licenses node
    20100815-nb-template-license
  5. Click "Add..." button on the right
  6. In the Open File Dialog find the file created in Step 1 and click "Add". Now you will see this file under Licenses node
  7. Highlight your license file and click "Open in Editor" button
    20100815-nb-license-file-selected
  8. Edit the file to your liking/requirements. Save it and close.
    My license block looks like this:
    /**
     * @version    $Id$
     * @package    BoolCast
     * @copyright  Copyright (C) 2010
     * @license    Proprietary
     */
  9. Open the Project that will be using this license. I will be using PHP project
  10. Open Files window (usually next to Projects). If you do not see Files window, go to Window->Files
  11. Extend nbproject directory and open project.properties
  12. Add new property called project.license and set it to the name of your license file without "license-" prefix
    project.license=boolcast
    20100815-nb-project-properties
  13. Save and Close

Congratulations! You are done. Now every file you create will have your custom license block.

Create a new file, just to double check. New file will look something like this:

20100815-nb-success

Couple of things to note:

  1. Once you add the license file to the NetBeans templates the file is copied to the NetBeans Templates directory. On Linux and Windows the path is pretty much the same
    /User Home/current netbeans directory/config/Templates/Licenses
    In current example the path is
    C:\Users\Alex\.netbeans\6.9\config\Templates\Licenses
  2. The "Duplicate License" button does not work properly and error reading file was displayed instead of license block. This was happening because after duplicating the license license name is not what you named it. For example, lets say you duplicated "license-default" to "license-MyLicense", the file name will be named "license-default_1" and not "license-MyLicense". Workaround is to create an empty file and add it and then edit it, this way name will be preserved
    Error reading included file Templates/Scripting/../Licenses/license-YourLicenseName.txt
  3. $Id$ requires version control property
Last Updated on Monday, 06 September 2010 20:04
 

Add comment


Security code
Refresh



Copyright © 2013 (bool) cast.com. All Rights Reserved.
Joomla!Joomla! is Free Software released under the GNU/GPL License.GNU/GPL License.

bottom
top
Site Map | Contact Us

bottom