Maven资源插件资源的平面副本 [英] maven resources plugin flat copy of resources
问题描述
给出一个包含不同RDBMS的JAR连接器的文件夹数据库".每个JAR都位于其自己的文件夹中:
Given a folder 'database' containing JAR-connectors for different RDBMS. Each JAR is located in its own folder:
+---database
+---db2
+---db2.jar
+---derby
+---derby.jar
+---h2
+---h2.jar
+---mysql
+---mysql.jar
我需要将所有这些JAR文件复制到WEB-INF \ lib中.
I need all of those JAR-files to be copied into WEB-INF\lib.
这是我的pom.xml:
Here's my pom.xml:
<build>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<webResources>
<resource>
<directory>../target/${project.artifactId}/classes/database</directory>
<targetPath>WEB-INF/lib</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
问题是,那些JAR会与它们的目录一起复制:
Problem is, that those JARs are copied with their directories:
+---WEB-INF/lib
+---db2
+---db2.jar
+---derby
+---derby.jar
+---h2
+---h2.jar
+---mysql
+---mysql.jar
这应该是这样的:
+---WEB-INF/lib
+---db2.jar
+---derby.jar
+---h2.jar
+---mysql.jar
我有20个连接器,我不想对其进行硬编码.
I have 20 connectors and I don't want to hard code them.
推荐答案
最正确的方法是将jar文件安装到Maven存储库中,然后使用 maven-antrun-plugin
(复制规则).
The most correct way of doing so will be to install your jar files into Maven repository and then use maven-dependency-plugin:copy
goal. Or if you want to solve this roughly then use maven-antrun-plugin
(copy rule).
这篇关于Maven资源插件资源的平面副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!