Saturday, April 12, 2014

Setting up a Maven GWT project in Eclipse with the GWT Maven Plugin

This how-to assumes that you have the GWT Maven Plugin.

In Eclipse, choose File -> New -> Other and select a wizard, and select "Maven Project"



Here do nothing. Just press "Next"


Type in "gwt" and select the "gwt-maven-plugin" Artifact id.


Enter the appropriate archetype parameters. Here: org.wmmnpr and mykita


The new maven project should have the following structure.

To correct the project errors modify the"pom.xml". In this example the gwt.version, maven.compiler.source and maven.compiler.target had to be set to 2.6.0, 1.7 and 1.7 respectively. Also embedd the build.plugin XML element within a pluginManagement element as follows:

 <build>
    <outputDirectory>war/WEB-INF/classes</outputDirectory>
    <pluginManagement>
    <plugins>
.
.
    </plugins>
    </pluginManagement>
Run from the context menu: Maven->Update Project ...



The error should disappear.

From the context menu, select "Run As" -> "Run Configurations..."

In "Goals" type "gwt:compile"


If the following error occurs, then
[ERROR] Failed to execute goal org.codehaus.mojo:gwt-maven-plugin:1.2.jboss:compile (default-cli) on project mykita: Execution default-cli of goal org.codehaus.mojo:gwt-maven-plugin:1.2.jboss:compile failed: A required class was missing while executing org.codehaus.mojo:gwt-maven-plugin:1.2.jboss:compile: org/codehaus/plexus/util/xml/XmlStreamReader

Change the version of the gwt-maven-plugin to 2.6.0 and run it again.

        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>2.6.0</version>

In the "Run Configuration" set-up, change the goal to gwt:run and press the "Run" button.



Here, select "Launch Default Browser" to see the application.


No comments:

Post a Comment