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 239582

Summary: License Changer doesn't recognize project.displayName template variable
Product: contrib Reporter: err <err>
Component: License ChangerAssignee: nhoffmann
Status: RESOLVED FIXED    
Severity: normal CC: tboudreau
Priority: P2    
Version: 7.4   
Hardware: PC   
OS: Windows XP   
Issue Type: DEFECT Exception Reporter:

Description err 2013-12-17 23:10:37 UTC
I've defined license text which contains the line

    ${licensePrefix}This file is part of ${project.displayName}.

when I get to the last step of LicenceChanger, the preview has

     * This file is part of Expression project.displayName \
       is undefined on line 6, column 40 in unknown..

I tried adding the variable definition to user.properties, no difference.

BTW, creating a new class properly expands that template variable.

The variable is documented at http://wiki.netbeans.org/FaqTemplateVariables
Comment 1 nhoffmann 2013-12-18 08:48:00 UTC
Thank you for spotting this. The next version of the LicenseChanger will 
support the ${project.name} and ${project.displayName} variables for interpolation.

However, ${name}, ${nameAndExt},${encoding}, ${time} and ${date} will not be included since their use in license headers is questionable. These should better be included in a custom file template. The LicenseChanger will respect existing comments and class-level javadoc and inserts the license header before those.
Comment 2 err 2013-12-18 16:20:35 UTC
(In reply to nhoffmann from comment #1)
> However, ${name}, ${nameAndExt},${encoding}, ${time} and ${date} will not be
> included since their use in license headers is questionable.

I understand all of these except ${date}. It looks like all of the license headers have

    Copyright (C) ${date?date?string("yyyy")}

and the lines usually contain ${licensePrefix} and some variant of ${user}. How would license changer handle this, if ${date} is not interpolated? (I can see how you wouldn't want to change the date, just because you change the license, but...)

Some license headers have
    ${project.organization!user}
as part of the Copyright line. I just checked FreeMarker site and found out what "!" does. I don't see project.organization in the template variable FAQ. Is it, or should it, be handled?
Comment 3 err 2013-12-18 16:59:50 UTC
In licensechanger source I see Project and getOrganization.

I couldn't find any FreeMarker stuff, but I just saw javax.script (which I didn't know about). I can see it would take a while to dig through this...
Comment 4 nhoffmann 2013-12-20 08:18:14 UTC
(In reply to err from comment #2)
> (In reply to nhoffmann from comment #1)
> > However, ${name}, ${nameAndExt},${encoding}, ${time} and ${date} will not be
> > included since their use in license headers is questionable.
On second thoughts, I will include those in the next version. I agree that users would expect the default variables to be available in License Changer as well.

'name', 'nameAndExt', and 'encoding' will be set individually for each processed file.

Date and Time will be set to the same initial date for all changed files and will be date objects, so you will be able to format them with the 'string(...)' directive from freemarker:

http://freemarker.org/docs/ref_builtins_date.html

> 
> I understand all of these except ${date}. It looks like all of the license
> headers have
> 
>     Copyright (C) ${date?date?string("yyyy")}
> 
> and the lines usually contain ${licensePrefix} and some variant of ${user}.
> How would license changer handle this, if ${date} is not interpolated? (I
> can see how you wouldn't want to change the date, just because you change
> the license, but...)
> 
> Some license headers have
>     ${project.organization!user}
> as part of the Copyright line. I just checked FreeMarker site and found out
> what "!" does. I don't see project.organization in the template variable
> FAQ. Is it, or should it, be handled?

This property is set via the Copyright Holder dialog on the first panel of the wizard. You can add simply add it to your user.properties in case your project's copyright is not held by an individual.
Comment 5 nhoffmann 2014-01-13 13:31:32 UTC
Fixed in changeset http://hg.netbeans.org/main/contrib/rev/5e27d570de18.
Comment 6 err 2014-01-13 18:06:25 UTC
I'm wondering if you intended to change the 'number of spaces per indent' from 4 to 8 when you made these changes? Or maybe it was some other setting about indent? This change and the one for Bug 239631 have this issue.

Anyway, just to bring it to your attention.