Take the 2-minute tour ×

I am working on a multi-module maven project with these modules

  |-- restful    // this is a jersey restful service as a WAR
  |-- shared     // some stuff shared by all other modules as a jar
  |-- cl-client  // a commandline client to the restful service, needs assembly

The parent pom.xml uses dependencyManagement to list all dependencies used by all modules

The pom for cl-client includes the assembly plugin, configured to be executed at the package phase:


and the assembly.xml is as follows:


When I run mvn package, the cl-client modules assembles fine and does create the directory that I hoped for, but the only problem is that all dependencies jars are copied in the lib/ directory, even the ones that are only used by the "restful" module such as jersey related jars. I tried to flip the useProjectArtifact flag, but it didn't seem to make any difference.

So I am just wondering if there is anyway I can tell Maven assembly to include only the jars required by the cl-client module. I poured through quite a few online resources on Maven assembly on multi-module projects, but wasn't able to get any clear answers.

share|improve this question
Does the cl-client project have the restful project as a dependency? If so, presumably executing mvn dependency:tree on the cl-client project shows all the JARs you are seeing in your assembly output? –  Duncan Feb 7 '13 at 8:07
Does the cl-client pom inherit from parent pom? –  Andrew Logvinov Feb 7 '13 at 8:09
@Andrew yes, the cl-client pom inherits from parent pom –  Jim Feb 7 '13 at 13:58
@Duncan thank you very much for the suggestion. I am still quite new to maven and didn't know about the dependency:tree command. This is very useful. It appears that hbase jar has a dependency on jersey, so that is why it is included. –  Jim Feb 7 '13 at 14:01
@Duncan: Would you (or Jim) please add an answer to this question with the solution. Then select this anweser as correct please Jim. It will then no longer be marked as "unanswered" -thanks! –  Jan Apr 30 '13 at 7:52

1 Answer 1

Use the mvn dependency:tree command to understand which dependencies exist between your modules. You'll probably discover an artifact has a transitive dependency on jersey, which is why it's being included.

share|improve this answer
+1: Fast one (aside from being a good answer as well, of course ;-) –  Jan Apr 30 '13 at 7:58

Your Answer


