How to compile a GWT module contained in the test source with gwt

I am trying to run GWT compile with maven through the plugin: gwt-maven-plugin, but the GWT module is contained in the test source path, namely: src/test/java. And the plugin complaints that it can't find the GWT module.

However, the module works fine when using it through an Eclipse launch file, using GWT class DevMode. Why can't the gwt maven plugin find the GWT module ?

The project contains 2 Gwt modules, 1 GwtTotalProd contained int he main source and a GwtTotalTest contained in the test source. The gwt maven plugin is able to build the GwtTotalProd, but not the GwtTotalTest, why (both run fine through Eclipse launch file)? I try it with including the test sources in the build pom (see below), but no luck.

Looking at the maven debug output (-X switch), I can understand that it can't find it, because the GWT SDK execution contains src/main/java, but not the src/test/java, and it not including the dependencies defined in the plugin. So how to tell the plugin to look in the test source path?

I could do it by creating an additional "test/dev" project that includes the GwtTotalTest in the main source (I do that for other projects), but in this case it's not desired, as it would be an empty project with only the Gwt config file ;)... Or maybe I should bind it to another maven phase? Instead of the goal "compile" I tried the goal "test" (test-compile doesn't seem to work, maven says it can't find the goal int he p lugin), but also no luck...

I am using plugin version 2.7.0 and the config maven:

            <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <id>TotalProd</id>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                    <configuration>
                        <module>com.total.GwtTotalProd</module>
                        <mode>htmlunit</mode>
                        <draftCompile>false</draftCompile>
                        <disableClassMetadata>true</disableClassMetadata> 
                        <compileReport>true</compileReport>
                        <warSourceDirectory>${gwt.war}</warSourceDirectory>
                        <webappDirectory>${gwt.output.total}</webappDirectory>
                        <gen>${gwt.output.total}/${gwt.gen}</gen>
                        <extra>${gwt.output.total}/${gwt.extra}</extra>
                        <fragmentCount>8</fragmentCount>
                        <extraJvmArgs>-Xms1G -Xmx1G -Xss1024k -Dgwt.persistentunitcache=false</extraJvmArgs>
                    </configuration>
                </execution>
                <execution>
                    <phase>compile</phase>
                    <id>TotalTest</id>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                    <configuration>
                        <module>com.total.GwtTotalTest</module>
                        <mode>htmlunit</mode>
                        <draftCompile>false</draftCompile>
                        <disableClassMetadata>true</disableClassMetadata> 
                        <compileReport>false</compileReport>
                        <warSourceDirectory>${gwt.war}</warSourceDirectory>
                        <webappDirectory>${gwt.output.total.test}</webappDirectory>
                        <gen>${gwt.output.total.test}/${gwt.gen}</gen>
                        <extra>${gwt.output.total.test}/${gwt.extra}</extra>
                        <fragmentCount>8</fragmentCount>
                        <extraJvmArgs>-Xms1G -Xmx1G -Xss1024k -Dgwt.persistentunitcache=false</extraJvmArgs>
                        <dependencies>
                            <dependency>
                                <groupId>com.company.gwt</groupId>
                                <artifactId>total-gwt</artifactId>
                                <version>${version.gen}</version>
                                <classifier>test-sources</classifier>
                            </dependency>
                            <dependency> 
                                <groupId>com.company.gwt</groupId>
                                <artifactId>total-gwt</artifactId>
                                <version>${version.gen}</version>
                                <type>test-jar</type>
                            </dependency>
                        </dependencies>
                    </configuration>
                </execution>
            </executions>
        </plugin>

The plugin doesn't provide this feature. As you noted, it would (probably) be a testCompile goal if it did.

There are several ways to do that though:

  • use a separate Maven module, as you noted
  • use the maven-invoker-plugin to launch a Maven module during the build, whose sources are contained within the module itself (rather than being a separate module in the reactor build)
  • use a GWTTestCase whose getModuleName() returns com.total.GwtTotalTest and you run with gwt:test with productionMode set to true (so that the module will be compiled before any test method run).
  • 链接地址: http://www.djcxy.com/p/44128.html

    上一篇: 在Applescript中接收Adium消息

    下一篇: 如何用gwt编译包含在测试源中的GWT模块