copy-resource not working in maven resource plugin

2019-08-19 17:12发布

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条回答
太酷不给撩
2楼-- · 2019-08-19 18:08

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>
查看更多
登录 后发表回答