Fixing Compilation in GWT4NB

By default GWT4NB recompiles all of your client code with the GWT compiler whether or not you’ve changed it. This is a time consuming (and sometimes irritating factor). After a recent discussion on the GWT dev mailing list (which I was away for most of), I decided to post the solution I use here and on the mailing list.

In your projects build.xml, just copy-and-paste the following:

<target name="-post-compile">
<property name="output.js" location="${build.web.dir}/${gwt.module}/${gwt.module}.nocache.js" />
</target>

<target name="debug" description="Debug project in IDE." depends="init,compile,compile-jsps,-do-compile-single-jsp" if="netbeans.home">
<property name="gwt.compile.unneeded" value="true" />
    <antcall target="dist"/>

    <nbdeploy debugmode="true" clientUrlPart="${client.urlPart}"/>
    <antcall target="connect-debugger"/>
    <antcall target="debug-connect-gwt-shell"/>
</target>

<target name="-pre-dist">
    <condition property="gwt.compile.unneeded">
        <and>
            <available file="${output.js}" />
            <uptodate>
                <srcfiles dir="${src.dir}" includes="**/client/**/*.java" />
                <mergemapper to="${output.js}" />
            </uptodate>
        </and>
    </condition>
    <antcall target="do-gwt-compile" />
</target>

<target name="do-gwt-compile" unless="gwt.compile.unneeded">
    <!-- You can override this property in the 'gwt.properties' file -->
<property name="gwt.compiler.output.style" value="OBFUSCATED"/>
<property name="gwt.compiler.logLevel" value="WARN"/>

    <java classpath="${javac.classpath}:${src.dir}" failonerror="true"
      classname="com.google.gwt.dev.GWTCompiler" fork="true" maxmemory="512m">
        <arg value="-out"/>
        <arg path="${build.web.dir}/"/>
        <arg value="-style"/>
        <arg value="${gwt.compiler.output.style}"/>
        <arg value="-logLevel"/>
        <arg value="${gwt.compiler.logLevel}"/>
        <arg value="${gwt.module}"/>
    </java>
<property name="gwt.output.dir" value="${gwt.module}"/>
    <move todir="${build.web.dir}/${gwt.output.dir}">
        <fileset dir="${build.web.dir}/${gwt.module}"/>
    </move>
</target>

What does it actually do? It checks to see if the client side code is newer than the module.nocache.js file in the web output. Since GWT overwrites this file every-time it compiles (and in GWT 1.5 actually deletes it first), it will only be older if one of your source files has changed.

Hope this helps you out, happy coding!

Edit 11/14/08: The script is now fixed to only build using normal javac when run in debugging mode.

On Netbeans; memory and speed

It’s about the most common complaint about Netbeans: It needs to much memory! *wine wine wine*
That, and: it’s so slows *cry cry cry*

You know something, there are two simple ways around this “problem”:

  1. If you are running Windos, switch to a real operating system! I recommend:
    1. Kubuntu for people with permanent internet or
    2. SUSE for those who are on dial-up
  2. If you are actually writing code, you need a minimum of 1Gb (preferably 1.5Gb) of RAM
    1. This applies to all software developers, regardless of you language or target platform (I included embedded developers in this statement).
    2. Software developers simply tend to have more software running at any given time
  3. A dual-core CPU does make an enormous difference to IDE performance

I do 100% of my development on a 1.6Ghz Centrino laptop, with 1.5Gb of RAM (533Mhz if you must know), with a standard laptop hard-drive. With this simple configuration I am amazed at the speed when I run:

  • Netbeans 5.5
  • Netbeans 6 beta-2
  • JBoss 4
  • Thunderbird
  • Firefox
  • Kopete
  • Konqueror
  • Amarok
  • Kerry-Beagle
  • Many terminals
  • MySQL

Spread out over 4 KDE desktops, and they all perform as if they were running by themselves. If you have the opertunity, switch to Netbeans 6, as it’s a much faster system than any previous version.

First impressions of Netbeans 6

I know I’m very late with this post, but I just haven’t really had the time recently to try out Netbeans 6. Now that I’ve spent a few days with it, I have a few things to say about it:

1. Memory Usage

Wow! How? Netbeans 6 is operating inside the 30 – 40 Mb range instead of the 90 – 200 Mb range. I have no idea whats happened under the hood, since Netbeans 6 seems to be doing a lot more “intelligent” work than Netbeans 5.5 did, and that usually translates to more memory being used.

2. Code Completion

Okay… This is one of the big features in Netbeans 6, but what nobody seems to be saying is that is extends well beyond the range of the auto-completion drop-down. Netbeans 6 automatically suggests names, what arguments you’re likely to use, etc. For example:

List<Person> people;

public void addPerson(Person p) {
people.add(p);
}

In the above example, the instant you open brackets for “people.add(“, Netbeans fills in “p);” and selects the “p”. This works not just with collections, but any method you care to name. It’s very impressive, because it chooses the parameters intelligently, based on the data-type.

And did I mention that the code-completion is about a million times faster than it used to be?!

3. Code Formatting

Finally, Netbeans gets decent code formatting. The new code formatting can conform to some of the most obscure styles I’ve ever seen, and the configuration is clean and easy to work with.

4. Surround With

The surround with functionality doesn’t sound like anything spectacular, until you see it work with a really tricky piece of code, and it does something unexpected… but amazingly elegant, like simply add another “catch” onto the end of and existing “try” block instead of writing a whole new “try/catch” in.

Like is mentioned on the site, Surround With is not just about “try/catch” anymore, it does any type of block you care to name, and like everything else in NB 6, it does it intelligently and elegantly.

Summary

Netbeans 6 still has a few niggly bugs (in beta 1 at least), but for me, none of them are show-stoppers. For my income producing work, I’m likely to wait until it’s released, but if you haven’t already downloaded it and tried it out, I strongly suggest you do. You may just fall in love.

Open Office to Netbeans for my Wedding

I’ve just written the first paragraph of my wedding speech (getting married next weekend, 2007-09-15) using Open Office. It’s generally a lovely writing tool, except I just discovered that it doesn’t have a “Select Current ATOM” shortcut. So, I’m switching to Netbeans to write the rest of the speech. What kind of IDE doesn’t have an “ALT-J” combination to select the current ATOM!

Netbeans Music Player Released

The Music Player module for Netbeans that I was talking about here has been published in the Netbeans Plugin Portal. It’s early days, but heres a list of features it already includes:

  • A Collection tab that sits in the same space as “Projects”; “Files” and “Runtime”
  • A Play list that occupies a tab with the source editor
    • The play list can be closed without causing the play problems
  •  Plays OGG and MP3 files
  • A player-controls toolbar

Here’s the link:http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=3219

Go download and enjoy! I’ll be releasing the source-code as soon as I’ve got a bit more time.

A Music Player for Netbeans

I finally decided to climb into the Netbeans platform (been meaning to do it for ages). I figured there are only really 3 things I want Netbeans to do that it can’t already do:

  1. Play Music while I code
  2. Check; Read and Write Email
  3. Browse the web (properly, not just HTML 3.2)

Since playing music turned out to be the most important for me, I decided that I’d write a music player as my first Netbeans module. I’m basing the entire module heavily on Amarok, since thats by far the best music player I’ve used (and I’ve used plenty). Currently the code has a Collection (of all your music), and a Playlist. It also adds a new menu, titled “Multimedia”.

Heres a screen-shot of the app so far:

nbentertainer.jpg

The Netbeans Platform (once you get your head around a few simple concepts) is a dream to work with. If you haven’t already used it, try coding something simple on it, you’ll almost certainly love it!

Update (18:15):

It’s already at a point that it’s quite usable, I’ll find somewhere to open-source the module in the next day or so, and post a link to it on my blog. It’s now happily playing a Nightwish MP3 in the background for me. It makes life a whole lot easier when you don’t have to leave your IDE to do something like queue a song.

Native looking Netbeans on Linux

It’s all very fine and well those Windows people having a nice native Look & Feel under Netbeans, but what about us lowly Linux types? Well as many already know, Sun implemented a GTK Look & Feel around the 1.5 release, but the Metal Look & Feel is still the default on a Linux system, even at 1.6. The new GTK Look & Feel actually uses GTK widgets underneath, so will emulate the GTK Look & Feel very closely (although I’ve come across a few minor issues with scrollbars).

So how do you invoke Netbeans with the GTK Look & Feel? It’s documented in the Netbeans documentation:

Instead of simply invoking the /bin/netbeans executable, invoke:

/opt/netbeans/bin/netbeans -laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel

Substitue /opt/netbeans for wherever you installed Netbeans to.

Hint: You can open your “/opt/netbeans/etc/netbeans.conf” file, and add the “-laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel” to the end of the “netbeans_default_options” variable.

This is all very fine and well for GNOME people, but what about the KDE users out there? The answer comes in the form of the QT Engine for GTK. It makes GTK applications use QT for their rendering (installed by default in SUSE).

nebeans-serenity.jpg Finally, heres a screen shot of Netbeans running with the Serenity Look & Feel (under KDE). I know it doesn’t look great, but it illustrates the idea anyway ;) Click the image for the full view.

Follow

Get every new post delivered to your Inbox.