Rename a file using fileSet in maven

2.6k Views Asked by At

I am using maven assembly plugin. I am trying to build a tgz with maven and I need a file to be copied with a different name while packaging it.

File 'abc.txt' is being copied to directory named 'target'. Is there a way I can rename this file to xyz.txt in this syntax ?

+++++++++++++++++++++++++++++++++++++++++++++++++++

<fileSet>
      <directory>source</directory>
      <outputDirectory>/target</outputDirectory>
      <includes>
        <include>abc.txt</include>
      </includes>
 </fileSet>

+++++++++++++++++++++++++++++++++++++++++++++++++++

1

There are 1 best solutions below

0
On

I'm not sure if you still need the answer for this, but I had a similar issue. In my case, I used to do the rename, not . I'm assuming you are using the assembly plugin. In your assembly.xml file, enter the following:

<files>
        <file>
            <source>source/abc.txt</source>
            <outputDirectory>target/</outputDirectory>
            <destName>xyz.txt</destName>
        </file>
<files>