maven 和新包装 gwt-app 和 gwt-lib 的 GWT CodeServer 增量编译问题

GWT CodeServer incremental compilation issue with maven and the new packaging gwt-app and gwt-lib

我一直在研究 gwt-maven-plugin 的最新变化。最值得注意的是,新包装 gwt-app 和 gwt-lib。

据我了解,如果我有一些代码想在不同的 GWT 应用程序之间重复使用,gwt-lib 会将所有需要的源和 *.gwt.xml 文件打包在紧挨着所有 classes。它就像一个魅力。

如果我选择多模块 maven 反应堆构建,编译时会检测到所有内容,并且我能够毫不费力地成功构建和部署。但是,如果我尝试开发,闪亮的 GWT 2.7 SuperDevMode 无法检测到 gwt-lib 项目中的更改,显然是因为它们是从 jars 中引用的,而不是它们被更改的实际源目录。

为了说明,我使用了 Thomas Broyer 的 modular-requestfactory 原型。

mvn archetype:generate \
   -DarchetypeCatalog=https://oss.sonatype.org/content/repositories/snapshots/ \
   -DarchetypeGroupId=net.ltgt.gwt.archetypes \
   -DarchetypeArtifactId=modular-requestfactorcom.testy \
   -DarchetypeVersion=1.0-SNAPSHOT

我输入了以下信息:

Define value for property 'artifactId': : mvngwt
Define value for property 'version':  1.0-SNAPSHOT: : 
Define value for property 'package':  com.test: : 
Define value for property 'module':  App: : MvngwtApp
Define value for property 'module-short-name':  mvngwtapp: : 

之后我创建了一个名为 "mvn-gwt-client-api" 的附加 maven 模块,其中包含一个将由 mvn-gwt-client 使用的 class。最终结构如下所示:

mvngwt/
--mvngwt-client/
--mvngwt-client-api/
--mvngwt-server/
--mvngwt-shared/
--pom.xml

目标是能够编辑 mvngwt-client-api 中的文件(例如目前唯一的 class:MvngwtApi.java),然后在 SuperDevMode 中重新编译并实际看到无需重新启动 CodeServer 即可立即更改。

可以在此处找到该项目的工作副本:https://github.com/elnicko/maven-gwt-test

PS:我尝试使用 build-helper-maven-plugin 解决它:

<profiles>
        <profile>
            <!-- elnicko: add to support CodeServer hot compile for referenced libraries -->
            <id>env-dev</id>
            <activation>
                <property>
                    <name>env</name>
                    <value>dev</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>add-shared-sources-to-classpath</id>
                                <!-- 
                                <phase>process-classes</phase> 
                                <phase>compile</phase> 
                                -->
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>${basedir}/../mvngwt-client-api/src/main/java</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

然而,这并没有改善这种情况。

任何 hints/pointers/ideas 非常感谢。


编辑:

我可以使用前面提到的 build-helper-maven-plugin 配置来使用 SuperDevMode 增量编译,将 mvngwt-client-api 包装从 "gwt-lib" 更改为 "jar",并添加一个 "maven-source-plugin"。这样 maven 编译和部署的工作方式相同,但是 CodeServer 知道 mvngwt-client-api 源目录中的更改。尽管如此,问题仍然悬而未决,如何在不丢失 CodeServer 增量编译的情况下使用新的 "gwt-lib"。差异可以在这里看到:https://github.com/elnicko/maven-gwt-test/compare/master...working_wihtout_gwt-lib_but_with_jar_packaging

您必须在依赖项中使用 <type>gwt-lib</type>

<dependency>
  <groupId>${project.groupId}</groupId>
  <artifactId>mvngwt-client-api</artifactId>
  <version>${project.version}</version>
  <type>gwt-lib</type>
</dependency>

实际上,如果您 运行 Maven 与 -X 您会在日志中看到:

[DEBUG] Adding sources for com.test:mvngwt-client:gwt-app:1.0-SNAPSHOT
[DEBUG] Ignoring com.test:mvngwt-shared:jar:1.0-SNAPSHOT; neither a java-source, gwt-lib or jar:sources.
[DEBUG] Adding sources for com.test:mvngwt-shared:jar:1.0-SNAPSHOT
[DEBUG] Ignoring com.test:mvngwt-client-api:jar:1.0-SNAPSHOT; neither a java-source, gwt-lib or jar:sources.
[DEBUG] Ignoring com.google.gwt:gwt-user:jar:2.7.0; neither a java-source, gwt-lib or jar:sources.
[DEBUG] Ignoring com.google.gwt:gwt-dev:jar:2.7.0; neither a java-source, gwt-lib or jar:sources.
[DEBUG] Ignoring com.google.gwt:gwt-codeserver:jar:2.7.0; neither a java-source, gwt-lib or jar:sources.

也许那些应该在 INFO 级别而不是 DEBUG 级别发出...


顺便说一句,您可以只使用 <type>java-source</type><classifier>sources</classifier> 依赖项而不是 build-helper-maven-plugin,就像对 mvngwt-shared 模块所做的那样。