I have a quite large java maven project with over 200 modules, it is OK as is. I am trying to merge all of those modules to single jar.
In some cases it would be very handy to declare just one new maven dependency eg. my-library-5.2.4-SNAPSHOT-bundle.jar or something similar in new projects.
I have tried to use maven assembly-plugin. I can create new jar file, jar contains all the module jars and it goes properly to local .m2 -folder if I install it. Jar can be declared as dependency in other projects.
But the problem is that I can't import any of those modules inside the library in my java classes. Importing won't recognise those.
I have added this build section to my root pom.xml:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-bundle</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
And my assembly.xml looks like this:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bundle</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<binaries>
<outputDirectory>modules</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
</assembly>