Requirements:
- Pom should work out of the box, not requiring GWT installation beforehand
- GWT 1.5.3
- Maven 2.0.9
- I downloaded the three distribution files from Goolge,
- deleted the doc and sample folders
- re-packaged them as jar files (gwt-dist-windows.jar, gwt-dist-linux.jar and gwt-dist-mac.jar)
- deployed them to our public maven repository http://semweb4j.org/repo/com/google/gwt as
com.google.gwt dist-windows 1.5.3
<!-- http://docs.codehaus.org/display/MAVENUSER/Profiles -->
<profiles>
<profile>
<id>mac</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<properties>
<os>mac</os>
</properties>
</profile>
<profile>
<id>linux</id>
<activation>
<os>
<name>linux</name>
</os>
</activation>
<properties>
<os>linux</os>
</properties>
</profile>
<profile>
<id>windows</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<os>windows</os>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>dev-${os}</artifactId>
<version>${gwtVersion}</version>
<scope>system</scope>
<systemPath>
${basedir}/gwt/gwt-${os}-${gwtVersion}/gwt-dev-${os}.jar
</systemPath>
</dependency>
</dependencies>
</profile>
</profiles>
Note the profiles achieves two things:
- Set the ${os} property (this cannot be achieved otherwise)
- Add a dependency to the gwt-dev jar - which must reside in the same directoy as some other OS-specific files.
Next we need to declare the GWT specific dependencies in the pom. We simply uploaded those to our public maven repository as well (http://semweb4j.org/repo)
<!-- gwt dependencies -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwtVersion}</version>
</dependency>
Now comes the clever part:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>dist-${os}</artifactId>
<version>${gwtVersion}</version>
</dependency>
This instructs maven to fetch our special GWT-dist jar. We also need to unpack it at the right time, which is done here, in
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-gwt</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.google.gwt</groupId>
<artifactId>dist-${os}</artifactId>
<version>1.5.3</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>
${basedir}/gwt
</outputDirectory>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</execution>
</executions>
</plugin>
Together these settings achieve our goals. Feedback welcome.
Sources considered can be found in delicious, tagged with maven2+gwt.
Note to myself: I should install GWT in ${user.home}/gwt-${gwtVersion} and not in the project root. Otherwise several projects have their separate copy of GWT, just wasting disk space.
ReplyDeleteWell, I'm using gwt-maven-plugin from codehaus/mojo and I don't have to install GWT on my machine.
ReplyDeleteHi Xavier, interesting. How can the plugin run the GEt howsted mode without the platform-specific GWT parts?
ReplyDeleteFirst of all, GWT is available on the main maven repository (http://repo1.maven.org/maven2/com/google/gwt/)
ReplyDeleteThen you should try http://gwt-maven.googlecode.com/svn/docs/maven-googlewebtoolkit2-plugin/index.html
which does this for you
with the profile part (same as you wrote)
ReplyDeletelook at: http://gwt-maven.googlecode.com/svn/trunk/maven-googlewebtoolkit2-plugin/simplesample/pom.xml
~j3t
Hi,
ReplyDeleteI'm the gwt-mojo developper. This one uses the same strategy you describe, and use a zip of natives libraries to be used by GWT for hosted mode. This zip is deployed on maven central with the other gwt artifacts.
Cheers,
Nicolas
I've been going this for a long time using the GWT Maven plugin on Google Code.
ReplyDeleteSee http://code.google.com/p/gwt-chronoscope for example. Today I build and test GWT apps across Linux, Windows, and OSX using JetBrains TeamCity continuous integration server. There is no need for any prior configuration of any machine.
Agree, the last gwt maven saves a lot of time by avoiding configuration like this, you really should try it !
ReplyDeleteGuys, thanks for the comments. I am convinces now to look much deeper into the GWT-maven plugin. It evolved very fast when we needed it, so we kept using some older version to get some stability into the build.
ReplyDelete