Supply of the only jar with the Maven project

I want to deliver a single .jar file for my clients, but my project is currently built with Maven, and I have several modules that generate one .jar each.

I know that attachments of different .jar files are a great idea, so I don't know how to do this.

Any ideas?

+7
jar maven-2
source share
4 answers

First of all, ask yourself if you really have a good reason to pack your application and all its dependencies in one jar. I did not find a lot of good reason for this (most of the reasons are due to the stupidity of organizational policy or simply ignorance). The way to keep the libraries in your banks and supply .zip / .tar.gz containing all your libraries and your application using

  • An executable .jar file with classpath accordingly your MANFIEST.MF file
  • .bat / .sh script that calls java and creates an appropriate class based on your fingerprints

Conversely, use JNLP (better known as Java Web Start).

If you really want maven to collect all your dependencies and your application under one jar, then you want to use the "jar-with-dependent" predefined builds . The maven build plugin usage page also shows how you can do this.

+8
source share

If you really want to go in this direction, there are several ways to do this:

Depending on your exact requirements and limitations, you may prefer one or the other.

+13
source share

Actually, embedded .jar files are not possible. There are no other cans in the jar.

.war and .ear files may contain jars, and this is a good solution if you are supplying a J2EE application.

If your application is just J2SE, I recommend looking at the Maven build plugin . As the name implies, it allows you to create a single binary distribution of your assembly.

+1
source share

You can also try the Maven Shade plugin. http://maven.apache.org/plugins/maven-shade-plugin/

General instructions for using the Shade plugin can be found on the usage page. Some more specific use cases are described in the examples below. Last but not least, users sometimes add additional examples, tips or errors to the wiki plugins page.

If you still have questions regarding the use of plugins, feel free to contact the user mailing list. Mailing list entries are archived and may already contain an answer to your question as part of an older thread. Therefore, it is also worth browsing / searching the mail archive.

If it seems to you that there is no function in the plugin or there is a defect, you can fill out a function request or an error report in our tracker problem. When creating a new problem, provide a detailed description of your problem. Especially for fixing bugs, it is imperative that developers can reproduce your problem. For this reason, whole debug logs, POM, or most preferably small demo projects related to this issue are greatly appreciated. Of course, patches are also welcome. Attendees can check out the project from our source repository and find more information in the help guide for Maven.

+1
source share

All Articles