0

I am building java project and by using maven-dependency-plugin i am able to copy all dependencies as jar in lib folder under target folder.

By using maven-jar-plugin i am able to create jar with classes/resources and manifest file.

But my desire output is that my.jar should include dependencies jar. I found couple of plugin like maven-shade-plugin, onejar-maven-plugin and maven-assembly-plugin.

But all of these provide exploded dependencies jars and i need jars dependencies as it is.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
        <execution>
            <id>copy-dependencies</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/lib</outputDirectory>
                <overWriteReleases>false</overWriteReleases>
                <overWriteSnapshots>false</overWriteSnapshots>
                <overWriteIfNewer>true</overWriteIfNewer>
            </configuration>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
        <archive>
            <manifest>
                <addClasspath>true</addClasspath>
                <classpathPrefix>lib/</classpathPrefix>
                <mainClass>com.my.app</mainClass>
            </manifest>
        </archive>
    </configuration>
</plugin>
ImranRazaKhan
  • 1,955
  • 5
  • 33
  • 74

0 Answers0