2

我有一个配置了 maven-surefire-plugin 的根 pom 和一个配置了 gwt-maven-plugin 的 gwt 模块 pom。升级到 Maven 3 后,出现奇怪的错误。

该项目的配置与此处描述的类似:将 GwtTest 测试与标准单元测试分开

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>2.6</version>
  <configuration>
    <useSystemClassLoader>true</useSystemClassLoader>
    <useManifestOnlyJar>false</useManifestOnlyJar>
    <forkMode>always</forkMode>
    <properties>
      <property>
        <name>usedefaultlisteners</name>
        <value>false</value>
      </property>
      <property>
        <name>listener</name>
        <value>org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter</value>
      </property>
    </properties>
    <argLine>-server -Xmx8192m -XX:MaxPermSize=1024M -XX:+CMSClassUnloadingEnabled</argLine>
    <excludes>
      <exclude>**/*GwtTest*.java</exclude>
    </excludes>
  </configuration>
</plugin>

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>gwt-maven-plugin</artifactId>
  <version>2.5.0</version>
  <dependencies>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <version>${gwt.version}</version>
    </dependency>
  </dependencies>
  <configuration>
  <modules>
    <module>my.app.gwt</module>
  </modules>
  <runTarget>/</runTarget>
  <extraJvmArgs>-Xss512m -Xmx2048m -XX:MaxPermSize=256M</extraJvmArgs>
  <hostedWebapp>${project.build.directory}/${project.build.finalName}</hostedWebapp>
  <includes>**/*GwtTestSuite.java</includes>
  <copyWebapp>true</copyWebapp>
  <logLevel>INFO</logLevel>
  <persistentunitcache>false</persistentunitcache>
  <draftCompile>${gwt.draftCompile}</draftCompile>
  <deploy>${project.build.directory}/${project.build.finalName}/WEB-INF/deploy</deploy>
  <disableCastChecking>true</disableCastChecking> 
  <mode>htmlunit</mode>
  <skipTests>${skipGwtTests}</skipTests></configuration>
  <executions>
    <execution>
      <id>gwt-compile</id>
      <goals>
        <goal>compile</goal>
      </goals>
      <phase>compile</phase>
    </execution>
    <execution>
      <id>gwt-test</id>
      <goals>
        <goal>compile</goal>
        <goal>test</goal>
      </goals>
      <phase>test</phase>
    </execution>
  </executions>
</plugin>

它适用于 maven 2,但使用 maven 3 我得到:

[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:2.5.0:test (gwt-test) on project my-webapp: Unable to parse configuration of mojo org.codehaus.mojo:gwt-maven-plugin:2.5.0:test: When configuring a basic element the configuration cannot contain any child elements. Configuration element 'excludes'. -> [Help 1]

似乎gwt插件无法解析surefire插件的分层样式。

只有当我将 gwt 插件中的所有排除/包含设置为一个逗号分隔的字符串行时,它才会编译,但这对我不起作用,因为我需要全局排除 gwt 测试,并在本地包含它们。

但是,包含/排除部分会合并,因此两个不兼容的语法定义将无法一起工作。

我希望有人能给我一个提示。

4

1 回答 1

0

您可以使用直接的 Maven Surefire 运行 GWTTestCases,请参阅此链接

于 2013-01-08T05:30:40.367 回答