在我的GoogleAppEngine项目中,我目前安装了很多节点模块,这些模块现在放在我的项目中 src / main / webapp / node_modules 位置。现在,当我尝试使用appengine-maven-plugin
(mvn appengine:run
)在本地测试该项目时,创建该项目最多需要10分钟。我想,将所有文件从node_modules
文件夹复制到目标文件夹需要花费很多时间。
由于我只需要这些文件进行开发,因此我在构建项目时尝试跳过此文件夹。但我不确定在哪里配置这种行为。在我的appengine-web.xml
我已经从静态文件和资源文件中排除了该文件夹:
<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>
我可以从哪里将该文件夹排除在复制到target/backend-1.0-snapshot
?
我使用appengine标准环境(1.9.63)和appengine-maven-plugin(1.3.2)
这是我的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>
答案 0 :(得分:2)
我刚发现我必须将maven-war-plugin
warSourceExcludes
- 配置添加到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>
这样,文件夹就不会被复制到爆炸的war文件夹中。
答案 1 :(得分:0)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<packagingExcludes>assets/node_modules/**</packagingExcludes>
</configuration>
</plugin>
其中 资产 是 src / main / webapp 目录中的文件夹。运行 mvn install 时,它将在 target 文件夹中创建 war 和源目录。虽然 node_modules 在目标内部的源目录中可见,但是当您提取war文件时,这些将被排除。您可以通过提取war文件来看到它。