繁体   English   中英

如何更新gwt-maven-plugin原型?

[英]How to update gwt-maven-plugin Archetype?

我想用Eclipse IDE创建Maven托管的gwt项目。

我正在使用GWT 2.7。 但是,当我从File> New> Maven Project创建一个项目并选择gwt作为Archetype时 ,请找到下面的图像-

在此处输入图片说明

版本是2.1.0-1,生成的pom.xml是gwt版本2.1。 如何更新org.codehaus.mojo原型 还是可以设置为用gwt版本生成?

编辑:生成的pom.xml在下面,但我正在使用gwt 2.7

<?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>com.my.test</groupId>
  <artifactId>TestingGWT</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.1.0</gwtVersion>
    <!-- GWT needs at least java 1.5 -->
    <maven.compiler.source>1.5</maven.compiler.source>
    <maven.compiler.target>1.5</maven.compiler.target>
    <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-servlet</artifactId>
      <version>2.1.0</version>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <version>2.1.0</version>
      <scope>provided</scope>
    </dependency>  
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.7</version>
      <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.1.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>testingGWT.html</runTarget>
          <hostedWebapp>${webappDirectory}</hostedWebapp>
          <i18nMessagesBundle>com.my.test.TestingGWT.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>

    </plugins>
  </build>

</project>

PS请不要在生成后建议编辑pom.xml文件。

原型目录似乎在Eclipse中已过时。 我不知道如何更新(我什至都​​不知道Maven如何在Eclipse之外进行更新),但是一个简单的解决方法是使用“ 添加原型”按钮添加org.codehaus.mojo:gwt-maven-plugin:2.7.0


话虽这么说,尽管2.7.0原型比2.1.0原型要好得多,但我不建议使用它,除非进行小型一次性实验或bug再现案例。
对于您希望在中/长期维护和发展的任何项目,我强烈建议您将单独的Maven模块用于客户端和服务器端代码。 我为该多模块设置构建了原型: https : //github.com/tbroyer/gwt-maven-archetypes ; 看到这里的公告。 还要注意,他们不使用org.codehaus.mojo插件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM