Home > OS >  How do you combine multiple files into 1 using maven assembly?
How do you combine multiple files into 1 using maven assembly?

Time:12-02

I have tried to combine the two files into 1 common manifestAB.txt file. This is a snippet of my assembly.xml file.

<files>
    <file>
        <source>src/resources/manifestA</source>
        <outputDirectory>./</outputDirectory>
        <destName>manifestAB.txt</destName>
        <filtered>true</filtered>
    </file>
    <file>
        <source>src/resources/otherDir/manifestB</source>
        <outputDirectory>./</outputDirectory>
        <destName>manifestAB.txt</destName>
        <filtered>true</filtered>
    </file>
</files>

Right now, it is only copying the contents of manifestA.

CodePudding user response:

may be two step

step 1: merge two source file into one source file

method A: use merge-maven-plugin(How can I merge resource files in a Maven assembly?)

method B: use exec-maven-plugin run copy or cat command combine two txt file into one txt file.

Step 2:

<files>
    <file>        <source>${build.outputDirectory}/manifestAB.txt</source>
        <outputDirectory>./</outputDirectory>
        <destName>manifestAB.txt</destName>
        <filtered>true</filtered>
    </file>
</files>

CodePudding user response:

Use this approach just like the Maven assembly does: https://github.com/apache/maven/blob/c6ecff9923088d854d4621e17d602f1c70dda806/apache-maven/src/assembly/component.xml#L103-L131

  • Related