1

What I am trying to do is to deploy/update my web aplication using he google appengine plugin for maven.

Therefore I added the plugins in my pom.xml file:

<project>

    <!-- .. -->

    <profiles>
        <profile>
            <build>
                <pluginManagement>
                    <plugins>

                        <plugin>
                            <groupId>com.google.appengine</groupId>
                            <artifactId>appengine-maven-plugin</artifactId>
                            <version>${appengine.version}</version>
                            <configuration>
                                <enableJarClasses>false</enableJarClasses>
                                <version>${app.version}</version>
                            </configuration>
                        </plugin>

                        <plugin>
                            <groupId>com.google.appengine</groupId>
                            <artifactId>gcloud-maven-plugin</artifactId>
                            <version>${gcloud.plugin.version}</version>
                            <configuration>
                                <set_default>true</set_default>
                            </configuration>
                        </plugin>

                    </plugins>
                </pluginManagement>

                <plugins>
                    <plugin>
                        <groupId>com.google.appengine</groupId>
                        <artifactId>appengine-maven-plugin</artifactId>
                        <version>${appengine.version}</version>
                    </plugin>
                </plugins>

            </build>
        </profile>
    </profiles>
</project>

I also added the pluginGroup:

  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
    <pluginGroup>com.google.appengine</pluginGroup>
  </pluginGroups>

However, if I call mvn appengine:update I am receiving

[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] mz-parent
[INFO] mz-web-shared
[INFO] mz-data-model
[INFO] mz-web-client
[INFO] mz-mobile-rest-shared
[INFO] mz-mobile-rest-api
[INFO] mz-web-server
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mz-parent 0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> appengine-maven-plugin:1.9.32:update (default-cli) > package @ mz-parent >>>
[INFO]
[INFO] --- maven-enforcer-plugin:1.2:enforce (enforce-maven) @ mz-parent ---
[INFO]
[INFO] <<< appengine-maven-plugin:1.9.32:update (default-cli) < package @ mz-parent <<<
[INFO]
[INFO] --- appengine-maven-plugin:1.9.32:update (default-cli) @ mz-parent ---
[INFO]
[INFO] Google App Engine Java SDK - Updating Application
[INFO]
[INFO] Retrieving Google App Engine Java SDK from Maven
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] mz-parent .................................... FAILURE [  0.390 s]
[INFO] mz-web-shared ................................ SKIPPED
[INFO] mz-data-model ................................ SKIPPED
[INFO] mz-web-client ................................ SKIPPED
[INFO] mz-mobile-rest-shared ........................ SKIPPED
[INFO] mz-mobile-rest-api ........................... SKIPPED
[INFO] mz-web-server ................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.460 s
[INFO] Finished at: 2016-03-18T00:33:58+01:00
[INFO] Final Memory: 16M/226M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.google.appengine:appengine-maven-plugin:1.9.32:update (default-cli) on project mz-parent: Execution default-cli of goal com.google.appengine:appengine-maven-plugin:1.9.32:update failed. NoSuchElementException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.google.appengine:appengine-maven-plugin:1.9.32:update (default-cli) on project mz-parent: Execution default-cli of goal com.google.appengine:appengine-maven-plugin:1.9.32:update failed.
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal com.google.appengine:appengine-maven-plugin:1.9.32:update failed.
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 20 more
Caused by: java.util.NoSuchElementException
        at com.google.common.collect.AbstractIterator.next(AbstractIterator.java:154)
        at com.google.common.collect.Iterators.find(Iterators.java:717)
        at com.google.common.collect.Iterables.find(Iterables.java:646)
        at com.google.appengine.SdkResolver.getSdk(SdkResolver.java:50)
        at com.google.appengine.appcfg.AbstractAppCfgMojo.resolveAndSetSdkRoot(AbstractAppCfgMojo.java:393)
        at com.google.appengine.appcfg.Update.execute(Update.java:26)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
        ... 21 more
[ERROR]
[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/PluginExecutionException

Question: how to fix this issue?

A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
  • Does the full stack trace of the error help in any way? (running with the `-e` switch). – Gilberto Torrezan Mar 11 '16 at 18:42
  • @GilbertoTorrezan I have updated my question after using the `-e` switch but the output does not really help me here ^^ – Stefan Falk Mar 17 '16 at 23:36
  • Well, actually it narrowed down the error to the `SdkResolver` class at line 50. It seems that the plugin can't find the right appengine version to retrieve from Maven. – Gilberto Torrezan Mar 18 '16 at 03:46
  • @GilbertoTorrezan Okay, if you put it that way .. you're right :D Okay that's interesting then the question is actually *why* it doesn't find it actually :/ my pom.xml doesn't look incorrect to me. – Stefan Falk Mar 18 '16 at 10:12
  • Well, looking at the `pom.xml`, what I have to say is to test whether the profile is really being activated. You can explicitly activate it by adding an `yourProfileId` tag into it and then running `mvn appengine:update -P yourProfileId`. – Gilberto Torrezan Mar 18 '16 at 12:47
  • @GilbertoTorrezan Back at this.. ^^ Adding the profile didn't change it. Same error as before :/ – Stefan Falk Apr 05 '16 at 18:10

2 Answers2

4

In this case you have a multi-module Maven project and you are trying to execute the appengine:update goal on the whole build, which is probably not possible, because the parent/aggregator pom (where the build is failing) would not provide the folders structure the goal is expecting and as such causing errors.

In fact, you don't want to execute appengine:update on the parent, the shared or model module, among others.

You should build the whole project via the standard

mvn clean install

Then only execute the appengine:update on the concerned war/ear module (mz-web-server in your case, I suppose), that is, the module which you effectively want to update to GAE.

cd mz-web-server <-- move to the concerned module
mvn appengine:update

If the profile you mentioned is defined in the aggregator/parent pom and activated during the multimodule build, then running appengine:update from the root directory will use the defined configuration and try to perform the update goal on each and every module, which is something you don't want (and you actually cannot, given the error, reasonably).

If you want to keep on running appengine:update from the root and only execute it on the concerned module, then you should edit your pluginManagement configuration above:

  • Keep on pluginManagement only the plugin declaration (groupId, artifactId, version)
  • Move the configuration of that plugin on the concerned module (the mz-web-server module)
  • Remove the appengin-maven-plugin declaration from the plugins section of the root pom and move it to the concerned module (with the configuration moved above, actually).

As such, the plugin will be declared as managed by the multi-module build (via pluginManagement) but not effectively used in each and every module (via plugins), then only declared and used in the concerned module.

Moreover, since you are not defining any execution of the plugin during the default build, you don't even need a profile I believe. The configuration you defined will only be used by explicit command line invocations, nothing else.


Basically, you could have in your aggregator/parent pom the following:

<project>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.google.appengine</groupId>
                    <artifactId>appengine-maven-plugin</artifactId>
                    <version>${appengine.version}</version>
                </plugin>

                <plugin>
                    <groupId>com.google.appengine</groupId>
                    <artifactId>gcloud-maven-plugin</artifactId>
                    <version>${gcloud.plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <!-- do you really need it? :) -->
        </profile>
    </profiles>
</project>

Then, in your mz-web-server module the following:

<project>

    <build>
        <plugins>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <!-- you don't need to re-define the version here -->
                <!-- version is taken from pluginManagement from the parent -->
                <configuration>
                    <enableJarClasses>false</enableJarClasses>
                    <version>${app.version}</version>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>gcloud-maven-plugin</artifactId>
                <!-- again, no version here -->
                <configuration>
                    <set_default>true</set_default>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

Note the different usage of pluginManagement and plugins within the build section. For further reading, check this SO post.

Community
  • 1
  • 1
A_Di-Matteo
  • 26,902
  • 7
  • 94
  • 128
0

Here's a sample of working pom.xml from one of my GAE projects :

<?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>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>

    <groupId>com.gae.mvn.demo</groupId>
    <artifactId>gae-maven-demo</artifactId>

    <properties>
        <app.id>your-app-id</app.id>
        <app.version>1</app.version>
        <appengine.version>1.9.32</appengine.version>
        <gcloud.plugin.version>2.0.9.74.v20150814</gcloud.plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
        <spring.version>4.2.5.RELEASE</spring.version>
    </properties>

    <prerequisites>
        <maven>3.1.0</maven>
    </prerequisites>

    <dependencies>
        <!-- Compile/runtime dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${appengine.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-endpoints</artifactId>
            <version>${appengine.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <!-- for hot reload of the web application -->
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>display-dependency-updates</goal>
                            <goal>display-plugin-updates</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>3.1</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
                <configuration>

                    <archiveClasses>true</archiveClasses>
                    <webResources>
                        <resource>
                            <directory>${basedir}/src/main/webapp/WEB-INF</directory>
                            <filtering>true</filtering>
                            <targetPath>WEB-INF</targetPath>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.version}</version>
                <configuration>
                    <enableJarClasses>false</enableJarClasses>
                    <version>${app.version}</version>
                </configuration>
            </executions>
            </plugin>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>gcloud-maven-plugin</artifactId>
                <version>${gcloud.plugin.version}</version>
                <configuration>
                    <set_default>true</set_default>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Hope this helps!

Raghvendra Kumar
  • 1,328
  • 1
  • 10
  • 26