tbroyer / gwt-maven-archetypes

Apache License 2.0
152 stars 39 forks source link

External modules in super dev mode compilation #42

Closed vegegoku closed 8 years ago

vegegoku commented 8 years ago

Hi first, thank you for the great work, now to the issue. i created a new gwt application using he multi module archetype, and i was able to get it running, and when i change some code in the client project the changes are being reflected when i press f5 which is awesome, then i tried to do something else, i brought another gwt module that i wrote some time in the past, this new module has its own client, serve, shared packages and is a maven project already installed on my local maven repository. i added this module inheritance to the multi module application inside the gwt.xml of the client project, and then rerun the application. every thing worked find and my new module was integrated and running successfully.

then i decided to change something in my external module client part then rebuild it and installed it in local maven repo. now when i press f5 in my browser no compilation happens and the changes are not applied. is there any way to make the plugin detect the changes in the inherited modules from external?

asdnf commented 8 years ago

seems like the plugin you built cannot be rescanned at runtime. You will have to rerun your code server each time yo build your external module. There is another option still.

       <profile>
            <id>superdevmode-server</id>
            <build>
                <defaultGoal>org.codehaus.mojo:exec-maven-plugin:java</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.4.0</version>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <mainClass>com.google.gwt.dev.codeserver.CodeServer</mainClass>
                            <environmentVariables>-DlogLevel=DEBUG</environmentVariables>
                            <arguments>
                                <argument>org.something.gwt.demo.DemoWidgetSet</argument>
                                <argument>-src</argument>
                                <argument>../demo/src/main/java</argument>
                            </arguments>
                            <classpathScope>compile</classpathScope>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>```

Specify your sources path for _-src_ argument which corresponds your external module sources root.
This will make maven plugin to watch for these sources too. You will even have no need to rebuild that module every time.
vegegoku commented 8 years ago

Sorry, still not working, is there anyway to debug or track why my external module changes are not picked up in the incremental compilation process? or is there a way to construct my external module to be detectable by incremental compilation?

tbroyer commented 8 years ago

@asdnf A much cleaner way when working on multiple projects simultaneously is to make an aggregator POM for your projects and work from it:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>whatever</groupId>
  <artifactId>whatever</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>

  <modules>
    <module>/path/to/first/project</module>
    <module>/path/to/second/project</module>
  </modules>

  <build>
    <plugins>
      <plugin>
        <groupId>net.ltgt.gwt.maven</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>1.0-rc-6</version>
        <inherited>false</inherited>
        <configuration>
           …
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

That way, the "other project" will be part of the reactor build.

tbroyer commented 8 years ago

@vegegoku AFAICT, JARs in the classpath are cached by the JVM, so you have to restart the JVM whenever you make a change for it. To have the JVM see the changes, you have to give the sources as discrete files in a root folder, and for that you should (with the net.ltgt.gwt.maven:gwt-maven-plugin, and without hacks) put all your projects in the same reactor build, so that the gwt-maven-plugin passes the module's source roots as -src arguments to the GWT CodeServer.

vegegoku commented 8 years ago

By adding my external module to my workspace then add it as a sub module in the main module pom file -same as the shared module- it worked like a charm, now i can change that sub-module and when i refresh the browser it re-compiles. the only thing remaining now is to apply incremental compilation, i wonder if this possible with the this plugin?!

branflake2267 commented 8 years ago

I figured I'd follow up with my angle. It's possible in any configuration as long as the [project].nocache.js has the sdm initialization to do the first compile and subsequent incremental compiles. (As long as that xxx.nocache.js file hostname points to the code server.)