0

I have a bunch of modules in my setup, and I'd like to copy a file to each of these modules. As copying is mostly done by using maven-assembly-plugin, I'd like to use it here as well.

However, I noticed that the plugin does not allow any loop mechanism such as for-each or so. Therefore when we have, let's say, 50 modules, we have to repeat coding fileSet tag 50 times, which looks lame and unprofessional.

For instance, consider the below descriptor. The snippet copies the config.properties file to one of the modules (project.base). However, I have a lot of modules in my setup, so I need to do the same operation for each of them. This leads to a situation where I need to copy-paste the fileSet 50 times, which is outrageous.

<fileSets>
        <fileSet>
            <directory>config</directory>
            <outputDirectory>../project.base</outputDirectory>
            <lineEnding>unix</lineEnding>
            <filtered>true</filtered>
            <includes>
                <include>config.properties</include>
            </includes>
            <excludes>
                <exclude>**/*</exclude>
            </excludes>
        </fileSet>
       <!-- Same to be repeat for every module here-->
    </fileSets>

Is there a way to automate this? Or was it designed to operate this way?

Schütze
  • 1,044
  • 5
  • 28
  • 48
  • maybe [this](http://stackoverflow.com/q/586202/1988304) is useful – JimHawkins Jul 13 '16 at 11:18
  • see also [maven-resources-plugin](https://maven.apache.org/plugins/maven-resources-plugin/index.html) and this [guide](https://maven.apache.org/guides/mini/guide-multiple-modules.html) – JimHawkins Jul 13 '16 at 11:24
  • I saw both, but I cannot use `ant-plugin` as I am told not to, and as for `resources-plugin`, the [same](https://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html) situation persists. I guess you just have to copy-paste the same tag for each copy. – Schütze Jul 13 '16 at 11:27
  • Can you explain why you need to do this copying over and over? It sounds like architecture is wrong ? – khmarbaise Jul 13 '16 at 14:16
  • Because the config file is to be put under every module's directory after the compilation process. – Schütze Jul 14 '16 at 07:14
  • Not only this file,sometimes you just need to have the copy of a certain file in every directory. It's not the first time I am encountering such a situation. And I am quite shocked to see that maven is unable to handle such a trivial task, apart from utilizing Ant. – Schütze Jul 14 '16 at 07:51

0 Answers0