Search code examples
javagwtantgwt-compiler

Running GWT from Ant buildfile with special arguments?


I would like to run the GWT compiler from my Ant buildfile with the compiler the following flags:

  • -compileReport
  • -XsoycDetailed
  • -extra
  • -XfragmentCount <x> (where <x> is an integer that I'll determine over time)

I looked into ant-gwt, which seemed pretty stable, however after a thorough inspection of the documentation and code, it doesn't seem like that plugin can handle these GWT compiler options.

Checking out the GWT command-line tools, I see a code snippet for an Ant task that runs a GWT class called com.google.gwt.dev.Compiler from inside a buildfile:

<java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
    <classpath>
        <pathelement location="src"/>
        <path refid="project.class.path"/>
    </classpath>
    <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
    <jvmarg value="-Xmx256M"/>
    <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
    <arg value="com.example.foo.Foo"/>
</java>

Is this the correct way to run the GWT compiler from Ant (that ant-gwt probably wraps)? I think the word dev in the package name is throwing me off: is this some smart compiler stub or is it actually the GWT compiler?

If not, then what is the proper way to run GWT from inside of Ant? The only other thing I can think of would be to kick off a Python script from inside the Ant task, and have the Python script call the GWT compiler, but even then, not sure what command-line tool to call from that Python script (maybe webAppCreator?). Thanks in advance.


Solution

  • After downloading GWT from http://code.google.com/p/google-web-toolkit/downloads/list, extract the content from zip folder. Please refer the build scripts "build.xml" provided by GWT team in "sample" folder projects like "Hello" .

    or

    Example Hello World Ant build.xml Modify 4th line to add your compiler options - <property name="gwt.args" value="-draftCompile -ea -style pretty -logLevel TRACE -workDir work" />