Maven – Include system scope dependency in maven-assembly-plugin

If you don’t have Maven repository server like Archiva or Nexus, you may need to include those libs which are not public on the internet in your Maven project and specifiy the dependency scope as system in the pom.xml. The following example includes the eureka-0.0.1.jar which is located in the folder called external on project root.



A few months ago i wrote a blog post about how to package the project jar file with all dependencies.
Maven – Package the jar file with dependencies

Please note that if you have system scope dependencies, they would not be included during the assembly as mentioned in the above blog post.

A workaround is instead of using system scope, we could make use of the maven-install-plugin to in install the external jars to the machine local Maven repository before the build. So you can remove the <scope> and <systemPath> in your dependency setting such that the it will use the default compile scope just like other dependencies.



Then add the maven-install-plugin in the pom.xml as well.



We could only attach the install process in the clean life cycle otherwise Maven requires all dependencies to be resolved before executing. So the external lib is not present in the local Maven repo, you have to install it through

mvn clean


Then you can start packing as normal.

mvn package


Please note that the above workaround violates the Maven practice so i would suggest setting up a repository server to cache the public artifacts and manage your own libs as well.

Done =)



6 thoughts on “Maven – Include system scope dependency in maven-assembly-plugin”

  1. This also doesn’t work if the library in question prevents renaming. Some SAP based java libraries are picky about this and installing the jar to your local repository breaks the jar and prevents it from running.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.