How to consolidate assembly artifacts from subprojects in Maven?

Sorry if this is considered elsewhere, I am afraid that I cannot find the answer to this particular trivial question.

I have a maven project that references and builds 4 subprojects (as packages). I correctly installed the dependencies between the sub-projects, and I end up with 4 different .jar files:

  • parentproj / sub1 / target / sub1.jar
  • parentproj / sub2 / target / sub2.jar
  • parentproj / sub3 / target / sub3.jar
  • parentproj / sub4 / target / sub4.jar

My question is, how do I configure the parent assembly mu so that when building from the main .POM file, all 4 jars are placed in "/ parentproj / target / ..."?

One more question: how do I also create xxxx-ALL.jar (which combines the contents of these 4 packages)?

+3
source share
2

Maven Assembly "dir", , "jar" .

:

  • maven ( )
  • maven ( pom), < >
  • pom.xml(. )
  • assembly.xml(. )

pom.xml:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2.1</version>
    <executions>
        <execution>
                <id>distro-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
            <configuration>
                <appendAssemblyId>false</appendAssemblyId>
                    <finalName>somefolder</finalName>
                    <attach>false</attach>
                    <descriptors>
                    <descriptor>assembly.xml</descriptor>
                    </descriptors>
                <phase>package</phase>
            </configuration>
        </execution>
    </executions>
</plugin>

assembly.xml:

<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>SomeName</id>
<formats>
    <format>dir</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<baseDirectory></baseDirectory>

<fileSets>
    <fileSet>
        <directory>appfiles</directory>
        <includes>
            <include>**</include>
        </includes>
        <outputDirectory>.</outputDirectory>
    </fileSet>
</fileSets>

<moduleSets>
    <moduleSet>
        <!-- useAllReactorProjects must be false if the assembly run on the project with the module list -->
        <useAllReactorProjects>false</useAllReactorProjects>
        <includeSubModules>false</includeSubModules>

        <binaries>
            <includeDependencies>true</includeDependencies>
            <outputDirectory>bundle</outputDirectory>
            <unpack>false</unpack>
        </binaries>
    </moduleSet>
</moduleSets>

+3

: xxxx-ALL.jar( 4 )?

uber-jar ( ) Maven shade. uber-jar.

+1

All Articles