Maven资源插件复制文件 [英] Maven Resource Plugin Copying Files

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

问题描述

我目前有一些Maven项目,在安装该项目时,我需要将所有文件从conf文件夹复制到目标文件夹.

I currently have some Maven projects which when I install the project I need to copy all files from the conf folder to the target folder.

|-Project
    |--src
    |--conf <--FROM HERE -->
    |--lib
    |--target <--TO HERE-->

我没有在pom.xml中尝试此操作.我究竟做错了什么?我的pom.xml插件部分如下:

I have attempted this in the pom.xml to no avail. What am I doing wrong? My plugin part of the pom.xml is below:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
    <execution>
        <id>copy-resources</id>
        <phase>install</phase>
        <goals>
            <goal>copy-resources</goal>
        </goals>
        <configuration>
            <outputDirectory>${basedir}/target</outputDirectory>
            <resources>
                <resource>
                    <directory>${basedir}/conf</directory>
                    <includes>
                        <include>*</include>
                    </includes>
                </resource>
            </resources>
        </configuration>
    </execution>
</executions>

推荐答案

您的问题是您在阶段install中复制了资源.在这一阶段,您的目标档案已被构建并复制到本地存储库中.请参阅 Maven生命周期.您可能会想要在process-resources阶段进行操作.

Your problem is that you copy the resources in the phase install. In that phase your target archive is already built and copied to your local repository. See the Maven lifecycle. You'll propably want to do it in the process-resources phase.

这篇关于Maven资源插件复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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