我有一些配置文件和各种文档,我想使用Maven2将它们从开发环境复制到dev-server目录。奇怪的是,Maven在这项任务上似乎并不强大。
以下是一些选项:
简单地使用Maven中的复制任务
< =“src /游戏/资源/文件副本配置。财产“tofile = ${项目配置}-配置服务器。财产" - >
Use the Ant plugin to execute copy from Ant.
Construct an artifact of type zip, alongside the "main" artifact of the POM which is usually of type jar, then unpack that artifact from the repository into the target directory.
maven-resources plugin, as mentioned below.
Maven Assembly plugin -- but this seems to require a lot of manual definitions, when I want to do things simply and "conventionally."
This page even shows how to build a plugin to do copying!
maven-upload plugin, as mentioned below.
maven-dependency-plugin with copy, as mentioned below.
所有这些似乎都是不必要的特别任务:Maven应该擅长于毫不费力地完成这些标准任务。
任何建议吗?
If someone wants total control over the path of the source and destination paths, then using maven-antrun-plugin's copy task is the best option. This approach will allow you to copy between any paths on the system, irrespective of the concerned paths being within the mvn project or not. I had a situation where I had to do some unusual stuff like copy generated source files from target directory back to the src directory for further processing. In my situation, this was the only option that worked without fuss. Sample code snippet from pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<tasks>
<copy file="${basedir}/target/myome/minifyJsSrcDir/myome.min.js" todir="${basedir}/src/main/webapp/app/minifyJsSrcDir"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>