Appengine maven 插件排除 node_modules
Appengine maven plugin exclude node_modules
在我的 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>
我刚刚发现我必须将带有 warSourceExcludes
配置的 maven-war-plugin
添加到 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 文件夹中。
<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>
其中 assets 是 src/main/webapp[=23 中的一个文件夹=]目录。当你 运行 mvn install 时,它会创建一个 war 和 source 目录 在您的 target 文件夹中。尽管 node_modules 将在目标内的源目录中可见,但是当您提取 war 文件时,这些将被排除.您可以通过提取 war 文件来查看。
在我的 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>
我刚刚发现我必须将带有 warSourceExcludes
配置的 maven-war-plugin
添加到 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 文件夹中。
<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>
其中 assets 是 src/main/webapp[=23 中的一个文件夹=]目录。当你 运行 mvn install 时,它会创建一个 war 和 source 目录 在您的 target 文件夹中。尽管 node_modules 将在目标内的源目录中可见,但是当您提取 war 文件时,这些将被排除.您可以通过提取 war 文件来查看。