Maven GWT 2.0和Eclipse

Leh*_*ane 52 java eclipse gwt maven-2

有没有人知道使用maven和eclipse用GWT的新2.0版本创建项目的好指南?我遇到很多问题让他们一起玩得很好.

为了它的价值,我可以使用maven eclipse插件创建一个gwt项目,它工作正常,但将其移植到maven不起作用(所以这个指南会很棒).

同样,我可以使用maven插件(gwt-maven-plugin),但是当我将它导入eclipse(import - >实现maven项目)时,它不会被识别为GWT项目......

谢谢

Pas*_*ent 42

编辑:我已经通过OP提供的其他步骤更新了我的答案.有关详细信息,请致OP.

我刚刚破坏了我的Eclipse设置,尝试安装最新版本的Google Plugin for Eclipse(适用于GWT 2.0),所以我无法确认所有内容,但我们假设满足以下先决条件:

你试过:

  1. 从Eclipse创建一个新项目(New> Other ...然后选择Maven Project并选择gwt-maven-plugin archetype).

  2. 编辑生成的pom.xml,更新gwt.version属性2.0.0(已在中央存储库中发布),添加Codehaus Snapshot存储库并将gwt-maven-plugin版本设置为1.2-SNAPSHOT(版本1.2未在中央发布,这应该很快 1.2发布)(已发布)在中央也).

  3. 添加<runTarget>到gwt-maven-plugin配置,如使用Google Eclipse插件中所述.

  4. 按照上一步中提到的页面中的说明配置maven-war-plugin.

  5. 通过设置使用Google Web Toolkit复选框从项目首选项手动启用项目上的GWT此步骤是不必要的,因为您将使用Maven运行配置而不是Eclipse的GWT插件构建/运行.

这就是我的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">
  <!--
    GWT-Maven archetype generated POM
  -->
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.demo</groupId>
  <artifactId>my-gwtapp</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>gwt-maven-archetype-project</name>

  <properties>

      <!-- convenience to define GWT version in one place -->
      <gwt.version>2.0.0</gwt.version>

      <!--  tell the compiler we can use 1.5 -->
      <maven.compiler.source>1.5</maven.compiler.source>
      <maven.compiler.target>1.5</maven.compiler.target>

  </properties>

  <dependencies>

    <!--  GWT dependencies (from central repo) -->
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-servlet</artifactId>
      <version>${gwt.version}</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <version>${gwt.version}</version>
      <scope>provided</scope>
    </dependency>

    <!-- test -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.4</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <outputDirectory>war/WEB-INF/classes</outputDirectory>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>1.2</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>generateAsync</goal>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <runTarget>com.mycompany.demo.gwt.Application/Application.html</runTarget>
        </configuration>
      </plugin>
      <!--
          If you want to use the target/web.xml file mergewebxml produces,
          tell the war plugin to use it.
          Also, exclude what you want from the final artifact here.
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webXml>target/web.xml</webXml>
                    <warSourceExcludes>.gwt-tmp/**</warSourceExcludes>
                </configuration>
            </plugin>
            -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <warSourceDirectory>war</warSourceDirectory>
          <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
        </configuration>
      </plugin>    
    </plugins>
  </build>

</project>
Run Code Online (Sandbox Code Playgroud)

运行gwt:eclipse目标(使用m2eclipse Maven2> build ...)来设置环境并为GWT模块创建启动配置.

运行gwt:compile gwt:run以在GWT托管模式下编译和运行GWT模块.