Curro
Curro

Reputation: 1411

Maven assembly plugin: include config files from modules

This is my project structure:

myapp-parent
  moduleMain
      src/main/java   ---> main class (it loads a spring context)
      src/main/config ---> main config files
  module1
      src/main/java   ---> specific code of the module
      src/main/config ---> specific config files of the module

I'm using assembly and appassembler maven plugins for the distribution. This is the assembly descriptor:

<assembly>
<id>archive</id>
<formats>
    <format>zip</format>
    <format>tar.gz</format>
</formats>

    <fileSets>
   <fileSet>
        <directory>${project.build.directory}/generated-resources/appassembler/jsw/myProject/bin</directory>
        <outputDirectory>bin</outputDirectory>
        <includes>
            <include>**</include>
        </includes>
        <useDefaultExcludes>true</useDefaultExcludes>
        <fileMode>0755</fileMode>
        <directoryMode>0755</directoryMode>
    </fileSet>

    <fileSet>
        <directory>src/main/config</directory>
        <outputDirectory>conf</outputDirectory>
    </fileSet>

    <fileSet>
        <directory>${project.build.directory}/generated-resources/appassembler/jsw/myProject/conf</directory>
        <outputDirectory>conf</outputDirectory>
    </fileSet>

    <fileSet>
        <directory>${project.build.directory}/generated-resources/appassembler/jsw/myProject/lib</directory>
        <outputDirectory>lib</outputDirectory>
    </fileSet>
 </fileSets> 
</assembly>

Thus I get a distribution package which includes a config folder ('conf'). The thing is that config files in that directory are from the mainModule and I would like to get that config files from module1 will be in the same location too.

myProject.tar.gz
    bin
    lib
    logs
    conf --> Here we have config files from modeuleMain & module1

any idea???

Upvotes: 1

Views: 3275

Answers (2)

buildchimp
buildchimp

Reputation: 109

You might want to check out the <moduleSet/> configuration in the assembly descriptor, especially the <sources/> sub-section: ModuleSet Source-Inclusion Example.

NOTE: This will only get you PART of the way to a solution by itself! The problem is that the assembly plugin's moduleSets function was originally designed for operating only on child modules of the current project (the one creating the assembly). To work around this, we introduced a new configuration in or around version 2.2 of the assembly plugin, called <useAllReactorProjects/>. Setting this flag to true, makes all modules in the current build available to the assembly.

If you enable this in your moduleSet, you should be able to include the config files from module1.

Upvotes: 2

chad
chad

Reputation: 7519

Have you explored the multi-module support of the assembly plugin?

http://maven.apache.org/plugins/maven-assembly-plugin/examples/multimodule/index.html

Upvotes: 0

Related Questions