2

Based on the PlayN Getting Started wiki page I created a skeleton project (called GuiPoc) in eclipse. I managed to make the guipoc-html project compile successfully (with Google -> GWT Compile), and eventually Run as -> Web Application. I tried using mvn gae:run from the guipoc/html directory (in cygwin) as per the wiki, and got the following output:

[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building GuiPoc HTML 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-gae-plugin:0.9.2:run (default-cli) @ guipoc-html >>>
[WARNING] The POM for com.mydomain.mynamespace:guipoc-core:jar:0.0.1-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.619s
[INFO] Finished at: Sun Jan 01 20:05:29 VET 2012
[INFO] Final Memory: 8M/121M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project guipoc-html: Could not resolve dependencies for project com.mydomain.mynamespace:guipoc-html:war:0.0.1-SNAPSHOT: Failure to find com.mydomain.mynamespace:guipoc-core:jar:0.0.1-SNAPSHOT in http://forplay.googlecode.com/svn/mavenrepo was cached in the local repository, resolution will not be reattempted until the update interval of forplay-legacy has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

Actual Question: I don't understand why it's looking for the dependency in the system repository instead of the local directory. What am I doing wrong? Do I need to change something in my pom.xml files? Create a settings.xml in my C:\Users\MyName.m2 directory and set something there?

Here is the content of guipoc/html/pom.xml:

<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.mydomain.mynamespace</groupId>
    <artifactId>guipoc</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <artifactId>guipoc-html</artifactId>
  <packaging>war</packaging>
  <name>GuiPoc HTML</name>

  <properties>
    <gwt.module>com.mydomain.mynamespace.GuiPoc</gwt.module>
    <gwt.name>guipoc</gwt.name>
    <!-- Desired Google App Engine SDK version -->
    <gae.version>1.6.0</gae.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.mydomain.mynamespace</groupId>
      <artifactId>guipoc-core</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>com.googlecode.playn</groupId>
      <artifactId>playn-html</artifactId>
      <version>${playn.version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-eclipse-plugin</artifactId>
        <version>2.8</version>
        <configuration>
          <downloadSources>true</downloadSources>
          <downloadJavadocs>false</downloadJavadocs>
          <wtpversion>2.0</wtpversion>
          <additionalBuildcommands>
            <buildCommand>
              <name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
            </buildCommand>
          </additionalBuildcommands>
          <additionalProjectnatures>
            <projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature>
            <projectnature>com.google.appengine.eclipse.core.gaeNature</projectnature>
          </additionalProjectnatures>
        </configuration>
      </plugin>
      <plugin>
        <groupId>net.kindleit</groupId>
        <artifactId>maven-gae-plugin</artifactId>
        <version>0.9.2</version>
        <dependencies>
          <!--
            Declare explicit dependency on gae-runtime here,
            so we can specify the App Engine SDK version
          -->
          <dependency>
            <groupId>net.kindleit</groupId>
            <artifactId>gae-runtime</artifactId>
            <version>${gae.version}</version>
            <type>pom</type>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
</project>

Here is the content of guipoc/core/pom.xml:

<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.mydomain.mynamespace</groupId>
    <artifactId>guipoc</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>

  <artifactId>guipoc-core</artifactId>
  <packaging>jar</packaging>
  <name>GuiPoc Core</name>

  <dependencies>
    <dependency>
      <groupId>com.googlecode.playn</groupId>
      <artifactId>playn-core</artifactId>
      <version>${playn.version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
      </plugin>
    </plugins>

    <resources>
      <!-- include the source files in our main jar for use by GWT -->
      <resource>
        <directory>${project.build.sourceDirectory}</directory>
      </resource>
      <!-- and continue to include our standard resources -->
      <resource>
        <directory>${basedir}/src/main/resources</directory>
      </resource>
    </resources>
  </build>
</project>

Here is the content of guipoc/pom.xml:

<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.googlecode.playn</groupId>
    <artifactId>playn-project</artifactId>
    <version>1.0.3</version>
  </parent>

  <groupId>com.mydomain.mynamespace</groupId>
  <artifactId>guipoc</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>GuiPoc Metaproject</name>

  <properties>
    <playn.version>1.0.3</playn.version>
  </properties>

  <modules>
    <module>core</module>
    <module>java</module>
    <module>html</module>
    <module>android</module>
  </modules>
  <dependencies>
    <dependency>
        <groupId>com.sun</groupId>
        <artifactId>tools</artifactId>
        <version>1.6</version>
        <scope>system</scope>
        <systemPath>C:\Program Files\Java\jdk1.7.0_02\lib\tools.jar</systemPath>
    </dependency>
  </dependencies>
</project>
Mark Schmit
  • 467
  • 4
  • 13

1 Answers1

3

Unfortunately, Maven is not too smart about multimodule projects. A standard PlayN project (including yours) has the following module structure:

top
+- core
+- html (depends on core)
+- java (depends on core)
+- android, flash, etc.

When you are in the top directory, and you invoke Maven, it reads all of the submodule POMs and "knows" about all of them and will properly set up classpaths so that they see the appropriate classes directory when compiling and running.

But if you go into, say, the html directory and invoke Maven there, it no longer "knows" about all of the submodules. All it knows about is the html POM and when it sees a dependency for anything else (like the core module in this case) it goes through the standard dependency resolution process, which is:

  1. Check the local Maven repository ~/.m2/repository.
  2. Check the repositories explicitly specified in the POMs.
  3. Check Maven Central.

When you have a situation where you want to run a command in one of your submodule projects, you have to arrange to do it from the top-level project. This is why testing from the command line involves running mvn test -P test-java or mvn test -P test-html from the top-level directory, rather than just cd-ing into the java or html directory and running mvn test.

Unfortunately, the tricks that we use to make it possible to test the Java or HTML submodule from the command line don't work with gae:run. So in this case, you have to work around Maven's limitations by first installing your project artifacts into your local Maven repository before invoking gae:run (and indeed, doing this every time you want to test using gae:run. This is accomplished like so:

cd top
mvn install
cd html
mvn gae:run

It would be great if Maven were smart enough to detect that it was being run in a submodule directory and automatically resolve sibling dependencies in the same way it would if you invoked Maven from the top-level project directory. Alas, smart is an adjective that's rarely applicable when talking about Maven.

samskivert
  • 3,694
  • 20
  • 22
  • This eventually worked after some other hoops involving installing the correct Android SDK version and running `mvn gae:unpack` to download the appropriate appengine SDK. Thanks much. – Mark Schmit Jan 15 '12 at 17:47