Archive

Posts Tagged ‘netbeans’

Version from git in a Netbeans Platform application

April 8, 2013 Leave a comment

To set the main window and about version of your Netbeans Platform application, redefine the branding target in your suite build.xml file, this way:

<target name="branding" depends="suite.branding">
    <exec executable="git" failifexecutionfails="false" logError="true" outputproperty="app.git.version">
        <arg line="describe --tags --always"/>
    </exec>
    <tstamp>
        <format property="app.git.version" pattern="yyyyMMddHHmmss"/>
    </tstamp>           
    <tempfile property="temp.dir"/>
    <unjar src="${cluster}/modules/locale/org-netbeans-core-windows_${branding.token}.jar" dest="${temp.dir}">
        <patternset>
            <include name="org/netbeans/core/windows/view/ui/Bundle_${branding.token}.properties"/>
        </patternset>
    </unjar>
    <propertyfile file="${temp.dir}/org/netbeans/core/windows/view/ui/Bundle_${branding.token}.properties">
        <entry  key="CTL_MainWindow_Title_No_Project" value="Schematic ${app.git.version}"/>
    </propertyfile>
    <jar jarfile="${cluster}/modules/locale/org-netbeans-core-windows_${branding.token}.jar" update="true" basedir="${temp.dir}"/>
    <delete dir="${temp.dir}"/>
    <unjar src="${cluster}/core/locale/core_${branding.token}.jar" dest="${temp.dir}">
        <patternset>
            <include name="org/netbeans/core/startup/Bundle_${branding.token}.properties"/>
        </patternset>
    </unjar>
    <propertyfile file="${temp.dir}/org/netbeans/core/startup/Bundle_${branding.token}.properties">
        <entry  key="currentVersion" value="Schematic ${app.git.version}"/>
    </propertyfile>
    <jar jarfile="${cluster}/core/locale/core_${branding.token}.jar" update="true" basedir="${temp.dir}"/>
    <delete dir="${temp.dir}"/>
</target>
Advertisements
Tags: ,

Mercurial vs Git performance

April 11, 2011 Leave a comment

I’ve just converted Netbeans/main Mercurial repository to Git using fast-export:

git clone http://repo.or.cz/r/fast-export.git
mkdir netbeans-git
cd netbeans-git
git init
~/fast-export/hg-fast-export.sh -r ~/netbeans-hg

The conversion lasts more than 24h. Using Python cProfile I’ve found that all measurable time was spent into the patch extraction of Mercurial. I did not investigate more but here are 2 hypothesis:

  • Mercurial is not designed to work on large source tree.
  • fast-export is not using Mercurial in the most efficient way.

Having such huge repositories in both Mercurial and Git is a good opportunity to measure how much Mercurial is slower than Git. For the following tests, I’m using Git 1.7.4.1 and Mercurial 1.7.5. I chose two commands:

  • status which shows how the tool scale with large source tree.
  • log which shows how the tool scale with a large number of commit.

The Netbeans/main repository repository contains more than 190000 commits and the current source tree contains 90519 files.
Read more…

May be python is easier than find+awk

June 9, 2010 1 comment

In Netbeans platform icons are displayed in the toolbar editor only if the underlying action have the iconBase property defined. I had more than hundred action to change when I found this bug/limitation. So I needed to add:

putValue("iconBase","org/foobar");

in all action constructors. I first tried with a find+awk/sed combo without any success. Here is the python script I used to this refactoring operation:

#! /usr/bin/python
import sys
import re
import tempfile
import os
import shutil

def do_a_file(filename):
    input=open(filename)
    output, output_name = tempfile.mkstemp()
    output = os.fdopen(output, "w")
    print output_name
    rawstr = r"""(.*)putValue\(.*NAME"""
    compile_obj = re.compile(rawstr)
    for l in input:
        match_obj = compile_obj.search(l)
        if match_obj != None and len(match_obj.groups()) > 0:
            output.write(match_obj.group(1)+'putValue("iconBase","org/foobar");\n')
        output.write(l)
    input.close()
    output.close()
    shutil.move(output_name, filename)

for root, subFolders, files in os.walk(sys.argv[1]):
    for file in files:
        if file.endswith(".java"):
            do_a_file(os.path.join(root,file))

Now I often use it with minor changes for any refactoring operations which are to specific to be supported by my favorit IDE.

Anyway I guess such multiline context search/replacement is possible with awk or sed, and I would be glad to know how.

Tags: ,

Netbeans DataObject life cycle

December 11, 2008 Leave a comment

Here are some questions which I did not found any answer on the Netbeans wiki:

  • When are DataObject created
  • When are DataObject destroyed
  • Am I expected to store custom data in DataObject

Answers can be found in the openide.loaders/src/org/openide/loaders/DataObjectPool.java file, in the source code:

  • DataObject are, at least, created when Netbeans need to display a Node representing a FileObject, that is, each time an explorer browse a file system.
  • DataObject are stored as WeakReference in the DataObjectPool instance. They are freed when memory is required.
  • As you do not control when DataObject are created nor disposed you should probably not load nor store data when the DataObject is created. It should be done by actions associated to the DataObject.

There is a funny side efect of using WeakReference to keep track on DataObject. If you open a directory with a lot’s of large DataObject, some of them may be destroyed by the garbage collector as soon are the are created. Then corresponding nodes are not displayed.

Tags: ,