这是我的pom.xml,试图在WEB-INF / lib目录中创建一个包含特定3个库的WAR文件。
我将它们包含在<packagingIncludes>
标记中,并将它们打包在lib目录中,但忽略所有.class
个文件。
我不能使用<packagingExcludes>
,因为依赖项目有很多第三方罐子而且我无法控制。
这里有什么问题,或者有什么方法可以忽略除3个特定罐子以外的所有罐子?
<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>1.0</modelVersion>
<parent>
<groupId>frmId</groupId>
<artifactId>frm</artifactId>
<version>1.5.9</version>
</parent>
<artifactId>frmw</artifactId>
<packaging>war</packaging>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<packagingIncludes>WEB-INF/lib/frm-fl*.jar,WEB-INF/lib/frm-bean*.jar,WEB-INF/lib/frm-facade-${ffm.fpi.version}.jar</packagingIncludes>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>com.fortify.ps.maven.plugin</groupId>
<artifactId>sca-maven-plugin</artifactId>
<version>${maven-sca-plugin.version}</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.fi.ps</groupId>
<artifactId>frmc-fl</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
答案 0 :(得分:5)
你只需要将你的3个特定库作为项目的依赖项,maven会在程序包阶段将它放在WEB-INF / lib上
<强>更新强>
要从依赖项中排除JAR,必须使用这种语法
<dependency>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
</exclusion>
</exclusions>
</dependency>
并排除所有子依赖项(仅限maven 3):
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
更新2
使用maven-war-plugin你应该将WEB-INF / classes / **添加到packagingIncludes
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<packagingIncludes>WEB-INF/lib/frm-fl*.jar,WEB-INF/lib/frm-bean*.jar,WEB-INF/lib/frm-facade-${ffm.fpi.version}.jar,WEB-INF/classes/**></packagingIncludes>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>