tags:

views:

18

answers:

2

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.

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  A: 

I see 2 options to solve your problem:

Benoit Courtine
I went with the antrun plugin, with one execution in prepare-package phase to create the renamed `.DS_Store`, and another in verify phase to delete it (just in case...). Looks like it's working, thanks!
wmorrell
A: 

You can avoid the over head of Ant by using the Maven Assembly plugin and the file assembly descriptor.

jgifford25