0

I'm getting the error below when when I try to compile. The goal is gwt:compile I do set the moduleName as a variable. The module name is com.example.app.App

Same thing command line ~/work/projects/gwt/app$ mvn gwt:compile "-DmoduleName=com.example.app.App"

Failed to execute goal net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-6:compile (default-cli) on project mysandbox: The parameters 'moduleName' for goal net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-6:compile are missing or invalid -> [Help 1]

On the other hand mvn package worked.

Here's my pom:

<?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>app</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>

  <prerequisites>
    <maven>${mavenVersion}</maven>
  </prerequisites>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <mavenVersion>3.0</mavenVersion>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt</artifactId>
        <version>2.8.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>net.ltgt.gwt.maven</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <inherited>false</inherited>
        <configuration>
          <launcherDir>${project.build.directory}/gwt/launcherDir</launcherDir>
        </configuration>
      </plugin>
    </plugins>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <!-- Do not upgrade past 3.1 to avoid triggering https://issues.apache.org/jira/browse/MSOURCES-95 -->
          <version>3.1</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.eclipse.jetty</groupId>
          <artifactId>jetty-maven-plugin</artifactId>
          <version>9.3.14.v20161028</version>
          <configuration>
            <skip>true</skip>
          </configuration>
        </plugin>
        <plugin>
          <groupId>net.ltgt.gwt.maven</groupId>
          <artifactId>gwt-maven-plugin</artifactId>
          <version>1.0-rc-6</version>
          <extensions>true</extensions>
          <configuration>
            <sourceLevel>1.8</sourceLevel>
            <failOnError>true</failOnError>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.0.1</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <phase>package</phase>
              <goals>
                <goal>jar-no-fork</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat6-maven-plugin</artifactId>
          <version>2.2</version>
        </plugin>
        <plugin>
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat7-maven-plugin</artifactId>
          <version>2.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  <modules>
    <module>app-client</module>
    <module>app-shared</module>
    <module>app-server</module>
  </modules>
</project>
Spiff
  • 3,873
  • 4
  • 25
  • 50
  • 1
    Can you show your POM? (BTW, why do you want to only `gwt:compile`? which would not e.g. process your resources, run your annotation processors and add the generated sources directory as a source root) – Thomas Broyer Jul 01 '18 at 18:01
  • I thought that I had to gwt:compile and then gwt:package-app,here's the pom. – Spiff Jul 07 '18 at 13:23
  • 1
    If you want to package your project, then `mvn package` and that's it. If you'd like to "call" any "task" and have all other required "tasks" executed automatically, then I'm afraid Maven (and its linear build lifecycle) is not the appropriate tool (have a look at Gradle rather). – Thomas Broyer Jul 08 '18 at 11:27

1 Answers1

3

So, you have a multi-module Maven project. Invoking mvn gwt:compile will try to execute that "goal" on each of the 4 modules (root module and 3 submodules). Because your moduleName property (used to configure the moduleName property of the gwt:compile goal) likely only exists in the app-client submodule, gwt:compile fails when applied to the root module or the app-shared submodule.

If you want to build your project, run mvn package (and if you don't want to run tests, pass -DskipTests).

Technically, you could also run mvn gwt:compile, but directly inside the submodule. For that to work, you'd first have to mvn install the app-shared submodule; otherwise Maven won't be able to resolve the dependency (as you would no longer be executing the full "reactor build".
For many reasons (see http://blog.lexspoon.org/2012/12/recursive-maven-considered-harmful.html and http://blog.ltgt.net/maven-is-broken-by-design/ as starting points), I highly discourage this practice (mvn install is an anti-pattern; most of the time what you want is actually mvn verify); and I also discourage using any phase before package with multi-module builds (which boils down to only ever using mvn package, possibly with -DskipTests, and mvn verify)

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164