0

When I package my project, I would like to include all the dependencies of that project in a folder named "lib" inside the JAR. Does anyone knows how to do this?

So far, I found this plugin, which allows me to include all my dependencies in the JAR, but they are in the root directory.

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <mainClass>main.Main</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

Thank you!

Rors
  • 159
  • 2
  • 10
  • Why would you want to do this? A jars contained within the lib directory of a jar will not be added to the classpath. This behaviour only occurs on web servers when expanding applications packaged as WAR files. – Mark O'Connor Dec 20 '15 at 20:39
  • I don't want to add a JAR inside the /lib directory of other JAR. I want to add the classes or directories of my dependencies inside the /lib directory of my application's JAR – Rors Dec 20 '15 at 20:55
  • 1
    If you change the folder inside the jar you will get a non working jar cause folders inside a jar are interpreted as package...I'm not sure if i understand your wish...Apart from that the `jar-with-dependencies` will package all dependencies inside the jar based on their appropriate packges. – khmarbaise Dec 20 '15 at 21:47

0 Answers0