目标com.google.appengine的执行default-cli:appengine-maven-plugin:1.9.32:更新失败

时间:2016-03-07 16:32:21

标签: maven google-app-engine maven-3 pom.xml multi-module

我要做的是使用google appengine插件为maven部署/更新我的网络应用程序。

因此我在pom.xml文件中添加了插件:

<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>

我还添加了pluginGroup:

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

但是,如果我致电mvn appengine:update我正在接收

[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

问题:如何解决此问题?

2 个答案:

答案 0 :(得分:4)

在这种情况下,你有一个多模块Maven项目,你试图在整个构建中执行appengine:update目标,这可能是不可能的,因为父/聚合器pom(构建失败的地方) )不会提供目标期望的文件夹结构,因此会导致错误。

事实上,您不想在父级,共享或模型模块等上执行appengine:update

您应该通过标准

构建整个项目
mvn clean install

然后只执行相关的war / ear模块appengine:update(我想你的情况为mz-web-server),也就是你有效想要更新到GAE的模块。

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

如果您提到的配置文件在聚合器/父pom中定义并在多模块构建期间激活,则从根目录运行appengine:update将使用已定义的配置并尝试执行update目标在每个模块上,这是你不想要的东西(你实际上不能,合理地给出错误)。

如果您希望继续从根运行appengine:update并仅在相关模块上执行它,那么您应该编辑上面的pluginManagement配置:

  • 仅保留pluginManagement插件声明(groupId,artifactId,version)
  • 在相关模块(mz-web-server模块)
  • 上移动该插件的配置
  • 从根pom的appengin-maven-plugin部分删除plugins声明并将其移至相关模块(实际上,配置已移至上方)。

因此,插件将被声明为由多模块构建(通过pluginManagement)管理,但未在每个模块中有效使用(通过plugins),然后仅声明和使用在相关模块中。

此外,由于您在默认构建期间未定义插件的任何execution,因此您甚至不需要我相信的配置文件。您定义的配置将仅由显式命令行调用使用,而不是其他任何内容。

基本上,您可以在聚合器/父pom中使用以下内容:

<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>

然后,在您的mz-web-server模块中,以下内容:

<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>

请注意pluginManagement部分中pluginsbuild的不同用法。如需进一步阅读,请查看this SO post

答案 1 :(得分:0)

以下是我的一个GAE项目中的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/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>

希望这有帮助!