maven-3onejar

move the maven-onejar generated jar to a custom location


I am using the onejar-maven-plugin to generate the jar for my project and it all goes well. But, when I try to change it to a sub-folder, for eg. dist, the jar from maven-jar-plugin gets generated, not the jar from onejar.

The onejar plugin does not have an output directory option.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <outputDirectory>${project.build.directory}/dist</outputDirectory>
        <archive>
            <manifest>
                <mainClass>com.ss.itempriceclient.ItemPriceUploader</mainClass>
            </manifest>
        </archive>
    </configuration>
</plugin>
<plugin>
    <groupId>org.dstovall</groupId>
    <artifactId>onejar-maven-plugin</artifactId>
    <version>1.4.4</version>
    <executions>
        <execution>
            <configuration>
                <classifier>onejar</classifier>
            </configuration>
            <goals>
                <goal>one-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

How do I change the output directory of the onejar generated file to a subfolder, eg. dist?


Solution

  • I finally went with maven-assembly-plugin. Has lots of configuration options.