只需在Eclipse Indigo中使用GWT 2.3和Maven2(3)项目

时间:2011-08-09 14:37:29

标签: eclipse gwt maven

当我尝试使用以下参数创建Maven项目时: Archetype Group Id - org.codehaus.mojo; Archetype Artifact Id - gwt-maven-plugin; 原型版本 - 2.3.0-1。 我得到一些奇怪的错误:

  • 生命周期配置未涵盖的插件执行:org.codehaus.mojo:gwt-maven-plugin:2.3.0-1:generateAsync(执行:默认,阶段:生成源)

  • 生命周期配置未涵盖插件执行:org.codehaus.mojo:gwt-maven-plugin:2.3.0-1:i18n(执行:默认,阶段:生成源)

  • 生命周期配置未涵盖插件执行:org.apache.maven.plugins:maven-war-plugin:2.1.1:爆炸(执行:默认,阶段:编译)

还有一些警告:

  • 无法找到项目方面jst.web的实现。功能将受到限制。

  • 无法找到项目方面wst.jsdt.web的实施。功能将受到限制。

这是我的pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project
  xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

  <!-- POM file generated with GWT webAppCreator -->
  <modelVersion>4.0.0</modelVersion>
  <groupId>net.test1</groupId>
  <artifactId>TestWebApp</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>GWT Maven Archetype</name>

  <properties>
    <!-- Convenience property to set the GWT version -->
    <gwtVersion>2.3.0</gwtVersion>
    <!-- GWT needs at least java 1.5 -->
    <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-servlet</artifactId>
      <version>${gwtVersion}</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <version>${gwtVersion}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.7</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.0.0.GA</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
      <version>1.0.0.GA</version>
      <classifier>sources</classifier>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <!-- Generate compiled stuff in the folder used for developing mode -->
    <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>

    <plugins>

      <!-- GWT Maven Plugin -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>2.3.0-1</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>test</goal>
              <goal>i18n</goal>
              <goal>generateAsync</goal>
            </goals>
          </execution>
        </executions>
        <!-- Plugin configuration. There are many available options, see 
          gwt-maven-plugin documentation at codehaus.org -->
        <configuration>
          <runTarget>TestWebApp.html</runTarget>
          <hostedWebapp>${webappDirectory}</hostedWebapp>
          <i18nMessagesBundle>net.test1.TestWebApp.client.Messages</i18nMessagesBundle>
        </configuration>
      </plugin>

      <!-- Copy static web files before executing gwt:run -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        <executions>
          <execution>
            <phase>compile</phase>
            <goals>
              <goal>exploded</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <webappDirectory>${webappDirectory}</webappDirectory>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>

等等。这是什么?我已经在互联网上尝试了所有可能的手册,并且到处都是。我试图在没有eclipse和同样的情况下手动创建项目。我认为,问题在于互联网上的手册是为旧版本的Eclipse,Maven,GWT编写的。我怎么能打败它?如何使用GWT 2.3,Maven2插件和Eclipse Indigo创建简单项目而不会出现错误结束警告?

1 个答案:

答案 0 :(得分:11)

这是已知的行为,在eclipse wiki上讨论过。见这里:http://wiki.eclipse.org/M2E_plugin_execution_not_covered

不要只是评论你的pom中有问题的部分,你确实需要它们。例如,在pom中为maven-war-plugin生成的注释是“在执行gwt:run之前复制静态Web文件”这证明是真的。如果您注释掉该插件并且“mvn clean gwt:run”,静态文件将不会被复制到目标文件夹并且无法用于托管模式。

幸运的是,解决方法很简单。如果您在Eclipse中打开pom,请查看Overview部分,然后单击顶部的错误消息,它将为您提供一些快速修复选项。例如“永久标记在pom.xml中爆炸的目标被忽略”。这将为你的pom添加一些m2e配置,因此它不再被标记为错误,并且一切都将像以前一样工作。 pom中新生成的部分是上面链接中描述的“忽略”选项。

希望这有帮助。

相关问题