Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does anyone have a sample GWT 2.7.0 pom?

Tags:

maven

gwt

I am trying to use Maven with GWT 2.7.0. Does anyone have a small pom.xml template?

I am particularly looking at clean / install / running (I used gwt:run in a previous project)...

like image 274
jgp Avatar asked Feb 20 '15 17:02

jgp


People also ask

Which is a minimum requirement POM element?

The minimum requirement for a POM are the following: project root. modelVersion - should be set to 4.0. 0.

Does GWT work with Java 11?

The GWT distribution is still compiled to run on Java 7 for this release, but no guarantees are made about whether or not this will work. Future versions will compile bytecode for Java 8+. The release was tested and found to work cross platform when run with Java 8, 11, and 14.

What is show effective POM?

The effective-pom goal is used to make visible the POM that results from the application of interpolation, inheritance and active profiles. It provides a useful way of removing the guesswork about just what ends up in the POM that Maven uses to build your project.

Is there a POM file for every project?

It should be noted that there should be a single POM file for each project. All POM files require the project element and three mandatory fields: groupId, artifactId, version. Projects notation in repository is groupId:artifactId:version.


1 Answers

What you need in your POM is:

  • GWT dependencies (gwt-user at a minimum, never deployed to the server; gwt-servlet for GWT-RPC or other server-side support, classes already included in gwt-user; gwt-dev and gwt-codeserver are recommended, it depends on the plugin you'll use though, never deploy them either)
  • gwt-maven-plugin; there are two of them: org.codehaus.mojo:gwt-maven-plugin (whose version must match the version GWT you're using), and net.ltgt.gwt.maven:gwt-maven-plugin (still in beta; works with any version of GWT)

Depending on the plugin, you'll use different packaging and plugin configuration.

Last, but not least, you really should use distinct Maven modules for client and server side code, plus possibly a third module for shared code. For a small project though, using a single module could be enough (but you'll have to add some configuration / hacks to your POM if you don't want to deploy your client-side classes on your server).

That gives us, for a single-module project (mixed client- and server-side code in the same project), with the CodeHaus Mojo plugin:

<?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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>test</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt</artifactId>
        <version>2.7.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-dev</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-codeserver</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-servlet</artifactId>
      <scope>runtime</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>2.7.0</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <module>com.example.test.Test</module>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

And use mvn gwt:run to run DevMode (which will also run your server-side code, with some limitations).

Or for the net.ltgt plugin:

<?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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>test</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>gwt-app</packaging>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt</artifactId>
        <version>2.7.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-dev</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-codeserver</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-servlet</artifactId>
      <scope>runtime</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>net.ltgt.gwt.maven</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>1.0-beta-1</version>
        <extensions>true</extensions>
        <configuration>
          <moduleName>com.example.test.Test</moduleName>
          <launcherDir>${project.build.directory}/${project.build.finalName}</launcherDir>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

And use mvn gwt:codeserver to run SuperDevMode (client-side code only). You'll have to use the jetty-maven-plugin or tomcat7-maven-plugin to run your server-side code though.


For a multi-module project, have a look at my archetypes: https://github.com/tbroyer/gwt-maven-archetypes I'm in the process of migrating them to the net.ltgt plugin, simplifying how you'll run them (no need to mvn install anymore; mvn gwt:codeserver has been designed for multi-module projects, contrary to CodeHaus Mojo's gwt:run and gwt:run-codeserver)

Disclaimer: I'm the maintainer for both plugins, but I'd favor my own plugin, which IMO fixes a lot of quirks and mistakes and legacy of the CodeHaus Mojo one.

like image 93
Thomas Broyer Avatar answered Sep 19 '22 06:09

Thomas Broyer