Netbeans Platform Branding and version info

August 6th, 2007 | by Tonny Kohar |

By default Netbeans Platform based application automatically insert the version information by using the platform build number (the first or last 4 digits, correct me if I am wrong). And currently there is no easy ways to set or update this version info, unless you want to dig through the branding folder and change the value manually.

Fortunately, the flexibility of Netbeans IDE (ant based build system) allow us to automate this stuff. Below is how I automate it

  • in the project properties add the the following properties eg:
    app.version=5.0
  • in your build xml add the following
    <!-- override build to add update branding -->
    <target name="build" depends="build-brand,suite.build"/>
     
    <target name="build-brand" depends="-init">
        <propertyfile
            file="${basedir}/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties" 
            comment="Updated by build script">
            <entry key="currentVersion" value="${app.title} ${app.version} " />
        </propertyfile>
     
        <propertyfile
            file="${basedir}/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties"
            comment="Updated by build script">
            <entry key="CTL_MainWindow_Title" value="${app.title} ${app.version}" />
            <entry key="CTL_MainWindow_Title_No_Project" value="${app.title} ${app.version}" />
        </propertyfile>
     
        <propertyfile
            file="${basedir}/branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties" 
            comment="Updated by build script">
            <entry key="LBL_ProductInformation" value="${app.title}" />
        </propertyfile>
     
    </target>

Finish, so everytime you do build, it automatically update the version info using whatever value your put in your projects properties.

Note: Tested on Netbeans 5.5.1 and 6.0M10

Tags: , , ,

  1. 17 Responses to “Netbeans Platform Branding and version info”

  2. By emilio on Aug 21, 2007 | Reply

    Good! I’ve a question. How branding standard menu item? (I’d like see “Salva” and not “Save”)
    thank!

  3. By Tonny Kohar on Aug 21, 2007 | Reply

    To make “Salva” instead of “Save”, you need to localize/internatiolize the Netbeans Platform. Please see this other blog entry, I write about localize Netbeans Platform default menu at http://blogs.kiyut.com/tonny/index.php/2007/08/04/netbeans-platform-i18n-and-localization/

    Basically just
    1) edit layer.xml file (menu section), to add pointer to your bundle properties
    2) edit/create the bundle_xx.properties to add your localized menu text

  4. By krishna on Dec 27, 2007 | Reply

    Can you Please Provide more information with detailed steps on how to achieve the same?

    Thanks in advance

  5. By johnny on Dec 31, 2008 | Reply

    IzFSUg Thanks for good post

  6. By ibtisamhoe0676 on Jan 4, 2009 | Reply

    Hello, you have a great blog here! I’m definitely going to bookmark you!

  7. By afanasiysheldonht67 on Jan 4, 2009 | Reply

    Hey, you have a great blog here! I’m definitely going to bookmark you!

  8. By annangracie1981 on Jan 4, 2009 | Reply

    Hey, you have a great blog here! I’m definitely going to bookmark you!

  9. By tegandougall1988 on Jan 8, 2009 | Reply

    Great information on your blog!

  10. By Nicolas Dumoulin on Jan 30, 2009 | Reply

    Thanks for this tip, but it has a bad point : it modifies existing files that could be committed on a VCS.
    I’ve adopted an other solution : I rename targetted properties files to Bundle_template.properties. And in the ant target, I copy these files and apply propertyfile tasks. I ignore generated Bundle.properties for the VCS. So if I update my app update, I only commit the project properties file.

    Thanks again

  11. By silhanek on Feb 25, 2009 | Reply

    Change for NBP 6.5 :

    last jar is not

    file=”${basedir}/branding/modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties”
    but

    file=”${basedir}/branding/core/core.jar/org/netbeans/core/startup/Bundle.properties”

  12. By Tonny Kohar on Feb 25, 2009 | Reply

    @silhanek

    Thanks for the updated info regarding NBP 6.5

  13. By Scott on Jun 17, 2009 | Reply

    I am having issues with the second jar:
    file=”${basedir}/branding/modules/org-netbeans-core-windows.jar/org/netbeans/core/windows/view/ui/Bundle.properties”

    I am using 6.5.1 and it can’t find the file. I do however have the jar:
    file=”${basedir}/branding/modules/org-netbeans-core-windows.jar/windows/view/ui/Bundle.properties”
    that have those key/value that are going to be updating. Is it safe to assume that this is the correct jar and properties file to update?

  14. By Scott on Jun 18, 2009 | Reply

    Please excuse my previous comment. I had somehow messed up my folder structure.

    Thanks for all your helpful blogs!

  15. By Eric on Jul 3, 2009 | Reply

    Thanks for the solution. It works great. I am now able to set my version to the current time stamp by doing the following:
    1. make build-brand depend on “pre-init,-init”
    2. define pre-init to take the current timestamp and shove it into app.version

    works great, thanks!

    Eric

  16. By Eric on Jul 3, 2009 | Reply

    I tried to attach the target to my above comment, but it got trimmed out… I will try with entity references, if that fails, then I am sorry… I tried to show you what I meant by that pre-init target.

    <target name=”pre-init”>
        <tstamp prefix=”build”/>
        <propertyfile file=”${basedir}/nbproject/project.properties”
            comment=”Updated by build script”>
            <entry key=”app.version” value=”${build.DSTAMP}.${build.TSTAMP}/>
        </propertyfile>
    </target>

    edited note: I edited the ant script to use <pre lang=”xml”>….</pre> to format the things 🙂

  17. By Tonny Kohar on Jul 3, 2009 | Reply

    @Eric

    Yes it is a nice tips and trick, and could help other.
    And you can always use <pre lang=”xml|java|etc”>…</pre> to format the things

  1. 1 Trackback(s)

  2. Nov 11, 2010: NetBeans Platform – how to customize the title bar and remove datestamp « Developmentality

You must be logged in to post a comment.