gpt4 book ai didi

java - 如何从 WAR 中排除文件夹?

转载 作者:行者123 更新时间:2023-12-01 19:32:18 26 4
gpt4 key购买 nike

我试图关注Maven packagingExcludes jars regex这就是我的 pom.xml 文件的样子。 node_modules 的完整路径是 project-directory/src/main/webapp/node_modules

<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>

<groupId>mobi.grocerymonkey.groceryapp</groupId>
<artifactId>groceryapp</artifactId>

<properties>
<!-- uncomment if you wish to set your project here project- gcloud is used otherwise -->
<!-- <app.deploy.project>enduring-trees-259812</app.deploy.project> -->
<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>
<archiveClasses>true</archiveClasses>
</properties>

<prerequisites>
<maven>3.5</maven>
</prerequisites>

<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.59</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>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>

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

<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-tools-sdk</artifactId>
<version>1.9.59</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>0.33</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>2.0.2-beta</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.googlecode.objectify</groupId>
<artifactId>objectify</artifactId>
<version>6.0.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>1.3.1</version>
<configuration>
<project>enduring-trees-259812</project>
<version>1</version>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>javax.servlet:javax.servlet-api</exclude>
<exclude>com.google.guava:guava</exclude> <!-- avoid android version -->
</excludes>
</configuration>
</plugin>

<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<packagingExcludes>
%regex[node_modules]
</packagingExcludes>
</configuration>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
</plugin>

<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>

<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
</plugin>

<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.6</version>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>

<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1</version>
</plugin>

<!-- https://cloud.google.com/appengine/docs/standard/java/building-app/environment-setup //-->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.1</version>
<configuration>
<jvmFlags>
<jvmFlag>-Xdebug</jvmFlag>
<jvmFlag>-Dappengine.fullscan.seconds=1</jvmFlag>
</jvmFlags>
</configuration>
</plugin>

<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.5</version>
</requireMavenVersion>
<requirePluginVersions>
<message>Best Practice is to always define plugin versions!</message>
<banLatest>true</banLatest>
<banRelease>true</banRelease>
<phases>clean,deploy,verify,appengine:run,appengine:deploy,appengine:update,appengine:devappaserver,site</phases>
</requirePluginVersions>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

我添加了以下内容来排除nodes_modules文件夹,但我仍然看到我的构建包含它并生成它,需要几分钟(总时间:03:16分钟)

<packagingExcludes>
%regex[node_modules]
</packagingExcludes>

如何从我的 war 文件中排除 node_modules?

最佳答案

您正在使用 packagingExcludesregex 版本,这不是您的用例。尝试指定指定的文件夹路径here如下

<packagingExcludes>WEB-INF/node_modules/**</packagingExcludes>    <!--or correct path to your folder-->

关于java - 如何从 WAR 中排除文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59249701/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com