djechlin djechlin - 2 years ago 178
Java Question

Maven deploy jar with dependencies to repo

I can deploy a

by using the following in my
and running
mvn deploy

<name>Internal Snapshots</name>

And I can build an executable
using the following:


Problem is I don't know how to stitch these together to deploy the executable
to my Maven repo. I don't really know if this is accomplished by a new plugin or by adding a goal or other step to the existing assembly plugin.

Answer Source

Essentially my difficulty doing this revealed the fact that my pom.xml was way off the rails already. Everything would have snapped into place on its own. I was formerly doing:

  • Save all the dependencies into a lib folder
  • Build a jar with a classpath slurping up that lib folder
  • Use the assembly plugin to make another deployable jar

I think there were several reasons this sort of made sense along the way, especially when my libraries were not well-factored from my applications.

However by deleting 1 and 2 all that is needed is the distributionManagement section and the deploy phase works automagically. So all in all this is an amazing case of literally adding functionality by deleting large swathes of code.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download