Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT compilation is skipped in maven when module packaging is pom

I am trying to reuse a assembled gwt compilation in another war. For this i am try to change the current maven module's packaging from war to pom. I then plan to use maven-assembly-plugin to zip up gwt's module js output and use that later on in another war module.

I tried changing the packaging tag from <packaging>war</packaging> to <packaging>pom</packaging> in pom.xml from Validation sample . gwt-maven-plugin never enters into compilation. Instead, it skips compilation!!!!!

  1. What is happening?
  2. Is this expected?
  3. Is there any workaround?

enter image description here

like image 358
appbootup Avatar asked Mar 22 '13 05:03

appbootup


1 Answers

To join multiple gwt compiled modules into a single .war file, it is very easy with the maven-dependency-plugin

  1. Package all your gwt examples as habitual (.war), and install them mvn install or mvn deploy if you have a private maven repo.
  2. Create an empty maven module of type war, with no code but with the maven folder structure, you can put any additional stuff you need here like a global src/main/webapp/index.html.
  3. Configure the new module to use the maven-dependency-plugin like shown below, and run mvn package:

    <dependency>
        <groupId>my.group</groupId>
        <artifactId>example1</artifactId>
        <version>...</version>
        <type>war</type>
    </dependency>
    ...
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
        <execution>
          <id>unpack-gwt-examples</id>
          <phase>prepare-package</phase>
          <goals>
            <goal>unpack-dependencies</goal>
          </goals>
          <configuration>
            <includeGroupIds>my.group</includeGroupIds>
            <includes>**/example1/**</includes>
            <outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}</outputDirectory>
          </configuration>
        </execution>
      </executions>
    </plugin>
    

Finally and related with the gwt-maven-plugin, like with any other maven pluging, it would be enough to select an appropriate phase of the pom-packaging life cycle (package, install or deploy):

  ...
  <packaging>pom</packaging>
  ...
     <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        ...
        <configuration>
        ...
        </configuration>
        <executions>
            <execution>
                <phase>package</phase>
                <goals>
                    <goal>compile</goal>
                </goals>
            </execution>
        </executions>
      </plugin>

Unfortunately, gwt-maven-plugin specifically disallows compilation when packaging is pom, take a look to line #269 of CompileMojo.java

like image 157
Manolo Carrasco Moñino Avatar answered Oct 29 '22 15:10

Manolo Carrasco Moñino