Munish Gogna has been a software developer since 2006. His languages and technologies include: Java, J2EE, SQL, Spring, Hibernate as well as basic shell scripting (Unix flavors). He is currently working at a swiss private bank in Singapore. Munish has posted 6 posts at DZone. View Full User Profile

Maven - Creating a Jar From Contents of Another Jar File

  • submit to reddit

Recently I came across a situation where I had to create a jar file with similar contents as of some other available jar. As using maven we cannot copy one jar file within another and also I didn't want to reinvent the wheel again so here is how I achieved the same.

Let's say there is an artifact 'sandeep-ejb-client' (some client ejb jar which has some dependency on some other artifacts say log4j and junit)
What I am interested is in creating a new jar file that has all the ejb client classes without including dependencies of 'sandeep-ejb-client'.

Here is the POM file to achieve the same:

<project xmlns=""

<name>Test JAR</name>



That's All, Simple? If anyone has got better approach please feel free to discuss !!!


Your rating: None
Published at DZone with permission of its author, Munish Gogna.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)