Search code examples
mavengoogle-app-enginewar

Appengine maven plugin exclude node_modules


In my GoogleAppEngine project I currently installed a lot of node-modules that are now placed in my project at the location src/main/webapp/node_modules. Now when I try to test that project locally with the appengine-maven-plugin (mvn appengine:run), it takes up to 10 Minutes to create that project. I figured out, that it takes so much time to copy all files from the node_modules folder to the target folder.

Since I only need these files for developing, I tried to skip this folder when building the project. But I'm not that sure where to configure that behavior. In my appengine-web.xml I already excludes that folder from static-files and resource-files:

<static-files>
        <include path="/build/build/favicon.ico" />
        <include path="/build/build/node_modules/**" />
        <include path="/build/build/images/**" />
        <include path="/build/build/src/**" />
        <include path="/build/build/robots.txt" />
        <include path="/build/build/sitemap.xml" />
        <exclude path="/node_modules/**/*" />
    </static-files>
    <resource-files>
        <include path="/build/build/index.html" />
        <exclude path="/node_modules/**/*" />
    </resource-files>

Where may I exclude that folder from beeing copied to target/backend-1.0-snapshot?

enter image description here

I'm using the appengine standard environment (1.9.63) with the appengine-maven-plugin (1.3.2)

Here is my pom.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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.xxx.xxx</groupId>
    <artifactId>backend</artifactId>

    <properties>
        <endpoints.framework.version>2.0.14</endpoints.framework.version>
        <endpoints.management.version>1.0.4</endpoints.management.version>
        <endpoints.project.id>XXX PROJECT XXX</endpoints.project.id>

        <appengine.maven.plugin.version>1.3.2</appengine.maven.plugin.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
    </properties>

    <prerequisites>
        <maven>3.5.0</maven>
    </prerequisites>

    <dependencies>
        <!-- Compile/runtime dependencies -->

        <dependency>
            <groupId>com.google.endpoints</groupId>
            <artifactId>endpoints-framework</artifactId>
            <version>${endpoints.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.endpoints</groupId>
            <artifactId>endpoints-management-control-appengine-all</artifactId>
            <version>1.0.7</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <type>jar</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>1.9.63</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.5</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>com.google.cloud.tools</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.maven.plugin.version}</version>
                <configuration>
                    <deploy.project>XXX PROJECT XXX</deploy.project>
                    <deploy.version>XXX VERSION XXX</deploy.version>
                    <deploy.stopPreviousVersion>false</deploy.stopPreviousVersion>
                    <deploy.promote>false</deploy.promote>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>endpoints-framework-maven-plugin</artifactId>
                <version>1.0.3</version>
                <configuration>
                    <!-- plugin configuration -->
                    <hostname>${endpoints.project.id}.appspot.com</hostname>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.5</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>display-dependency-updates</goal>
                            <goal>display-plugin-updates</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Solution

  • I just found out that I have to add the maven-war-plugin with the warSourceExcludes-configuration to the build part of the pom.xml.

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <warSourceExcludes>node_modules/**</warSourceExcludes>
                </configuration>
            </plugin>
    

    That way the folder won't be copied to the exploded war folder.