Maven GWT 2.0和Eclipse [英] Maven GWT 2.0 and Eclipse

查看:100
本文介绍了Maven GWT 2.0和Eclipse的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



为什么值得,我可以使用maven eclipse插件创建一个工程正常的gwt项目,但将其移植到maven不起作用(所以这个指南会很好)。



同样,我可以使用maven插件(gwt-maven-plugin),但是当我导入到eclipse(import - > materialize maven项目)时,它不会被确认为GWT项目...



感谢

解决方案

编辑:我已经通过OP提供的其他步骤更新了我的答案。对于详细信息,请点击OP。



我刚刚打破了我的Eclipse安装程序,试图安装最新版本的Google Plugin for Eclipse(对于GWT 2.0),所以我可以' t确认一切,但我们假设满足以下先决条件:





您尝试过:


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


  2. 编辑生成的 pom.xml ,将 gwt.version 属性更新为 2.0.0 (已在中央repo发布),添加 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.0encoding =UTF-8?> 
< project xmlns =http://maven.apache.org/POM/4.0.0xmlns: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原型生成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>

<! - 方便在一个地方定义GWT版本 - >
< gwt.version> 2.0.0< / gwt.version>

<! - 告诉编译器我们可以使用1.5 - >
< maven.compiler.source> 1.5< /maven.compiler.source>
< maven.compiler.target> 1.5< /maven.compiler.target>

< / properties>

<依赖关系>

<! - GWT依赖关系(来自中央repo) - >
<依赖关系>
< groupId> com.google.gwt< / groupId>
< artifactId> gwt-servlet< / artifactId>
< version> $ {gwt.version}< / version>
< scope>运行时< / scope>
< / dependency>
<依赖关系>
< groupId> com.google.gwt< / groupId>
< artifactId> gwt-user< / artifactId>
< version> $ {gwt.version}< / version>
< scope>已提供< / scope>
< / dependency>

<! - test - >
<依赖关系>
< 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>
<执行>
< 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>
<! -
如果要使用mergewebxml生成的目标/ web.xml文件,
告诉war插件来使用它。
此外,从这里最后的工件排除您想要的内容。
< 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>

运行 gwt:eclipse m2eclipse Maven2> build ...)设置您的环境并为您的GWT模块创建启动配置。



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


Does anyone know of a good guide for creating a project with the new 2.0 release of GWT using maven and eclipse? I am running into a lot of problems getting them to play nicely together.

For what it's worth, I can create a gwt project using the maven eclipse plugin which works fine, but porting it to maven doesn't work (so a guide for this would be great).

Likewise, I can use the maven plugin (gwt-maven-plugin), but when I import it to eclipse (import -> materialize maven projects), it does not get recognised as a GWT project...

Thanks

解决方案

EDIT: I've updated my answer with additional steps provided by the OP. Credits to the OP for the details.

I just broke my Eclipse setup trying to install the latest version of the Google Plugin for Eclipse (for GWT 2.0) so I can't confirm everything but, let's assume the following prerequisites are fulfilled:

Did you try to:

  1. Create a new project from Eclipse (New > Other... then select Maven Project and choose the gwt-maven-plugin archetype).

  2. Edit the generated pom.xml, update the gwt.version property to 2.0.0 (which has been released in the central repo), add the Codehaus Snapshot repository and set the gwt-maven-plugin version to 1.2-SNAPSHOT (the version 1.2 isn't released in central, this should happen soon) 1.2 (which has been released in central too).

  3. Add a <runTarget> to the gwt-maven-plugin configuration as documented in Using the Google Eclipse Plugin.

  4. Configure the maven-war-plugin as documented in the page mentioned in the previous step.

  5. Manually enable GWT on the project from project preference by setting the Use Google Web Toolkit checkbox This step is unnecessary since you'll be building/running with a Maven run configuration, not the GWT Plugin for Eclipse.

This is how my pom.xml actually looks like:

<?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 the gwt:eclipse goal (using m2eclipse Maven2 > build...) to setup your environment and create the launch configuration for your GWT modules.

Run gwt:compile gwt:run to compile and run a GWT module in the GWT Hosted mode.

这篇关于Maven GWT 2.0和Eclipse的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆