I have a main project (made up of several maven projects/modules) and a helper project. All projects are mavenized, the main one is the parent of its modules and the auxiliary project has no parent.
The goal is to create a single jar, containing the classes of the projects that make up the main and the classes of my module project.
EDIT 1: I have created a separate Maven project, which includes all the projects and modules mentioned above and I have managed to create a jar with all the (compiled) classes of all the projects, but now I have two points to address:
The auxiliary project has xml files that do not appear inside the jar, I think I have to touch the includes but it doesn't work for me
I am unable to create a jar with the java sources without compiling
What am I failing?
So I have the pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>TestProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/assembly/bin.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.test.grupo</groupId>
<artifactId>ProyectoPadre</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.test.otro</groupId>
<artifactId>ProyectoAuxiliar</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
And the bin descriptor is as follows:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>bin</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<includes>
<include>com.test.grupo:Modulo1</include>
<include>com.test.grupo:Modulo2</include>
<include>com.test.otro:ProyectoAuxiliar</include>
</includes>
<unpack>true</unpack>
<unpackOptions>
<includes>
<include>*.xml</include>
</includes>
</unpackOptions>
<scope>compile</scope>
<useProjectArtifact>false</useProjectArtifact>
<useProjectAttachments>false</useProjectAttachments>
</dependencySet>
</dependencySets>
It's been a while since I got the answer, but I forgot to indicate it in case someone needs it in the future.
This would be my pom:
(I had a problem with the default directory where the classes were saved, that's why I keep it in classProject)
And the descriptor would look like this: