java - 如何更新 gwt-maven-plugin 原型(prototype)?

标签 java eclipse maven gwt maven-archetype

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

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

enter image description here

版本是2.1.0-1,生成的pom.xml是gwt版本2.1。我如何更新这个org.codehaus.mojo原型(prototype)?或者我可以设置为使用我的 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 中的原型(prototype)目录似乎已过时。我不知道如何更新它(我什至不知道 Maven 如何在 Eclipse 之外执行此操作),但一个简单的解决方法是使用 Add Archetype… 按钮添加 org .codehaus.mojo:gwt-maven-plugin:2.7.0.

<小时/>

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

关于java - 如何更新 gwt-maven-plugin 原型(prototype)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30250914/

相关文章:

java - hibernate ,从集合中删除

eclipse - 如何打开包含事件 Eclipse 编辑器文件的外部 Vim 编辑器

java - 我如何找出所有格表达以及它们之间的联系?

java - 在 cassandra 中使用 TTL 指定列过期时间

eclipse - 没有参数的方法不适用于 eclipse java

maven - tomcat7-maven-plugin 部署 spring boot 并选择合适的 spring 配置文件

maven - 为什么我无法下载 MysqlConnectionPoolDataSource 源并使用 Maven 查找 javadoc?

Java项目目录结构约定

java - 使用 Web 浏览器延迟 JOptionPane

Eclipse Che 没有启动