Search code examples
javaeclipsemavengwtmaven-archetype

How to update gwt-maven-plugin Archetype?


I would like to create maven managed gwt project with Eclipse IDE.

I am using GWT 2.7. But when I create a project from File > New > Maven Project and choose gwt as Archetype , please find the image below -

enter image description here

The Version is 2.1.0-1 and generated pom.xml was gwt version 2.1. How can I update this org.codehaus.mojo Archetype ? Or can I setup to generate with my gwt version ?

EDIT: generated pom.xml is below but I am using 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 : Please don't suggest to edit pom.xml file after generated.


Solution

  • It looks like the archetype catalog is out of date in your Eclipse. I don't know how to update it (I don't even know how Maven does it outside of Eclipse), but an easy workaround is to use the Add Archetype… button to add org.codehaus.mojo:gwt-maven-plugin:2.7.0.


    That being said, despite the 2.7.0 archetype being much better than the 2.1.0 one, I don't recommend using it except for small one-off experiments or bug repro cases.
    For any project you expect to maintain and grow in the medium/long term, I strongly advise you use separate Maven modules for the client-side and server-side code. I built archetypes for that multi-module setup: https://github.com/tbroyer/gwt-maven-archetypes; see announcement here. Note also that they don't use the org.codehaus.mojo plugin.