tags:

views:

25

answers:

3

I'm using an Ant task to invoke Google's GWT compiler, as in:

<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
 <arg value="package.of.GWTClass" />
</java>

This works, but I'd like to avoid recompiling the entire project during each Ant build in none of the dependencies have changed. I'm aware that Ant can't automatically track these dependencies, but is there any way for me to manually encode them, and selectively skip the target when nothing has changed?

A: 

You may add an if clause to your ant target. We use it as follows:

<target name="gwt-compile" if="gwt" description="Compile GWT related code.">
    <!-- ... -->
</target>

When you invoke the target you can enable the compilation by setting the gwt property with -D:

ant -Dgwt=yes gwt-compile

The opposite of if in a target is unless.

Hope that helps.

kraftan
+1  A: 

You could also consider attempting to parallelise the GWT compile step in your ANT build with the java compilation. We used ANT's tag to run the GWT compile step alongside the standard java compilation step. Clearly this will only really help if your computer is has more than one core.

e.g.

    <parallel>
        <antcall target="gwt-compile"/>
        <sequential>
            <antcall target="compile/java"/>
        </sequential>
        <parallel>
            <antcall target="compile/test-unit"/>
            <antcall target="compile/test-integration"/>
            <antcall target="compile/test-gwt"/>
            <antcall target="compile/test-selenium"/>
        </parallel>
    </parallel>

We also defined module files that targetted just the Firefox browser for running the tests part of the build (for our check in buid), and then also a more complete module file with all browsers supported for the full build on the Continuous Integration build.

Stuart Ervine
A: 

use the uptodate task in conjunction with gwt. What it does is check if a file is more recent than another file, and sets a property if it is. You compare the gwt source file with the *.js output files' dates, and if its more recent, you do the compile.

you will have to get all the files the gwt compiler will use, which can be hard if you only have a module name, and cannot work out the inheritance tree easily, but a simple but not always optimal approach would be to just use every gwt java file. Then, in the gwt compile task, check the property before compiling.

Chii