Skip to content

Commit

Permalink
Move to net.ltgt.gwt.maven:gwt-maven-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
tbroyer committed Feb 23, 2015
1 parent 3f53aa7 commit b3ef2b9
Show file tree
Hide file tree
Showing 34 changed files with 258 additions and 720 deletions.
62 changes: 13 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,66 +36,30 @@ delete the `src/test` folder thus bypassing tests (provided the tests pass on th
continuous integration platform, it's not a big _risk_).


### Use SuperDevMode
### Start the development mode

Change directory to your generated project and issue the following commands:

1. `mvn clean install -Dgwt.draftCompile`
2. In one terminal window: `cd *-client && mvn gwt:run-codeserver -Ddev`
3. In another terminal window: `mvn tomcat7:run -Ddev`
1. In one terminal window: `mvn gwt:codeserver -pl *-client -am`
2. In another terminal window: `mvn tomcat7:run -pl *-server -am -Denv=dev`

The same is available with `tomcat6` instead of `tomcat7`.

Or if you'd rather use Jetty than Tomcat, use `cd *-server && mvn jetty:start -Ddev` instead of `mvn tomcat7:run`.

Note that you only need to `install` once so that `gwt:run-codeserver` and `jetty:start`
can find the other modules. This is currently needed because neither `gwt:run`
nor `jetty:start` support running in reactor builds, contrary to `tomcat7:run`.

The `-Dgwt.draftCompile` in the first step is not required, it's only to speed up the
GWT compilation by disabling optimizations.

### Start the development mode

This is similar to using SuperDevMode, except you can use `-Dgwt.compiler.skip`
instead of `-Dgwt.draftCompile` to speed up the first step (it only has to be done once
though so it's probably no big deal), and more importantly you'll use `mvn gwt:run`
instead of `mvn gwt:run-codeserver`.
Or if you'd rather use Jetty than Tomcat, use `cd *-server && mvn jetty:start -Denv=dev` instead of `mvn tomcat7:run`.

Steps therefore become:

1. `mvn clean install -Dgwt.compiler.skip`
2. In one terminal window: `cd *-client && mvn gwt:run -Ddev`
3. In another terminal window: `mvn tomcat7:run -Ddev`
Note that the `-pl` and `-am` are not strictly necessary, they just tell Maven not to
build the client module when you're dealing with the server one, and vice versa.


### Profiles

There's a special profile defined in the POM file of client and server modules:
`dev`, which is used only when developping. It configures the Tomcat and Jetty
plugins and speeds up development with `gwt:run-codeserver`, `gwt:run` and
`jetty:start` by not requiring a restart when a change to the
`${rootArtifactId}-shared` is made.

To activate the `dev` profile you can provide the `-Ddev` system property, or
use `-Pdev`.

### Productivity tips

When working on the server-side code exclusively, you don't need GWT's DevMode.
You can then compile the GWT app using `mvn package` or `mvn package -Dgwt.draftCompile`
and then `mvn tomcat7:run` or `cd *-server && mvn jetty:start -Ddev`. The
webapp will be redeployed automatically when you change a class (either
compiled by your IDE, or by `mvn compile`) in either the
`${rootArtifactId}-server` or `${rootArtifactId}-shared` module (be careful
though when changing classes in `shared` that you do not break the GWT client
code, particularly when using GWT-RPC).

When working on the client-side code exclusively, to quickly test it in a
browser in production mode, use `mvn package -Dgwt.draftCompile`. You can use
`mvn package -Dgwt.draftCompile -pl :${rootArtifactId}-client -am` while the
Tomcat or Jetty server is running (launched by `mvn tomcat7:run` or
`cd *-server && mvn jetty:start -Ddev`), and then simply hit `F5` in your browser.
There's a special profile defined in the POM file of server modules:
`env-dev`, which is used only when developping. It configures the Tomcat and Jetty
plugins and removes the dependency on the client module (declared in the `env-prod`
profile, active by default.)

To activate the `env-dev` profile you can provide the `-Denv=dev` system property, or
use `-Penv-dev`.

Compatibility
-------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory>src/main/webapp</directory>
<directory>src/main</directory>
<includes>
<include>**/*.xml</include>
<include>module.gwt.xml</include>
</includes>
</fileSet>
</fileSets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,131 +10,60 @@
</parent>

<artifactId>${artifactId}</artifactId>
<packaging>war</packaging>
<packaging>gwt-app</packaging>

<prerequisites>
<maven>${mavenVersion}</maven>
</prerequisites>

<properties>
<gwt.genParam>false</gwt.genParam>
<!-- keep in sync with ${rootArtifactId}-server -->
<runTarget>http://localhost:8080/</runTarget>
</properties>

<dependencies>
<!-- XXX: use scope=provided for all dependencies to avoid copying them into WEB-INF/lib -->
<dependency>
<groupId>${dollar}{project.groupId}</groupId>
<artifactId>${rootArtifactId}-shared</artifactId>
<version>${dollar}{project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>${dollar}{project.groupId}</groupId>
<artifactId>${rootArtifactId}-shared</artifactId>
<version>${dollar}{project.version}</version>
<classifier>sources</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-codeserver</artifactId>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt.inject</groupId>
<artifactId>gin</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-gwt</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<configuration>
<module>${package}.${module}</module>
<genParam>${dollar}{gwt.genParam}</genParam>
<noserver>true</noserver>
<runTarget>${dollar}{runTarget}</runTarget>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>WEB-INF/**</packagingExcludes>
<moduleName>${package}.${module}</moduleName>
<moduleShortName>${module-short-name}</moduleShortName>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<profiles>
<profile>
<id>dev</id>
<activation>
<property>
<name>dev</name>
</property>
</activation>
<build>
<!-- FIXME: workaround for MGWT-332 -->
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-shared-sources-to-classpath</id>
<!-- After 'compile' so they're not compiled to ${dollar}{project.build.outputDirectory} -->
<!-- But before 'process-classes' to make them available to 'gwt:run' -->
<!-- Use add-source because gwt-maven-plugin adds sources to the classpath, not resources. -->
<phase>process-classes</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<!-- Only sources, resources come from target/classes (to support filtering) -->
<source>${dollar}{basedir}/../${rootArtifactId}-shared/src/main/java</source>
<source>${dollar}{basedir}/../${rootArtifactId}-shared/target/classes</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to="${module-short-name}">
<module>
<inherits name="com.google.common.base.Base" />
<inherits name="com.google.gwt.activity.Activity" />
<inherits name="com.google.gwt.inject.Inject" />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
<artifactId>${rootArtifactId}-shared</artifactId>
<version>${dollar}{project.version}</version>
</dependency>
<dependency>
<groupId>${dollar}{project.groupId}</groupId>
<artifactId>${rootArtifactId}-client</artifactId>
<version>${dollar}{project.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.web.bindery</groupId>
<artifactId>requestfactory-apt</artifactId>
Expand Down Expand Up @@ -135,10 +128,27 @@

<profiles>
<profile>
<id>dev</id>
<!-- XXX: We want to exclude ${rootArtifactId}-client from 'env-dev' profile, Maven forces us to make a 'env-prod' profile -->
<id>env-prod</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>${dollar}{project.groupId}</groupId>
<artifactId>${rootArtifactId}-client</artifactId>
<version>${dollar}{project.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
</dependencies>
</profile>
<profile>
<id>env-dev</id>
<activation>
<property>
<name>dev</name>
<name>env</name>
<value>dev</value>
</property>
</activation>
<build>
Expand All @@ -151,7 +161,7 @@
<scanIntervalSeconds>1</scanIntervalSeconds>
<webApp>
<baseResource implementation="org.eclipse.jetty.util.resource.ResourceCollection">
<resourcesAsCSV>src/main/webapp,${dollar}{basedir}/../${rootArtifactId}-client/target/${rootArtifactId}-client-${dollar}{project.version}/</resourcesAsCSV>
<resourcesAsCSV>src/main/webapp,${dollar}{basedir}/../target/gwt/launcherDir/</resourcesAsCSV>
</baseResource>
<extraClasspath>${dollar}{basedir}/../${rootArtifactId}-shared/target/classes/</extraClasspath>
</webApp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#set( $dollar = '$' )
<Context reloadable="true">

<!-- FIXME: workaround for https://issues.apache.org/jira/browse/MTOMCAT-158 -->
<Resources className="org.apache.naming.resources.VirtualDirContext"
extraResourcePaths="/${module-short-name}=${dollar}{basedir}/../${rootArtifactId}-client/target/${rootArtifactId}-client-${dollar}{project.version}/${module-short-name}/" />
extraResourcePaths="/=${dollar}{basedir}/../target/gwt/launcherDir/" />
</Context>
46 changes: 13 additions & 33 deletions guice-rf-activities/src/main/resources/archetype-resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<launcherDir>${project.build.directory}/gwt/launcherDir</launcherDir>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
Expand All @@ -88,40 +98,20 @@
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.3.v20140905</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.7.0</version>
<version>1.0-beta-1</version>
<extensions>true</extensions>
<configuration>
<deploy>${dollar}{project.build.directory}/gwtc/extra</deploy>
<extra>${dollar}{project.build.directory}/gwtc/extra</extra>
<gen>${dollar}{project.build.directory}/gwtc/gen</gen>
<!-- There's an issue on Mac: see http://code.google.com/p/google-web-toolkit/issues/detail?id=7474
<workDir>${dollar}{project.build.directory}/gwtc/work</workDir>
<codeServerWorkDir>${dollar}{project.build.directory}/gwtc/superDevMode</codeServerWorkDir>
-->
<sourceLevel>1.7</sourceLevel>
<failOnError>true</failOnError>
</configuration>
<executions>
<execution>
<id>gwt-compile</id>
<phase>prepare-package</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
Expand All @@ -146,16 +136,6 @@
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.5</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
Expand Down
Loading

0 comments on commit b3ef2b9

Please sign in to comment.