copy-resource not working in maven resource plugin

你说的曾经没有我的故事 提交于 2019-12-11 16:54:04

问题


I am trying to copy an xml file at build time using maven resource plugin with no success till now.

<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 Goal - clean install

Does it need any special maven goal to get things copied ? Please help me out here.

plugin version -2.6

Refering this


回答1:


The issue was wrong phase and multiple maven-resource-plugin entries.

Below code worked for me.

<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>


来源:https://stackoverflow.com/questions/55880013/copy-resource-not-working-in-maven-resource-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!