POM file to adapt Maven to GWT's directory structure

5 views
Skip to first unread message

Laird Nelson

unread,
Apr 22, 2009, 4:39:28 PM4/22/09
to Codehaus Mojo gwt-maven-plugin Users
I managed to get a POM file that adapts Maven to the GWT directory
structure while also playing nicely with the gwt-maven-plugin.

The relevant bits are as follows:

<dependencies>
<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>
</dependencies>

<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<outputDirectory>war/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>${project.build.sourceDirectory}</directory>
<targetPath></targetPath>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warSourceDirectory>${basedir}/war</warSourceDirectory>
<!--
We don't need to include any sources to copy to the
target,
because the target *is* our source.
-->
<warSourceIncludes></warSourceIncludes>
<warSourceExcludes>**</warSourceExcludes>
<webappDirectory>${basedir}/war</webappDirectory>
<webXml>${basedir}/war/WEB-INF/web.xml</webXml>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<!--
<goal>generateAsync</goal>
-->
</goals>
</execution>
</executions>
<configuration>
<runTarget>path.to.your.Module/../Module.html</runTarget>
<output>${basedir}/war</output>
<webXml>${basedir}/war/WEB-INF/web.xml</webXml>
<hostedWebapp>${basedir}/war</hostedWebapp>
</configuration>
</plugin>

</plugins>
</build>

<pluginRepositories>
<pluginRepository>
<id>Codehaus</id>
<url>http://snapshots.repository.codehaus.org</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

<!--
These are properties that can be referred to in other Maven
POMs. They're
probably not all that interesting to someone new to Maven.
-->
<properties>
<gwt.version>1.6.4</gwt.version>
</properties>

I hope this helps folks.

Best,
Laird

Agustín Gañán

unread,
Apr 23, 2009, 4:05:07 AM4/23/09
to codehaus-mojo-gwt-...@googlegroups.com
Hi all,

Laird, what's the property  <hostedWebapp>${basedir}/war</hostedWebapp> doing in the gwt plugin configuration?
I'm looking for it in the docs and in the AbstractGwtShellMojo and I can't find it.

Regards,

Agus

2009/4/22 Laird Nelson <ljne...@gmail.com>

nicolas de loof

unread,
Apr 23, 2009, 4:17:13 AM4/23/09
to codehaus-mojo-gwt-...@googlegroups.com
This one defines the hosted mode webroot (that SHOULD be distinct from maven war webroot). As the Google Eclipse plugin uses this hardcoded path, "/war" is now the default value.

2009/4/23 Agustín Gañán <agu...@gmail.com>

Agustín Gañán

unread,
Apr 23, 2009, 4:40:37 AM4/23/09
to codehaus-mojo-gwt-...@googlegroups.com
>(that SHOULD be distinct from maven war webroot)

Do you mean that I can use src/main/webapp as <hostedWebapp>?


2009/4/23 nicolas de loof <nicolas...@gmail.com>

nicolas de loof

unread,
Apr 23, 2009, 7:11:24 AM4/23/09
to codehaus-mojo-gwt-...@googlegroups.com
No, for running the hosted mode - i.e. testing the GWT UI with mock server-side components - the /war is the best choice as it matches Google Eclipse plugin configuration (but maybe you don't use Eclipse)

for GWT compilation, src/main/webapp is a good choice as it can be used to run the webapplication (full server-side components) inplace, with no packaging and deployment phase on server, for example using mvn jetty:run.

Cheers,
Nicolas

2009/4/23 Agustín Gañán <agu...@gmail.com>

Agustín Gañán

unread,
Apr 23, 2009, 9:18:46 AM4/23/09
to codehaus-mojo-gwt-...@googlegroups.com
My little contribution:
With this POM[1] ( I post only the plugins config) I'm able to run the hosted mode (mvn clean install gwt:run) and also generate a valid war to deploy in an app server (I've tested it in jetty and Tomcat 6). I also can run the embedded jetty server (mvn clean install jetty:run).
 
I'm not using the eclipse plugin but I think it's easy to adapt this config.

The gwt version is 1.6.4

Hope this helps,

Agus
       
[1]
<!--
            GWT Plug-in GWT
            (http://mojo.codehaus.org/gwt-maven-plugin/)
         -->

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>gwt-maven-plugin</artifactId>
            <version>1.1-SNAPSHOT</version>
            <configuration>
                <runTarget>
                   mymodule.gwt.spring.Prototype/Prototype.html
                </runTarget>
                <output>${project.build.directory}/war/${artifactId}-${pom.version}</output>
                 <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
                 <hostedWebapp>${project.build.directory}/war/${artifactId}-${pom.version}</hostedWebapp>
                 <module>mymodule.gwt.spring.Prototype</module>
                <rpcPattern>{0}.rpc</rpcPattern>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <!--
                             To generate the asyncInterface of the RPC services
                            -->
                        <goal>generateAsync</goal>
                        <goal>compile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!--
           WAR plugin
         -->

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
               <configuration>
                <warName>${artifactId}-${pom.version}</warName>
                <!-- To include the spring context src/main/webapp/applicationContext.xml -->
                <warSourceDirectory>src/main/webapp</warSourceDirectory>
                <warSourceIncludes>**</warSourceIncludes>
                <warSourceExcludes></warSourceExcludes>
                <webappDirectory>${project.build.directory}/war/${artifactId}-${pom.version}</webappDirectory>
                <webXml>${basedir}/src/main/webapp/WEB-INF/web.xml</webXml>
                <outputDirectory>${project.build.directory}/war</outputDirectory>
              </configuration>
        </plugin>
          <!-- Jetty plugin -->
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.5</version>
                <configuration>
                    <contextPath>/</contextPath>
                    <scanIntervalSeconds>0</scanIntervalSeconds>
                    <connectors>
                        <connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
                        <port>8888</port>
                        <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                <webAppSourceDirectory>
                ${project.build.directory}/war/${artifactId}-${pom.version}
                </webAppSourceDirectory>
                </configuration>
            </plugin>

Farrukh Najmi

unread,
Apr 23, 2009, 10:55:56 AM4/23/09
to codehaus-mojo-gwt-...@googlegroups.com

Dear all, Thanks for all the contributions. Again I would like to propose to dev team to create a samples sub-project which can have one or more samples as sub-projects so that we can all collaboratively come up with simple samples reflecting best practices. Nicolas what do you think?
--
Regards,
Farrukh
Reply all
Reply to author
Forward
0 new messages