Using Clover-for-Ant with GWT

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

You can instrument server-side code only. This is due to a nature of the Google Web Toolkit which translates client and shared parts into a JavaScript. If you try to instrument client code, GWT will search for sources of all referenced classes, including the Clover instrumentation, which would cause a build failure.

 

Clover with manual GWT integration

The following example is based on GWT SDK 2.5.

 

1) Download and install

2) Open the sample DynaTable application (located in <gwt-sdk>/samples/DynaTable; referred as <project_dir>) and enhance build.xml file by adding:

  • <clover-setup> with includes="'' for server-side code
  • <clover-report> or <clover-html-report>
  • clover.jar to runtime classpath

 

Example:

build.xml
<project name="DynaTable" default="build" basedir=".">
    <!-- Add following properties and targets -->

    <property name="clover.jar" location="${user.home}/clover.jar"/>
    <property name="clover.license" location="${user.home}/clover.license"/>
    <property name="clover.db" location="clover/db/clover.db"/>
    <property name="clover.report" location="clover/report"/>
    <taskdef resource="cloverlib.xml" classpath="${clover.jar}"/>

    <target name="init" if="with.clover">
        <clover-setup initstring="${clover.db}">
            <fileset dir="src" includes="com/google/gwt/sample/dynatable/server/**"/>
        </clover-setup>
    </target>

    <target name="report">
        <clover-html-report initstring="${clover.db}" outdir="${clover.report}"/>
    </target>

    <!-- ... -->

    <!-- Add the "init" target to depends="..." -->
    <target name="javac" depends="libs, init" description="Compile java source to bytecode">
       <!-- ... -->
    </target> 

    <!-- Add the clover.jar to classpath -->

    <target name="devmode" depends="javac" description="Run development mode">
        <java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode">
            <classpath>
                <pathelement location="src"/>
                <path refid="project.class.path"/>
                <pathelement location="../../validation-api-1.0.0.GA.jar" />
                <pathelement location="../../validation-api-1.0.0.GA-sources.jar" />
                <pathelement location="${clover.jar}"/> <!-- ADD THIS -->
            </classpath>
            <!-- ... -->
        </java>
    </target>

    <!-- ... -->

</project>

 

3) Build application, run tests and generate Clover report.

(warning) GWT requires Java 1.6 or above

 

ant devmode -Dwith.clover=true
... open web browser, close GWT console ...
ant report

Open <project_dir>/clover/report/index.html file. You shall see a report like this:

References

See also

 

Last modified on Jan 2, 2013

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.