2

Using Android Studio, I have created an Android project with a cloud endpoint backend (Tools > Google Cloud Endpoints > Generate AppEngine Backend). The initial setup works and I am able to have the Android app see the exposed cloud endpoints.

However after adding more components to the AppEngine project (more entities, endpoints, servlets, etc) the AppEngine build fails during the Maven goal appengine-maven-plugin:enhance with a command line too long error.

Upon researching this, it appears this goal delegates to the datanucleus-maven-plugin:enhance goal (please see the Maven mojo source code here). When I run the goal from the command line using Maven's -X option, I see that the enhancer attempts to run on all classes (servlets, non-entities, etc) and that the command line length exceeds Window's limit.

The solution to this appears to be specifying only the specific entities to be enhanced. This post describes how the Maven plugin can be configured for that.

This all seems fair enough, but my attempts to configure the plugin from my pom.xml have no effect. Executing from the command line, I see the message that the datanucleus enhance goal is configured with it's default configuration and not from the pom.

I am a Maven newbie, so it'd be very much appreciated if someone could explain what the Maven appengine enhance mojo is expecting for a configuration which the source code seems to be grabbing in the line 115: mojoDescriptor.getMojoConfiguration()

My pom.xml looks like this:

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

Thanks!

Community
  • 1
  • 1
Nic
  • 21
  • 1
  • So which M2 plugin is being used ? datanucleus-maven, or appengine-maven ? and why do you have metadataIncludes on datanucleus-maven when you should have a persistenceUnitName for JPA usage – Neil Stockton Aug 15 '13 at 17:50
  • Hi Neil, the appengine-maven:enhance goal does not provide much in the way of configuration. I saw from the source code that it internally uses datanucleus-maven:enhance and presumable loads some configuration for it (line #115: mojoDescriptor.getMojoConfiguration()). Thus my inclusion of the datanucleus-maven plugin with configuration parameters. – Nic Aug 16 '13 at 03:34
  • Also thanks for the heads up on metadataIncludes being for JDO only. I was not aware of this. Do I then restrict what classes are enhanced through tags as seen [here](http://stackoverflow.com/questions/1780341/do-i-need-class-elements-in-persistence-xml)? – Nic Aug 16 '13 at 03:43
  • Specifying classes in a persistence-unit would achieve the end goal of specifying which classes need enhancement (and the persistenceUnitName should be specified as input to the datanucleus-maven-plugin, whether by you, or by googles plugin) – Neil Stockton Aug 16 '13 at 06:47

0 Answers0