Modified pom for GWT 1.6.4


/ Published in: XML
Save to your folder(s)

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 !


Copy this code and paste it in your HTML
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <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">
  3. <modelVersion>4.0.0</modelVersion>
  4. <groupId>fr.salvadordiaz.gwt.sample</groupId>
  5. <artifactId>maven-example</artifactId>
  6. <packaging>war</packaging>
  7. <version>1.0-SNAPSHOT</version>
  8. <name>gwt-maven-archetype-project</name>
  9. <properties>
  10. <!-- convenience to define GWT version in one place -->
  11. <gwt.version>1.6.4</gwt.version>
  12. <!-- tell the compiler we can use 1.5 -->
  13. <maven.compiler.source>1.5</maven.compiler.source>
  14. <maven.compiler.target>1.5</maven.compiler.target>
  15. <!-- define a transient output directory for gwt -->
  16. <gwt.output.directory>${basedir}/target/gwt</gwt.output.directory>
  17. <!-- the value of the rename-to attribute in your GWT module configuration -->
  18. <gwt.module.alias>Application</gwt.module.alias>
  19. </properties>
  20. <dependencies>
  21. <!-- GWT dependencies (from central repo) -->
  22. <dependency>
  23. <groupId>com.google.gwt</groupId>
  24. <artifactId>gwt-servlet</artifactId>
  25. <version>${gwt.version}</version>
  26. <scope>runtime</scope>
  27. </dependency>
  28. <dependency>
  29. <groupId>com.google.gwt</groupId>
  30. <artifactId>gwt-user</artifactId>
  31. <version>${gwt.version}</version>
  32. <scope>provided</scope>
  33. </dependency>
  34.  
  35. <!-- test -->
  36. <dependency>
  37. <groupId>junit</groupId>
  38. <artifactId>junit</artifactId>
  39. <version>4.4</version>
  40. <scope>test</scope>
  41. </dependency>
  42. </dependencies>
  43. <build>
  44. <!-- Compile classes into the war transient directory for hosted mode live editing -->
  45. <outputDirectory>${gwt.output.directory}/WEB-INF/classes</outputDirectory>
  46.  
  47. <plugins>
  48. <plugin>
  49. <groupId>org.codehaus.mojo</groupId>
  50. <artifactId>gwt-maven-plugin</artifactId>
  51. <version>1.1-SNAPSHOT</version>
  52. <executions>
  53. <execution>
  54. <phase>process-classes</phase>
  55. <configuration>
  56. <output>${gwt.output.directory}</output>
  57. <logLevel>INFO</logLevel>
  58. </configuration>
  59. <goals>
  60. <goal>compile</goal>
  61. </goals>
  62. </execution>
  63. </executions>
  64. </plugin>
  65.  
  66. <plugin>
  67. <groupId>org.apache.maven.plugins</groupId>
  68. <artifactId>maven-compiler-plugin</artifactId>
  69. <version>2.0.2</version>
  70. <configuration>
  71. <source>${maven.compiler.source}</source>
  72. <target>${maven.compiler.target}</target>
  73. <encoding>UTF-8</encoding>
  74. <!-- Fix for GWT issue #3439 -->
  75. <excludes>
  76. <exclude>javax/servlet/**</exclude>
  77. </excludes>
  78. </configuration>
  79. </plugin>
  80.  
  81. <plugin>
  82. <groupId>org.apache.maven.plugins</groupId>
  83. <artifactId>maven-resources-plugin</artifactId>
  84. <version>2.3</version>
  85. <!-- set encoding to something not platform dependent -->
  86. <configuration>
  87. <encoding>UTF-8</encoding>
  88. </configuration>
  89. </plugin>
  90.  
  91. <plugin>
  92. <groupId>org.apache.maven.plugins</groupId>
  93. <artifactId>maven-antrun-plugin</artifactId>
  94. <version>1.2</version>
  95. <executions>
  96. <!-- This execution copies the war folder to the gwt transient output directory -->
  97. <execution>
  98. <id>war-folder-creation</id>
  99. <phase>process-resources</phase>
  100. <goals>
  101. <goal>run</goal>
  102. </goals>
  103. <configuration>
  104. <tasks>
  105. <copy todir="${gwt.output.directory}">
  106. <fileset dir="${basedir}/src/main/webapp" />
  107. </copy>
  108. </tasks>
  109. </configuration>
  110. </execution>
  111. </executions>
  112. </plugin>
  113.  
  114. <plugin>
  115. <groupId>org.apache.maven.plugins</groupId>
  116. <artifactId>maven-war-plugin</artifactId>
  117. <!-- Include GWT compiler output in the war -->
  118. <configuration>
  119. <webResources>
  120. <resource>
  121. <!-- this is relative to the pom.xml directory, it's the GWT compiler output -->
  122. <directory>${gwt.output.directory}/${gwt.module.alias}</directory>
  123. <!-- override the destination directory (WEB-INF/classes) for this resource -->
  124. <targetPath>${gwt.module.alias}</targetPath>
  125. </resource>
  126. </webResources>
  127. </configuration>
  128. </plugin>
  129. </plugins>
  130. </build>
  131.  
  132. <!-- This should really be located in your settings.xml but for simplicity's sake we will leave it here -->
  133. <pluginRepositories>
  134. <pluginRepository>
  135. <id>Codehaus Mojo Snapshot</id>
  136. <url>http://snapshots.repository.codehaus.org/</url>
  137. </pluginRepository>
  138. </pluginRepositories>
  139. </project>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.