Question

Our pom.xml has multiple executions inside the maven-jar-plugin with the intention of creating three separate jar files. What is the means to invoke mvn and build the three jars?

Presently

mvn compile jar:jar

still creates only a single jar.

    <artifactId>maven-jar-plugin</artifactId>
        <version>2.3.2</version>
    <executions>
        <execution>
            <id>UDFCommon</id>
            <goals><goal>jar</goal></goals>
            <phase>package</phase>
            <configuration>
                <forceCreation>true</forceCreation>
                <classifier>UDFCommon</classifier>
                <includes>
                    <include>**/pafcommon/*</include>
                </includes>
            </configuration>
        </execution>
        <execution>
            <id>UDFOne</id>
            <goals><goal>jar</goal></goals>
            <phase>package</phase>
            <configuration>
                <classifier>UDFOne</classifier>
                <includes>
                    <include>**/dqm/*</include>
                </includes>
            </configuration>
        </execution>
        <execution>
            <id>UDFTwo</id>
            <goals><goal>jar</goal></goals>
            <phase>package</phase>
            <configuration>
                <classifier>UDFTwo</classifier>
                <includes>
                    <include>**/ciview/*</include>
                </includes>
            </configuration>
        </execution>
    </executions>
    </plugin>
Was it helpful?

Solution

It appears that jar:jar does not handle multiple jar files. But running

mvn compile package

does the trick.

-rw-r--r--   1 steve  staff  2629074 Oct 16 15:24 UDFPafDqm.jar
-rw-r--r--   1 steve  staff    13286 Oct 16 15:24 UDFPafDqm-UDFTwo.jar
-rw-r--r--   1 steve  staff    40315 Oct 16 15:24 UDFPafDqm-UDFOne.jar
-rw-r--r--   1 steve  staff     6942 Oct 16 15:24 UDFPafDqm-UDFCommon.jar

An assembly.xml is required for this: a barebones one is shown below.

<assembly>
    <id>job</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${project.build.outputDirectory}</directory>
            <outputDirectory>/</outputDirectory>
        </fileSet>
    </fileSets>


    <dependencySets>
        <dependencySet>
            <scope>runtime</scope>
            <outputDirectory>lib</outputDirectory>
        </dependencySet>
    </dependencySets>
</assembly>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top