leponceau.org

Programming And Stuff, You Know The Thing…

Example GWT Maven pom.xml

Posted at — Mar 11, 2013

Supports:

    <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>com.gwt</groupId>
        <artifactId>gwt-ui-sandbox</artifactId>
        <packaging>war</packaging>
        <version>0.0.1-SNAPSHOT</version>
        <name>GWT UI Sandbox</name>
        
        <properties>
            <license.licenseName>apache_v2</license.licenseName>
            <license.inceptionYear>2012</license.inceptionYear>
    
            <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
            <default.encoding>UTF-8</default.encoding>
            <project.build.sourceEncoding>${default.encoding}</project.build.sourceEncoding>
            <project.reporting.outputEncoding>${default.encoding}</project.reporting.outputEncoding>
            <maven.compiler.plugin.encoding>${default.encoding}</maven.compiler.plugin.encoding>
            <gwt.version>2.5.0</gwt.version>
        </properties>
    
        <dependencies>
            <dependency>
                <groupId>com.google.gwt</groupId>
                <artifactId>gwt-user</artifactId>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
            </dependency>
            <dependency>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </dependency>        
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
            </dependency>
        </dependencies>
    
    
        <build>
            <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
            
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <filtering>false</filtering>
                    <excludes>
                        <exclude>**/*.css</exclude>
                        <exclude>**/Messages.properties</exclude>
                    </excludes>
                </resource>
            </resources>        
            
            <plugins>
                <!--            <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>license-maven-plugin</artifactId>
                    <version>1.1</version>
                    <executions>
                        <execution>
                            <id>first</id>
                            <goals>
                                <goal>update-file-header</goal>
                            </goals>
                            <phase>process-sources</phase>
                        </execution>
                    </executions>
                </plugin>-->
                            
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.5.1</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
                
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.6</version>
                </plugin>
                
                <!-- Copy static web files before executing gwt:run -->
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.3</version>
                    <executions>
                        <execution>
                            <phase>compile</phase>
                            <goals>
                                <goal>exploded</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <webappDirectory>${webappDirectory}</webappDirectory>
                    </configuration>                
                </plugin>
                
                <plugin>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>2.1.2</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                
                <plugin>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.6</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>            
                
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.8.1</version>
                </plugin>
                
                <plugin>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>8.1.9.v20130131</version>
                    <executions>                
                        <execution>
                            <id>start-jetty</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>deploy-war</goal>
                            </goals>
                            <configuration>
                                <daemon>true</daemon>
                                <scanIntervalSeconds>0</scanIntervalSeconds>
                                
                            </configuration>
                        </execution>
                        <execution>
                            <id>stop-jetty</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                        </execution>
                    </executions>    
                    <configuration>
                        <systemProperties>
                            <systemProperty>
                                <name>some.prop</name>
                                <value>false</value>
                            </systemProperty>
                        </systemProperties>
                        <stopKey>stop</stopKey>
                        <stopPort>8079</stopPort>
                    </configuration>
                </plugin>
    
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>gwt-maven-plugin</artifactId>
                    <version>${gwt.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compile</goal>
                                <goal>css</goal>
                                <goal>i18n</goal>
                                <goal>generateAsync</goal>
                                <!-- package source files with .class files: -->
                                <!-- (this is not good for dev mode incremental parsing) -->
                                <!-- <goal>resources</goal> -->
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <runTarget>index.html</runTarget>
                        <hostedWebapp>${webappDirectory}</hostedWebapp>
                        <compileReport>false</compileReport>
                        <style>PRETTY</style>
                        <draftCompile>true</draftCompile>
                        <logLevel>INFO</logLevel>
                        
                        <mode>manual</mode>
                        <productionMode>true</productionMode>
                        <remoteweb>rmi://127.0.0.1/chromium</remoteweb>
                        <browser>/usr/bin/chromium-browser</browser>
                        <timeOut>${gwt.timeout}</timeOut>
                        
                        <i18nMessagesBundles>
                            <!-- need to compile only one language in order to make the compiler happy... -->
                            <!-- My guess: GWT seems to directly use the properties files when using translations from sub-modules -->
                            <i18nMessagesBundle>com.gwt.uisandbox.Messages</i18nMessagesBundle>
                        </i18nMessagesBundles>
                        
                        <cssFiles>
                            <cssFile>com/gwt/uisandbox/Style.css</cssFile>
                        </cssFiles>
                    </configuration>
                </plugin>
                
                <plugin>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <version>1.7</version>
                    <executions>
                        <execution>
                            <phase>process-resources</phase>
                            <configuration>
                                <target>
                                    <!-- http://code.google.com/p/google-web-toolkit/issues/detail?id=4599 -->
                                    <replace dir="${basedir}">
                                        <include name="target/generated-sources/gwt/com/gwt/uisandbox/Style.java"/>
                                        <replacetoken>interface Style extends CssResource {</replacetoken>
                                        <replacevalue>public interface Style extends CssResource {</replacevalue>
                                    </replace>
                                </target>
                            </configuration>
                            <goals>
                                <goal>run</goal>
                            </goals>                        
                        </execution>
                    </executions>
                </plugin>
                
                <!-- http://maven.apache.org/plugins/maven-enforcer-plugin/plugin-info.html -->
                <plugin>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>enforce-sane-versions</id>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                            <configuration>
                                <rules>
                                    <requirePluginVersions />
                                    <DependencyConvergence />
                                </rules>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
            
            <pluginManagement>
                <plugins>
                    <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <version>2.5</version>
                    </plugin>        
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>2.6</version>
                    </plugin>        
                    <plugin>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>2.1.2</version>
                    </plugin>        
                    <plugin>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <version>2.7</version>
                    </plugin>        
                    <plugin>
                        <artifactId>maven-install-plugin</artifactId>
                        <version>2.4</version>
                    </plugin>        
                    <plugin>
                        <artifactId>maven-site-plugin</artifactId>
                        <version>3.2</version>
                    </plugin>        
                    <plugin>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>2.4</version>
                    </plugin>        
                    <plugin>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <version>1.2</version>
                    </plugin>
                    <plugin>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.9</version>
                    </plugin>                
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.13</version>
                    </plugin>        
                </plugins>
            </pluginManagement>
        </build>
        
        <dependencyManagement>
            <dependencies>
                <dependency>
                    <groupId>commons-codec</groupId>
                    <artifactId>commons-codec</artifactId>
                    <version>1.7</version>
                </dependency>
                <dependency>
                    <groupId>com.google.gwt</groupId>
                    <artifactId>gwt-user</artifactId>
                    <version>${gwt.version}</version>
                    <!-- netbeans needs provided scope to find gwt sources (when debuggung) -->
                    <scope>provided</scope>
                </dependency>
                <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                    <version>1.2.17</version>
                </dependency>
                <dependency>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                    <version>4.11</version>
                </dependency>
                <dependency>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                    <version>1.6.6</version>
                </dependency>
                <dependency>
                    <groupId>commons-io</groupId>
                    <artifactId>commons-io</artifactId>
                    <version>2.4</version>
                </dependency>
            </dependencies>
        </dependencyManagement>
    </project>