如何使用一些复制任务配置maven资源插件?

时间:2014-01-28 14:41:03

标签: java maven maven-resources-plugin

我有两个复制任务,我想用maven-resources-plugin做。例如,我需要将config.ymlsrc/main/resources复制到根文件夹,并将所有文件夹内容从/src/main/resources/examples复制到src/examples

root
  /src
    /main
      /resources   --> config.yml (to root)
        /examples  --> all folder contents (to /src/examples)

我发现的唯一解决方案是:

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
    <execution>
        <id>copy-resources</id>
        <phase>validate</phase>
        <goals>
            <goal>copy-resources</goal>
        </goals>
        <configuration>
            <outputDirectory>${basedir}</outputDirectory>
            <resources>
                <resource>
                    <directory>src/main/resources</directory>
                    <includes>
                        <include>**/config.yml</include>
                    </includes>
                </resource>
                <!-- <resource>
                    <directory>src/main/resources/examples</directory>
                </resource> -->
            </resources>
        </configuration>
    </execution>
</executions>
</plugin>

但我只能添加一个目标文件夹。

1 个答案:

答案 0 :(得分:0)

您可以使用不同的ID和配置创建另一个执行:

<execution>
    <id>copy-resources-2</id>
    <phase>validate</phase>
    <goals>
        <goal>copy-resources</goal>
    </goals>
    <configuration>
        ...
    </configuration>
</execution>