maven 复制文件插件使用
在使用maven开发的项目中,有时候需要在打包时根据环境的不同复制不同目录下的文件,通常是配置文件。
apache提供了maven-resources-plugin可以复制在指定的maven生命周期中复制文件,如下示例配置
<project> ... <build> <plugins> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>copy-resources</id> <!-- here the phase you need --> <phase>validate</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${basedir}/target/extra-resources</outputDirectory> <resources> <resource> <directory>src/non-packaged-resources</directory> <filtering>true</filtering> </resource> </resources> </configuration> </execution> </executions> </plugin> </plugins> ... </build> ...