3

I have a GWT project using GWT 2.7.0 and am using maven. The app is compiling and running correctly, however, I am struggling to get GWT's Super Dev Mode to work correctly. When I start Super Dev Mode with

mvn gwt:run-codeserver

Super Dev Mode starts correctly, compiles, and the latest changes ARE shown in the browser. However, when I press the compile bookmarklet to recompile the GWT code, the recompile completes correctly and the browser refreshes but does NOT include any subsequent changes I've made to the client/GWT java files.

When starting GWT Super Dev Mode it appears to copy the source files (.java files) from src/main/java into maven's build folder (target) and it appears to be compiling from source files in the target folder rather than those in src/main/java. I've tested this by manually copying a java file I've made changes to from src/main/java into the target folder, and then hitting the compile bookmarklet. When I do this the recompile succeed as before, and the latest changes are shown.

I am assuming I have either missed some configuration that will copy src/main/java into the target folder whenever I hit the compile bookmarklet, or I have misconfigured Super Dev Mode to compile from the target folder when it should be compiling from sources in src/main java

Any help to understand how it should function and resolve this would be appreciated.

The relevant part of my pom.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?><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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
...
<packaging>war</packaging>
<version>0.1.0.BUILD-SNAPSHOT</version>
...

<properties>
    <java.version>7</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <slf4j.version>1.7.12</slf4j.version>
    <spring.version>4.2.2.RELEASE</spring.version>
    <spring-security.version>3.2.8.RELEASE</spring-security.version>
    <spring-data.version>1.9.0.RELEASE</spring-data.version>
    <spring.integration.version>4.2.0.RELEASE</spring.integration.version>
    <hazelcast.version>3.6.4</hazelcast.version>
    <aspectj.version>1.8.5</aspectj.version>
    <gwt.version>2.7.0</gwt.version>
    <cucumber.version>1.2.4</cucumber.version>
    <togglz.version>2.1.0.Final</togglz.version>
    <apache.poi.version>3.16</apache.poi.version>
    <skipTests>true</skipTests>
</properties>

<repositories>
    <repository>
        <id>spring-maven-release</id>
        <name>Spring Maven Release Repository</name>
        <url>http://maven.springframework.org/release</url>
    </repository>
    <repository>
        <id>spring-maven-milestone</id>
        <name>Spring Maven Milestone Repository</name>
        <url>http://maven.springframework.org/milestone</url>
    </repository>
    <repository>
        <id>maven.springframework.org.external</id>
        <url>http://maven.springframework.org/external</url>
        <name>SpringSource Maven Repository - External Releases</name>
    </repository>
    <repository>
        <id>ailis-releases</id>
        <name>Ailis Maven Releases</name>
        <url>http://nexus.ailis.de/content/groups/public/</url>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>spring-maven-release</id>
        <name>Spring Maven Release Repository</name>
        <url>http://maven.springframework.org/release</url>
    </pluginRepository>
    <pluginRepository>
        <id>spring-maven-milestone</id>
        <name>Spring Maven Milestone Repository</name>
        <url>http://maven.springframework.org/milestone</url>
    </pluginRepository>
</pluginRepositories>

<dependencies>

    <!-- Spring dependencies -->
    ...

    <!-- General dependencies -->

    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjrt</artifactId>
        <version>${aspectj.version}</version>
    </dependency>
    <dependency>
        <groupId>org.aspectj</groupId>
        <artifactId>aspectjweaver</artifactId>
        <version>${aspectj.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.el</groupId>
        <artifactId>javax.el-api</artifactId>
        <version>2.2.2</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>2.2.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <!-- GWT dependencies -->

    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-servlet</artifactId>
        <version>${gwt.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt-user</artifactId>
        <version>${gwt.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.google.gwt.inject</groupId>
        <artifactId>gin</artifactId>
        <version>2.1.2</version>
    </dependency>
    <dependency>
        <groupId>com.google.gwt.eventbinder</groupId>
        <artifactId>eventbinder</artifactId>
        <version>1.1.0</version>
    </dependency>
    <dependency>
        <groupId>com.googlecode.gwtupload</groupId>
        <artifactId>gwtupload</artifactId>
        <version>1.0.3</version>
    </dependency>
    <dependency>
        <groupId>com.google.gwt.google-apis</groupId>
        <artifactId>gwt-visualization</artifactId>
        <version>1.1.2</version>
    </dependency>

</dependencies>

<build>
    <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>

    <plugins>
        <!-- Clean -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <filesets>
                    <fileset>
                        <directory>src/main/webapp/app</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>

        <!-- War -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
        </plugin>

        <!-- Compiler -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <encoding>${project.build.sourceEncoding}</encoding>
            </configuration>
        </plugin>

        <!-- Aspectj -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>aspectj-maven-plugin</artifactId>
            <version>1.4</version>
            <!-- NB: do not use 1.3 or 1.3.x due to MASPECTJ-90 issue  -->
            <dependencies>
                <!-- NB: You must use Maven 2.0.9 or above or these are ignored (see MNG-2972) -->
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjrt</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.aspectj</groupId>
                    <artifactId>aspectjtools</artifactId>
                    <version>${aspectj.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <phase>process-sources</phase>
                    <goals>
                        <goal>compile</goal>
                        <goal>test-compile</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <outxml>true</outxml>
                <aspectLibraries>
                    <aspectLibrary>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-aspects</artifactId>
                    </aspectLibrary>
                </aspectLibraries>
                <source>${java.version}</source>
                <target>${java.version}</target>
                <!--
                  Aspects in src/main/java and src/main/aspects are added
                  as default in the compile goal.
                  Aspects in src/getAllClients/java and src/getAllClients/aspects are added
                  as default in the getAllClients-compile goal.
                  Aspects in src/main/java are added in the getAllClients-compile
                  goal if weaveWithAspectsInMainSourceFolder is set to true
                -->
                <weaveWithAspectsInMainSourceFolder>false</weaveWithAspectsInMainSourceFolder>
            </configuration>
        </plugin>

        <!-- Resources -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <encoding>${project.build.sourceEncoding}</encoding>
            </configuration>
            <executions>
                <execution>
                    <id>copy-resources</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>copy-resources</goal>
                    </goals>
                    <configuration>
                        <outputDirectory>
                            ${project.build.outputDirectory}/za/co/shared/domain/i18n
                        </outputDirectory>
                        <resources>
                            <resource>
                                <directory>src/main/java/za/co/shared/domain/i18n</directory>
                                <includes>
                                    <include>**/*.properties</include>
                                </includes>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <!-- Assembly -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
        </plugin>

        <!-- Deploy -->
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>2.7</version>
        </plugin>

        <!-- Tomcat -->
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <port>8080</port>
                <path>/app</path>
            </configuration>
        </plugin>

        <!-- GWT -->
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>${gwt.version}</version>
            <configuration>
                <logLevel>INFO</logLevel>
                <style>PRETTY</style>
                <runTarget>/app</runTarget>
                <modules>
                    <module>${project.groupId}.app</module>
                </modules>
                <extraJvmArgs>-XX:MaxPermSize=2048m -Xmx2048m</extraJvmArgs>
                <localWorkers>1</localWorkers>
                <inplace>true</inplace>
                <noServer>true</noServer>
                <draftCompile>false</draftCompile>
                <compileReport>false</compileReport>
                <compilerMetrics>false</compilerMetrics>
                <i18nConstantsBundle>za.co.shared.domain.i18n.GlobalConstants</i18nConstantsBundle>
            </configuration>
            <executions>
                <execution>
                    <id>gwt-compile-on-package</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>compile</goal>
                    </goals>
                </execution>
                <execution>
                    <id>gwt-resources</id>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>resources</goal>
                    </goals>
                </execution>
                <execution>
                    <id>gwt-clean</id>
                    <phase>clean</phase>
                    <goals>
                        <goal>clean</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.google.gwt</groupId>
                    <artifactId>gwt-dev</artifactId>
                    <version>${gwt.version}</version>
                </dependency>
                <dependency>
                    <groupId>com.google.gwt</groupId>
                    <artifactId>gwt-user</artifactId>
                    <version>${gwt.version}</version>
                </dependency>
            </dependencies>
        </plugin>

    </plugins>
</build>

trf
  • 1,279
  • 1
  • 13
  • 33
  • Possibly similar to https://stackoverflow.com/questions/45544888/super-dev-mode-doesnt-detect-changes-after-recompiling?rq=1 but no answers there. – trf May 10 '18 at 11:42
  • Workaround: as a hopefully temporary workaround I have used inotifywait and rsync to monitor for file changes and sync them from /src/main/java to the build directory. Seems to work quite well. – trf May 12 '18 at 20:31

2 Answers2

1

https://tbroyer.github.io/gwt-maven-plugin/codeserver.html

Starting with GWT 2.7, you should set the launcherDir property to get recompile on reload. The property should point to a folder that your web server / servlet container will look into for web resources, so that the *.nocache.js file generated by the CodeServer can be loaded by your web browser.

Felix
  • 959
  • 5
  • 13
  • This does not answer the question: this is a different plugin, the excerpt deals with how a recompile is triggered not what is compiled. – Thomas Broyer May 11 '18 at 23:22
  • Then I've misunderstood the problem report. I remembered I faced similar issues and I was missing the `launcherDir`. He hasn't configured it neither. I wonder if it helps anyway. – Felix May 12 '18 at 19:48
  • Thanks for the response @Felix, unfortunately Thomas Broyer is correct, Im am using the org.codehaus.mojo GWT plugin. I tried setting the launcherDir anyway (the org.codehaus.mojo plugin has it too) but it sets where the compiled code is output TO (which is already correct in my case), my problem appears to be where it is looking for the source files to compile FROM. – trf May 12 '18 at 20:24
  • 1
    Just to also mention, I have tried @ThomasBroyer 's plugin which works perfectly and solves my problem, unfortunately my project is not nicely setup with client and server code in separate maven modules which then causes other issues, so that it isn't an option for me until I can separate them. – trf May 12 '18 at 20:25
  • it may not have answered the original question directly but it's solved a related problem for me, so i'm happy :-) – Stik Jan 13 '22 at 14:23
0

Some time I face that problems and I follow those steps: 1. Clear browser cache 2. Clear GWT cache located in temp folder (in USER_HOME folder, it's based on your OS) and in gwt-unitCache folder (in launcherDir)

Sann Tran
  • 159
  • 5