2011-06-07 80 views
1

在Maven中,有没有一种方法可以将一个文件映射到另一个具有不同名称的文件?我知道有一种方法将文件具有相同名称的不同文件中的某个目录下有图有以下几点:Maven映射文件

<mapping> 
    <directory>/some/path/to/dir</directory> 
    <sources> 
    <source>/some/path/to/file/xyz</source> 
    </sources> 
</mapping> 

这将映射到​​/some/path/to/dir/xyz。相反,我想​​映射到/some/path/to/dir/abc。有没有一种干净的maven方式来做到这一点?

谢谢!

回答

0

没有直接。您可以通过antrun maven plugin使用Ant的copy task。请参见Mapping File Names

<plugin> 
    <artifactId>maven-antrun-plugin</artifactId> 
    <version>1.6</version> 
    <executions> 
     <execution> 
     <phase> <!-- a lifecycle phase --> </phase> 
     <configuration> 
      <target> 
      <copy todir="/some/path/to/dir"> 
       <fileset dir="/some/path/to/file/"/> 
       <mapper/><!-- you'll make the name mapping configuration here--> 
      </copy> 
      </target> 
     </configuration> 
     <goals> 
      <goal>run</goal> 
     </goals> 
     </execution> 
    </executions> 
    </plugin> 
+0

我最终使用antrun插件通过执行copy-> move任务来复制和重命名文件。谢谢你的回答。 – 2011-06-13 21:32:14