2

使用 Android Studio,我创建了一个带有云端点后端的 Android 项目(工具 > Google Cloud Endpoints > 生成 AppEngine 后端)。初始设置有效,我可以让 Android 应用程序看到暴露的云端点。

但是,在向 AppEngine 项目添加更多组件(更多实体、端点、servlet 等)后,AppEngine 构建在 Maven 目标 appengine-maven-plugin:enhance 期间失败,并出现命令行太长错误

经过研究,这个目标似乎委托给了 datanucleus-maven-plugin:enhance 目标(请在此处查看 Maven mojo 源代码)。当我使用 Maven 的 -X 选项从命令行运行目标时,我看到增强器尝试在所有类(servlet、非实体等)上运行,并且命令行长度超过了 Window 的限制。

对此的解决方案似乎是仅指定要增强的特定实体。这篇文章描述了如何为此配置 Maven 插件。

这一切看起来很公平,但我尝试从我的 pom.xml 配置插件没有效果。从命令行执行,我看到数据核增强目标配置为默认配置而不是来自 pom.xml 的消息。

我是一个 Maven 新手,所以如果有人可以解释Maven appengine 增强 mojo对第 115 行中源代码似乎正在抓取的配置的期望,将不胜感激: mojoDescriptor.getMojoConfiguration()

我的 pom.xml 看起来像这样:

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

<groupId>com.myproject</groupId>
<artifactId>MyProject</artifactId>

<properties>
    <appengine.target.version>1.8.3</appengine.target.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!--Found by examining mvn com.google.appengine:appengine-maven-plugin:1.8.3:enhance -X
    see https://code.google.com/p/appengine-maven-plugin/source/browse/src/main/java/com/google/appengine/AppengineEnhancerMojo.java?spec=svn834b839bf5deab60499ecfb85facd55f06f8e258&r=834b839bf5deab60499ecfb85facd55f06f8e258
     -->
    <appengine.enhancerApi>JPA</appengine.enhancerApi>

</properties>

<dependencies>
    <!-- Compile/runtime dependencies -->
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-1.0-sdk</artifactId>
        <version>${appengine.target.version}</version>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-endpoints</artifactId>
        <version>${appengine.target.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-jpa_2.0_spec</artifactId>
        <version>1.1</version>
    </dependency>
    <dependency>
        <groupId>net.sf.jsr107cache</groupId>
        <artifactId>jsr107cache</artifactId>
        <version>1.1</version>
    </dependency>

    <dependency>
        <groupId>com.google.appengine.orm</groupId>
        <artifactId>datanucleus-appengine</artifactId>
        <version>2.1.2</version>
    </dependency>

    <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1.1</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>com.ganyo</groupId>
        <artifactId>gcm-server</artifactId>
        <version>1.0.2</version>
    </dependency>

    <!-- Test Dependencies -->
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-testing</artifactId>
        <version>${appengine.target.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.appengine</groupId>
        <artifactId>appengine-api-stubs</artifactId>
        <version>${appengine.target.version}</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.datanucleus</groupId>
        <artifactId>datanucleus-maven-plugin</artifactId>
        <version>3.2.0-release</version>
    </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.apache.maven.plugins</groupId>
            <version>2.5.1</version>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <webXml>
                    ${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml
                </webXml>
                <webResources>
                    <resource>
                        <!-- this is relative to the pom.xml directory -->
                        <directory>
                            ${project.build.directory}/generated-sources/appengine-endpoints
                        </directory>
                        <!-- the list has a default value of ** -->
                        <includes>
                            <include>WEB-INF/*.discovery</include>
                            <include>WEB-INF/*.api</include>
                        </includes>
                    </resource>
                </webResources>
            </configuration>
        </plugin>


        <!-- 
        No config settings get applied?
        -->
        <plugin>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-maven-plugin</artifactId>
            <version>3.2.0-release</version>

            <configuration>
                <fork>false</fork>
                <verbose>true</verbose>
                <metadataIncludes>some_path</metadataIncludes>
            </configuration>

            <executions>
                <execution>
                    <id>default-enhance</id>
                    <configuration>
                        <fork>false</fork>
                        <verbose>true</verbose>
                        <metadataIncludes>some_path</metadataIncludes>
                    </configuration>
                </execution>
            </executions>

        </plugin>

        <plugin>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>1.8.3</version>
            <configuration>
                <enableJarClasses>false</enableJarClasses>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>endpoints_get_discovery_doc</goal>
                        <!--goal>endpoints_get_client_lib</goal-->
                        <goal>enhance</goal>
                    </goals>
                </execution>
            </executions>

            <dependencies>
                <dependency>
                    <groupId>org.datanucleus</groupId>
                    <artifactId>datanucleus-maven-plugin</artifactId>
                    <version>3.2.0-release</version>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

谢谢!

4

0 回答 0