1

I want to package my project in a single non-executable library JAR for distribution. How can I make a Maven project package all dependency JARs into my output JAR? There is a jar-with-dependencies option in Maven assembly plugin to create an executable JAR with dependencies. There is a reciept to obtain the goal. However, I need to build a library jar without Main class. How can I build such a jar?

Loom
  • 9,768
  • 22
  • 60
  • 112
  • Just build it and don't use the `maven-jar-plugin` per default it builds a non-executable `.jar` file. When the packaging is `jar` – CodeMatrix Jul 04 '19 at 12:56
  • There is a maven shade plugin, I believe that is what you are looking for. It will repack your dependencies directly into your jar. But I obviously have no idea why would you need it like that – maslan Jul 04 '19 at 13:09

1 Answers1

0

Its not necessary that you use the maven-jar-plugin to build a non-executable jar. The mvn clean install command by default builds a non-executable jar if it has the node <packaging>jar</packaging> in your projects pom.xml.

Leo Varghese
  • 165
  • 1
  • 2
  • 12
  • Actually, this is a way to build a non-executable jar __without__ dependencies – Loom Jul 04 '19 at 13:48
  • Thanks for the correction. Hope the maven-shade plugin helps you create a jar with dependencies. But not sure if it can be done without a Main class. – Leo Varghese Jul 05 '19 at 05:12