Question

Hi I need to assembly jars from multimodule project in master directory. Let us have a structure like this:

MASTER(pom)
|
+-A3(pom)
| +-A1(jar)
| +-A2(jar)
+-B3(pom)
  +-B1(jar)
  +-B2(jar)

What I want to achieve is to assembly all jar packaged modules in MASTER.

jars/
+- A1.jar
+- A2.jar
+- B1.jar
+- B2.jar

For now I achieved only good resolution on submodules (A3 and B3) by creating pom.xml like:

<modules>
 <module>../A1</module>
 <module>../A2</module>
</modules>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
                    <configuration>
                        <descriptors>
                            <descriptor>src/main/assembly/bin.xml</descriptor>
                        </descriptors>
                    </configuration>
        </plugin>
    </plugins>
 </build>

and assembly descriptor:

<moduleSets>
  <moduleSet>
    <includes>
      <include>org.mycompany:A1</include>
      <include>org.mycompany:A2</include>
    </includes>
    <binaries>
      <includeDependencies>false</includeDependencies>
      <outputDirectory>jars/${artifactId}</outputDirectory>
      <unpack>false</unpack>
    </binaries>
  </moduleSet>
</moduleSets>

When I do

mvn clean package assembly:assembly

on submodules (A3 or B3) separately they seem to assembly their own submodules fine.

I don't know how to specify assembly descriptor in MASTER. The one similar to A3 and B3 descriptor does not deal with it ([ERROR] you must specify at least one file). I tried several additional tags like includeSubModules... still nothing.

Was it helpful?

Solution

Resolution as promised (Master Assembly Descriptor):

<moduleSets>
 <moduleSet>
    <binaries>
        <includeDependencies>false</includeDependencies>
        <outputDirectory>jars/${artifactId}</outputDirectory>
        <unpack>false</unpack>
    </binaries>
 </moduleSet>
</moduleSets>

as you can see - no pointing to specific modules with <include> like in A3 and B3

<includes>
 <include> 
  (...) 
 </include>
</includes>

this is strange indeed. Nevertheless working.

OTHER TIPS

<module> just tells to add other poms in the reactor, but it doesn't provide any dependencies. So you cannot refer these modules anywhere, including assembly descriptors until you add dependencies.

If you want and build, and depend, you should add and <module> and <dependency>.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top