el.nicko
el.nicko

Reputation: 473

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. Most notably, the new packagings gwt-app and 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. 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. 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.

To illustrate, I used the modular-requestfactory archetype by 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. 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 (e. g. the only class currently: MvngwtApi.java), then recompile in SuperDevMode and actually see the changes immediately without restarting the CodeServer.

A working copy of the project can be found here: https://github.com/elnicko/maven-gwt-test

PS: I tried to work it out with the 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". 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. Nevertheless, the question remains open, how one can use the new "gwt-lib" without losing the CodeServer incremental compilation. The diff may be seen here: https://github.com/elnicko/maven-gwt-test/compare/master...working_wihtout_gwt-lib_but_with_jar_packaging

Upvotes: 2

Views: 658

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64541

You have to use <type>gwt-lib</type> in your dependency.

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

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


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.

Upvotes: 3

Related Questions