Maven资源插件资源的平面副本 [英] maven resources plugin flat copy of resources

查看:92
本文介绍了Maven资源插件资源的平面副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出一个包含不同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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆