Search code examples
mavenmaven-2maven-pluginmaven-assembly-plugin

create common output zip file using maven


I have 3 modules which are linked to a parent project similar to this.

root (pom.xml)
   +--- mod1 (pom.xml)
   +--- mod2 (pom.xml)
   +--- mod3 (pom.xml)

I have some configuration files in config folder of mod1. I have other configuration files in config folder of mod2. I want to place all these configuration files in a common folder in the output zip file.

Is this possible


Solution

  • Yes, it is possible. You have to add maven-assembly-plugin execution to the last module in build process (I assume in your case it is mod3) and add assembly descriptor, somewhat like this:

    <assembly>
      <formats>
        <format>zip</format>
      </formats>
      <fileSets>
        <fileSet>
            <directory>../mod1/config</directory>
            <outputDirectory>config</outputDirectory>
        </fileSet>
        <fileSet>
            <directory>../mod2/config</directory>
            <outputDirectory>config</outputDirectory>
        </fileSet>
      </fileSets>
    </assembly>