How to put all dependencies in separate folder for runnable jar?

membersound :

I'm using mvn package to create a runnable jar with all dependencies packed inside, which runs fine. But I'd prefer to have all external dependencies packed in a separate folder. What would I have to change therefore?

    <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.4</version>
        <configuration>
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
            <archive>
                <manifest>
                    <mainClass>my.MainApp</mainClass>
                </manifest>
            </archive>
        </configuration>
        <executions>
            <execution>
                <id>make-assembly</id>
                <phase>package</phase>
                <goals>
                    <goal>single</goal>
                </goals>
            </execution>
        </executions>
        </plugin>
Will :

Use the maven-dependencies-plugin to specify an output directory for the copy-dependencies execution.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>2.5.1</version>
    <executions>
      <execution>
        <id>copy-dependencies</id>
        <phase>package</phase>
        <goals>
        <goal>copy-dependencies</goal>
        </goals>
        <configuration>
        <outputDirectory>${project.build.directory}/lib/</outputDirectory>
        </configuration>
      </execution>
    </executions>
</plugin>

Update:

To let the jar know where to find the lib folder, you can specify this as a Class-Path value in the manifest using the maven-jar-plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <configuration>
    <archive>
        <manifest>
        <addClasspath>true</addClasspath>
        <classpathPrefix>lib/</classpathPrefix>
        <mainClass>foo.bar.MainClass</mainClass>
        </manifest>
    </archive>
    </configuration>
</plugin>

Hope this helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to create a runnable jar with maven that includes dependencies in a separate "lib" folder (not an uber jar)

From Dev

How can I put all dependencies into one folder inside a JAR file with Maven?

From Dev

How to create a jar with Maven that includes dependencies in a separate folder for each dependency

From Dev

Runnable jar with dependencies

From Dev

CefSharp ChromiumWebBrowser put all dependencies in different Folder

From Dev

How to import all dependencies of a jar?

From Java

How do I put all required JAR files in a library folder inside the final JAR file with Maven?

From Dev

How to specify a runnable jar to use tomcat's lib for dependencies

From Dev

How can I create an executable/runnable JAR with dependencies using Maven?

From Dev

How do I create a Netbeans style Jar with all dependencies in a lib folder?

From Dev

How to use runnable jar in java project by importing it to libs folder

From Java

Bundle native dependencies in runnable .jar with Maven

From Dev

Gradle dependencies not being exported to runnable jar by eclipse

From Dev

Deploying a runnable jar in ECLIPSE by considering dependencies

From Dev

How do I only put dependencies into a specific folder for yarn?

From Dev

How to put test executables into a separate folder using CMake?

From Dev

Kotlin: How to create a runnable jar?

From Dev

How to retrieve NuGet package with all dependencies to local folder?

From Java

How to produce an executable jar file with all maven dependencies?

From Java

How do I create a jar with all dependencies using Gradle 4.4?

From Dev

How to generate javafx jar from gradle including all dependencies

From Dev

how to put all docx data into separate dataframe columns in python

From Dev

How to put all app.use in a separate common file

From Dev

How to load files and all result put in separate files in bash?

From Dev

Rename all files in a folder from camel case to lowercase and put underscore to separate words

From Dev

Maven not adding all dependencies to jar

From Java

How to list dependencies of a JAR

From Dev

how to put all files from folder and subfolders into an array

From Dev

How to get all commit releated to a folder and put it into new repo?

Related Related

  1. 1

    How to create a runnable jar with maven that includes dependencies in a separate "lib" folder (not an uber jar)

  2. 2

    How can I put all dependencies into one folder inside a JAR file with Maven?

  3. 3

    How to create a jar with Maven that includes dependencies in a separate folder for each dependency

  4. 4

    Runnable jar with dependencies

  5. 5

    CefSharp ChromiumWebBrowser put all dependencies in different Folder

  6. 6

    How to import all dependencies of a jar?

  7. 7

    How do I put all required JAR files in a library folder inside the final JAR file with Maven?

  8. 8

    How to specify a runnable jar to use tomcat's lib for dependencies

  9. 9

    How can I create an executable/runnable JAR with dependencies using Maven?

  10. 10

    How do I create a Netbeans style Jar with all dependencies in a lib folder?

  11. 11

    How to use runnable jar in java project by importing it to libs folder

  12. 12

    Bundle native dependencies in runnable .jar with Maven

  13. 13

    Gradle dependencies not being exported to runnable jar by eclipse

  14. 14

    Deploying a runnable jar in ECLIPSE by considering dependencies

  15. 15

    How do I only put dependencies into a specific folder for yarn?

  16. 16

    How to put test executables into a separate folder using CMake?

  17. 17

    Kotlin: How to create a runnable jar?

  18. 18

    How to retrieve NuGet package with all dependencies to local folder?

  19. 19

    How to produce an executable jar file with all maven dependencies?

  20. 20

    How do I create a jar with all dependencies using Gradle 4.4?

  21. 21

    How to generate javafx jar from gradle including all dependencies

  22. 22

    how to put all docx data into separate dataframe columns in python

  23. 23

    How to put all app.use in a separate common file

  24. 24

    How to load files and all result put in separate files in bash?

  25. 25

    Rename all files in a folder from camel case to lowercase and put underscore to separate words

  26. 26

    Maven not adding all dependencies to jar

  27. 27

    How to list dependencies of a JAR

  28. 28

    how to put all files from folder and subfolders into an array

  29. 29

    How to get all commit releated to a folder and put it into new repo?

HotTag

Archive