Recently I converted my GWT web-app (GWT 2.4.0) to a maven project.
I am using maven 2.2.1, gwt-maven plugin (2.4.0), Eclipse Indigo (3.7) and the m2eclipse plugin.
The dependencies and general configuration seem to be fine as the web-app compiles without any problems and also works in production mode.
The same applies to hosted mode.
However I have a strange behavior: When I change a single line in a Java/GWT source file, the Maven Project Builder
is invoked and this steps takes painfully long (around 10 secs) and eclipse sometimes becomes unusable during this time.
Is this a normal behavior of m2eclipse?
And if it is, is there any way to speed it up?
Note: I had to configure the life cycle plugin for m2eclipse. Here is the important section of the pom file:
<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.4.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->
<configuration>
<runTarget>index.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<i18nMessagesBundle>com.gmi.nordborglab.testapp.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>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<versionRange>[2.4.0,)</versionRange>
<goals>
<goal>resources</goal>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<versionRange>[2.1.1,)</versionRange>
<goals>
<goal>exploded</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
This perfectly illustrates why m2e doesn't let any "unknown" plugins to run on incremental build by default ( http://wiki.eclipse.org/M2E_plugin_execution_not_covered#Background ). Most maven plugins aren't fit for incremental building and do a complete build whenever they're invoked (and as a bonus, you might get classloader leakages).
In your plugin management section, you specified that gwt:resources, gwt:compile and war:exploded should be executed. By default, they're executed on incremental builds, that means on EVERY resource change. Since these goals/plugins aren't optimized for an incremental build, they take a while to complete.
If you want to speed things up, you can tell m2e to execute them only on Full builds (i.e. after a project clean) by using
<execute>
<runOnIncremental>false</runOnIncremental>
</execute>
Then, manually doing an eclipse clean build will automatically trigger their execution. Be aware that JDT sometimes decides to promote incremental builds to full ones.
I believe (but may be wrong) that, if you were using the Google Eclipse Plugin, you could ignore gwt:resources and gwt:compile altogether (by replacing <execute> with <ignore>).