/ Published in: XML
This new version uses maven-antrun-plugin to create the war transient folder to workaround a bug in m2eclipse. It also sets directly the compiler output to WEB-INF/classes in the war transient folder to minimize eclipse configuration (m2eclipse takes care of it now). Thanks to Eugene Kuleshov for the tip !
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?xml version="1.0" encoding="UTF-8"?> <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> <groupId>fr.salvadordiaz.gwt.sample</groupId> <artifactId>maven-example</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>gwt-maven-archetype-project</name> <properties> <!-- convenience to define GWT version in one place --> <gwt.version>1.6.4</gwt.version> <!-- tell the compiler we can use 1.5 --> <maven.compiler.source>1.5</maven.compiler.source> <maven.compiler.target>1.5</maven.compiler.target> <!-- define a transient output directory for gwt --> <gwt.output.directory>${basedir}/target/gwt</gwt.output.directory> <!-- the value of the rename-to attribute in your GWT module configuration --> <gwt.module.alias>Application</gwt.module.alias> </properties> <dependencies> <!-- GWT dependencies (from central repo) --> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-servlet</artifactId> <version>${gwt.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-user</artifactId> <version>${gwt.version}</version> <scope>provided</scope> </dependency> <!-- test --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.4</version> <scope>test</scope> </dependency> </dependencies> <build> <!-- Compile classes into the war transient directory for hosted mode live editing --> <outputDirectory>${gwt.output.directory}/WEB-INF/classes</outputDirectory> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <version>1.1-SNAPSHOT</version> <executions> <execution> <phase>process-classes</phase> <configuration> <output>${gwt.output.directory}</output> <logLevel>INFO</logLevel> </configuration> <goals> <goal>compile</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> <encoding>UTF-8</encoding> <!-- Fix for GWT issue #3439 --> <excludes> <exclude>javax/servlet/**</exclude> </excludes> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.3</version> <!-- set encoding to something not platform dependent --> <configuration> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.2</version> <executions> <!-- This execution copies the war folder to the gwt transient output directory --> <execution> <id>war-folder-creation</id> <phase>process-resources</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <copy todir="${gwt.output.directory}"> <fileset dir="${basedir}/src/main/webapp" /> </copy> </tasks> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <!-- Include GWT compiler output in the war --> <configuration> <webResources> <resource> <!-- this is relative to the pom.xml directory, it's the GWT compiler output --> <directory>${gwt.output.directory}/${gwt.module.alias}</directory> <!-- override the destination directory (WEB-INF/classes) for this resource --> <targetPath>${gwt.module.alias}</targetPath> </resource> </webResources> </configuration> </plugin> </plugins> </build> <!-- This should really be located in your settings.xml but for simplicity's sake we will leave it here --> <pluginRepositories> <pluginRepository> <id>Codehaus Mojo Snapshot</id> <url>http://snapshots.repository.codehaus.org/</url> </pluginRepository> </pluginRepositories> </project>