1

I have a Maven project that is intended to be a demo of one of our products, which is itself a fat jar with several dependencies. We distribute the source code of these demos as a .zip file containing a self-contained Maven project that our customers can build and play around with.

I'm using the maven-assembly-plugin to do a custom assembly of our distributed demos project. I'm using a dependencySet to place our product's JAR in a lib/ directory in the final assembly. The problem is, the maven-assembly-plugin splits up our fat jar into the normal jar (without dependencies), and all of the dependencies of the jar. I would rather the plugin not split up the fat jar, and simply place the fat jar in the lib/ directory. Is there a way to do this?

assembly.xml:

    <dependencySets>
        <dependencySet>
            <useProjectArtifact>false</useProjectArtifact>
            <outputDirectory>lib/</outputDirectory>
            <includes>
                <include>our-product:jar</include>
            </includes>
            <outputFileNameMapping>our-product.jar</outputFileNameMapping>
        </dependencySet>
    </dependencySets>

pom.xml:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <mainClass>DemoManager</mainClass>
            </manifest>
        </archive>
        <!-- Generates jar -->
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <!-- Generates distributed demo project -->
        <descriptors>
            <descriptor>src/assembly/assembly.xml</descriptor>
        </descriptors>
    </configuration>
    <executions>
        <execution>
            <id>make-jar</id>
            <phase>package</phase>
            <goals>
                <goal>attached</goal>
            </goals>
        </execution>
    </executions>
</plugin>
mario_sunny
  • 1,412
  • 11
  • 29
  • The [latest version of the plugin (3.1.1)](http://maven.apache.org/plugins/maven-assembly-plugin/plugin-info.html) doesn't show the `attached` goal, which has been deprecated for a long time. If you switch goal to `single` does that make a difference? If you use the latest plugin version, does that help? Also, look carefully at the logs, how many times is the assembly plugin running? – user944849 Feb 26 '19 at 22:17

0 Answers0