When developing, I set the user.agent
property to a single value, to keep compile times down. When releasing, I have a WAR file built for all user agents.
I unfortunately seem to keep forgetting to switch the property, either:
I want to automate this, preferably using the maven-release-plugin.
You want to have 2 different .gwt.xml files - one used for development and one used for production.
There is a good example on the 'Renaming modules' section of Developer Guide/Organizing projects.
The gwt.xml file used for development would inherit from the gwt.xml file used for production and set the user.agent property as well. e.g.:
<module rename-to="com.foo.MyModule">
<inherits name="com.foo.MyModule" />
<set-property name="user.agent" value="ie6" />
</module>
Now, when doing development, you would use the development gwt.xml file, and when doing a production build. you would use the production gwt.xml file.
The easiest way to achieve this with Maven is to activate the development module using a profile. I've written in detail about this at Maven Recipe : GWT development profile.
Create a MavenFilteredUserAgent module that sets user.agent
from various profiles in the pom.xml.
MavenFilteredUserAgent.gwt.xml
...
<set-property name="user.agent" value="${gwt.compile.user.agent}" />
...
pom.xml
...
<properties>
<!-- By default we still want all five rendering engines when none of the following profiles is explicitly specified -->
<gwt.compile.user.agent>ie6,ie8,gecko,gecko1_8,safari,opera</gwt.compile.user.agent>
</properties>
<profiles>
<profile>
<id>gwt-firefox</id>
<properties>
<gwt.compile.user.agent>gecko1_8</gwt.compile.user.agent>
</properties>
</profile>
</profiles>
<!-- Add additional profiles for the browsers you want to singly support -->
....
<build>
<resources>
<resource>
<!-- Put the filtered source files into a directory that later gets added to the build path -->
<directory>src/main/java-filtered</directory>
<filtering>true</filtering>
<targetPath>${project.build.directory}/filtered-sources/java</targetPath>
</resource>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
...
<plugin>
<!-- Add the filtered sources directory to the build path-->
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/filtered-sources/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
...
</plugins>
...
Have all of your modules inherit the MavenFilteredUserAgent module.
Then you can build for just firefox like so.
mvn install -Pgwt-firefox
http://9mmedia.com/blog/?p=854 has more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With