复制资源在Maven资源插件中不起作用

时间:2019-04-27 11:18:23

标签: java maven maven-resources-plugin

我正在尝试使用Maven资源插件在构建时复制xml文件,但到目前为止没有成功。

<profile>
.
.
<build>
.

<resources>
    <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
    </resource>
    <resource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
    </resource>
</resources>
.
.
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <configuration>
            <encoding>UTF-8</encoding>
        </configuration>
        <executions>
            <execution>
                <id>copy-resources</id>
                <phase>package</phase>
                <goals>
                    <goal>copy-resources</goal>
                </goals>
                <configuration>
                    <outputDirectory>${basedir}/target/Test</outputDirectory>
                    <overwrite>true</overwrite>
                    <resources>
                        <resource>
                            <directory>${basedir}/target/common-aws</directory>
                            <filtering>true</filtering>
                            <includes>
                                <include>*.xml</include>
                            </includes>
                        </resource>
                    </resources>
                </configuration>
            </execution>
        </executions>
    </plugin>   
<plugins>
.
.
</build>
.
.
</profile>

Maven目标-全新安装

是否需要任何特殊的Maven目标来复制内容? 请在这里帮助我。

插件版本-2.6

Refering this

1 个答案:

答案 0 :(得分:0)

阶段,并且有多个maven-resource-plugin条目存在问题。

下面的代码对我有用。

<execution>
        <id>copy-resources3</id>
        <phase>process-resources</phase>
        <goals>
            <goal>copy-resources</goal>
        </goals>
        <configuration>
            <outputDirectory>${basedir}/somedirectory</outputDirectory>
            <overwrite>true</overwrite>
            <resources>
                <resource>
                    <directory>${basedir}/target/common-aws</directory>
                    <includes>
                        <include>*.xml</include>
                    </includes>
                </resource>
            </resources>
        </configuration>
    </execution>
</executions>