[英]How to compile a GWT module contained in the test source with gwt-maven-plugin?
我试图通过插件gwt-maven-plugin使用maven运行GWT编译,但是GWT模块包含在测试源路径中,即:src / test / java。 并且该插件抱怨找不到GWT模块。
但是,通过GWT类DevMode通过Eclipse启动文件使用该模块时,该模块可以正常工作。 为什么gwt maven插件找不到GWT模块?
该项目包含2个Gwt模块,其中1个GwtTotalProd包含在主要源中,而GwtTotalTest包含在测试源中。 gwt maven插件能够构建GwtTotalProd,但是不能构建GwtTotalTest,为什么(两者都可以通过Eclipse启动文件运行)? 我尝试通过将测试源包含在build pom中进行尝试(请参见下文),但是没有运气。
查看maven调试输出(-X开关),我可以理解它找不到它,因为GWT SDK执行包含src / main / java,但不包含src / test / java,并且不包括依赖项在插件中定义。 那么如何告诉插件查看测试源路径呢?
我可以通过创建一个额外的“ test / dev”项目来做到这一点,该项目在主源中包含GwtTotalTest(我对其他项目也是如此),但是在这种情况下,这是不希望的,因为它将是一个只有Gwt的空项目配置文件;)...或者我应该将其绑定到另一个Maven阶段? 我没有尝试目标“编译”,而是尝试了目标“测试”(test-compile似乎不起作用,maven表示无法找到目标),但是也没有运气...
我正在使用插件版本2.7.0和配置专家:
<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>
插件不提供此功能。 如您所述,(如果这样做)(可能)将成为testCompile
目标。
但是有几种方法可以做到这一点:
maven-invoker-plugin
启动Maven模块,其源代码包含在模块本身中(而不是在Reactor构建中作为单独的模块) getModuleName()
返回com.total.GwtTotalTest
的GWTTestCase
, 并在gwt:test
并将productionMode
设置为true
(这样,将在运行任何测试方法之前编译模块)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.