简体   繁体   English

Gaven CodeServer增量编译问题与Maven和新包装的gwt-app和gwt-lib

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

I've been toying around with the latest changes in the gwt-maven-plugin. 我一直在研究gwt-maven-plugin的最新更改。 Most notably, the new packagings gwt-app and gwt-lib. 最值得注意的是,新包装gwt-app和gwt-lib。

To my understanding, if I have some code that I'd like to reuse between different GWT apps, gwt-lib packages all needed sources and *.gwt.xml files in the jar right next to all classes. 据我了解,如果我想在不同的GWT应用程序之间重复使用某些代码,则gwt-lib会将所有需要的源代码和* .gwt.xml文件打包在所有类旁边的jar中。 It works like a charm. 它像一种魅力。

If I opt for a multi-module maven reactor build, everything is detected on compile time and I'm able to build and deploy successfully without any hassle. 如果我选择多模块Maven反应堆构建,那么在编译时就可以检测到所有内容,并且我可以毫无问题地成功构建和部署。 If I try to develop however, the shiny GWT 2.7 SuperDevMode is unable to detect changes in the gwt-lib projects, obviously because they are referenced from the jars and not the actual sources directory where they were changed. 但是,如果我尝试开发,闪亮的GWT 2.7 SuperDevMode无法检测到gwt-lib项目中的更改,显然是因为它们是从jar中引用的,而不是从更改所在的实际source目录中引用的。

To illustrate, I used the modular-requestfactory archetype by Thomas Broyer. 为了说明这一点,我使用了Thomas Broyer的模块化请求原型。

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

and I entered the following information: 我输入了以下信息:

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: : 

Afterwards I created an additional maven module called "mvn-gwt-client-api", which contains a single class that is to be used by the mvn-gwt-client. 之后,我创建了一个名为“ mvn-gwt-client-api”的附加Maven模块,其中包含一个单独的类,该类将由mvn-gwt-client使用。 The end structure looks like this: 最终结构如下所示:

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

The goal is to be able to edit the files in mvngwt-client-api (eg the only class currently: MvngwtApi.java), then recompile in SuperDevMode and actually see the changes immediately without restarting the CodeServer. 目的是能够编辑mvngwt-client-api中的文件(例如,当前唯一的类:MvngwtApi.java),然后在SuperDevMode中重新编译并立即查看更改,而无需重新启动CodeServer。

A working copy of the project can be found here: https://github.com/elnicko/maven-gwt-test 该项目的工作副本可以在这里找到: https : //github.com/elnicko/maven-gwt-test

PS: I tried to work it out with the build-helper-maven-plugin: 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>

However it didn't improve the situation. 但是它并没有改善这种情况。

Any hints/pointers/ideas greatly appreciated. 任何提示/指针/想法,不胜感激。


Edit: 编辑:

I am able to use the SuperDevMode incremental compilation by using the aforementioned build-helper-maven-plugin configuration, changing the mvngwt-client-api packaging from "gwt-lib" to "jar", and adding a "maven-source-plugin". 通过使用上述build-helper-maven-plugin配置,将mvngwt-client-api包装从“ gwt-lib”更改为“ jar”,并添加“ maven-source-plugin”,我可以使用SuperDevMode增量编译。 ”。 That way maven compilation and deployment work the same way, but the CodeServer is made aware of the changes in the source directory of mvngwt-client-api. 这样,maven编译和部署的工作方式相同,但是使CodeServer知道了mvngwt-client-api源目录中的更改。 Nevertheless, the question remains open, how one can use the new "gwt-lib" without losing the CodeServer incremental compilation. 但是,问题仍然悬而未决,即如何使用新的“ gwt-lib”而不丢失CodeServer增量编译。 The diff may be seen here: https://github.com/elnicko/maven-gwt-test/compare/master...working_wihtout_gwt-lib_but_with_jar_packaging 差异可以在这里看到: https : //github.com/elnicko/maven-gwt-test/compare/master...working_wihtout_gwt-lib_but_with_jar_packaging

You have to use <type>gwt-lib</type> in your dependency. 您必须在依赖项中使用<type>gwt-lib</type>

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

Actually, if you run Maven with -X you'll see in the logs: 实际上,如果您使用-X运行Maven,则会在日志中看到:

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

Maybe those should be emitted at INFO level rather than DEBUG… 也许那些应该在INFO级别而不是DEBUG发出。


BTW, instead of the build-helper-maven-plugin, you could have just used a <type>java-source</type> or <classifier>sources</classifier> dependency, like it's done for the mvngwt-shared module. 顺便说一句,您可以只使用<type>java-source</type><classifier>sources</classifier>依赖性,而不是build-helper-maven-plugin,就像对mvngwt-shared模块所做的mvngwt-shared

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM