每当我更改源文件(GWT)时,将调用Maven Project Builder [英] Maven Project Builder is invoked every time I change a source file (GWT)

查看:107
本文介绍了每当我更改源文件(GWT)时,将调用Maven Project Builder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我把GWT网页应用( GWT 2.4.0 )转换为maven项目。

我正在使用maven 2.2.1, gwt-maven plugin (2.4.0),Eclipse Indigo(3.7)和m2eclipse插件。



依赖关系和一般配置似乎很好,因为网络应用程序编译没有任何问题,也可以在生产模式下工作。

同样适用托管模式。



但是我有一个奇怪的行为:当我在Java / GWT源文件中更改单行时, Maven Project Builder 被调用并且这个步骤痛苦地(约10秒),并且eclipse有时在这段时间不可用。



这是m2eclipse的正常行为吗?



是否有任何方法加速?



注意:我不得不为m2eclipse配置生命周期插件。这是pom文件的重要部分:

 < build> 
<! - 在用于开发模式的文件夹中生成编译的东西 - >
< outputDirectory> $ {webappDirectory} / WEB-INF / classes< / outputDirectory>

< plugins>

<! - GWT Maven插件 - >
< plugin>
< groupId> org.codehaus.mojo< / groupId>
< artifactId> gwt-maven-plugin< / artifactId>
< version> 2.4.0< / version>
<执行>
< execution>
< goals>
< goal> compile< / goal>
< goal> test< / goal>
< / goals>
< / execution>
< / executions>
<! - 插件配置。有很多可用选项,请参阅codehaus.org上的gwt-maven-plugin
文档 - >
< configuration>
< runTarget> index.html< / runTarget>
< hostedWebapp> $ {webappDirectory}< / hostedWebapp>
< i18nMessagesBundle> com.gmi.nordborglab.testapp.client.Messages< / i18nMessagesBundle>
< / configuration>
< / plugin>

<! - 在执行gwt之前复制静态Web文件:run - >
< plugin>
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-war-plugin< / artifactId>
< version> 2.1.1< / version>
<执行>
< execution>
< phase> compile< / phase>
< goals>
< goal> expanding< / goal>
< / goals>
< / execution>
< / executions>
< configuration>
< webappDirectory> $ {webappDirectory}< / webappDirectory>
< / configuration>
< / plugin>
< / plugins>

< pluginManagement>
< plugins>
< plugin>
< groupId> org.eclipse.m2e< / groupId>
< artifactId>生命周期映射< / 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> expanding< / goal>
< / goals>
< / pluginExecutionFilter>
< action>
< execute />
< / action>
< / pluginExecution>

< / pluginExecutions>
< / lifecycleMappingMetadata>
< / configuration>
< / plugin>
< / plugins>
< / pluginManagement>

< / build>


解决方案

这完美地说明了为什么m2e不允许任何未知插件默认运行在增量版本上( http://wiki.eclipse.org/M2E_plugin_execution_not_covered#Background )。大多数maven插件不适合增量建筑,每当调用时都会进行完整的构建(作为奖励,您可能会遇到类加载器泄漏)。



在您的插件管理部分,你指定gwt:resources,gwt:compile和war:expanded应该执行。默认情况下,它们是在增量版本上执行的,这意味着每次更改资源。由于这些目标/插件未针对增量版本进行优化,因此需要一段时间才能完成。



如果要加快速度,可以告诉m2e执行他们只有在完整版本(即项目清理后)使用

 < execute> 
< runOnIncremental> false< / runOnIncremental>
< / execute>

然后,手动执行eclipse clean build会自动触发它们的执行。请注意,JDT有时会决定将增量版本推广到完整版本。



我相信(但可能是错误的),如果您使用Google Eclipse插件,您可以忽略gwt:resources和gwt:compile altogether(通过用< ignore>替换< execute>)。


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>).

这篇关于每当我更改源文件(GWT)时,将调用Maven Project Builder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆