重命名Maven中的资源 [英] Renaming resources in Maven

查看:107
本文介绍了重命名Maven中的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Maven构建中的目标目录中找到一种将资源文件复制到新名称的方法.我在搜索时发现的几乎所有内容都建议解决方法,其中涉及/src/main/resources中的多个子目录并通过配置文件在其中进行选择.但是,就我而言,这不能解决问题,即我想要的文件具有魔术"名称.

I am trying to find a way to copy a resource file to a new name in the target directory in a Maven build. Pretty much everything I have found while searching suggests workarounds involving multiple sub-directories in /src/main/resources and selecting among them via profiles. However, in my case, this does not solve the problem, namely that the file I want has a "magic" name.

基本上我想做的是将/src/main/resources/default.DS_Store文件复制到${project.build.directory}/.DS_Store.由于.DS_Store文件在Mac OSX中具有特殊含义,因此在源代码树和版本控制中不希望使用具有该名称的文件.但是,我确实希望文件中的数据位于源代码树和版本控制中,并在构建过程中将其重命名为"magic"名称.

Basically what I want to do is have a /src/main/resources/default.DS_Store file get copied to ${project.build.directory}/.DS_Store. Since the .DS_Store file has special meaning in Mac OSX, it is not desirable to have a file with that name in the source tree, and in version control. However, I do want the data in the file to be in the source tree and version control, and have it renamed to the "magic" name during the build.

我开始认为蚂蚁是自动执行此操作的唯一方法.有没有更简单的方法?

I'm starting to think that ant is the only way to do this automatically. Is there any easier way?

推荐答案

我看到2种解决方案来解决您的问题:

I see 2 options to solve your problem:

  • Use the Maven-Ant-Plugin, and define an Ant rename task that will rename your file only at the packaging phase, in the build directory.
  • Use this dedicated Maven plugin (I didn't test it): http://code.google.com/p/maven-file-rename-plugin/

这篇关于重命名Maven中的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆