We have a aggregation .pom set up to include several, individual modules, similar to the Maven documentation:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<packaging>pom</packaging>
<modules>
<module>my-module</module>
<module>my-module-2</module>
</modules>
</project>
Is there a way to get the artifacts from the builds (.JAR files) from these two modules into a common ‘dist’ directory after building? I did not want to adjust to output directory for the individual modules from “my-module/target” since they can be built separately as well.
I’m a Maven new-comer, so I’m sure there’s an easy way to do this I’m missing.
The Maven Assembly Plugin can do that, it is very powerful and flexible. But power and flexibility also mean that this is not the most trivial plugin to use. In your case, the idea would be to generate a
dirdistribution from amoduleSetsand you’ll have to create a custom assembly descriptor for that.I suggest starting with chapter 8.2. Assembly Basics of the Maven book and to pay a special attention to the chapter 8.5.5. moduleSets Sections.