Packaging jar is invalid Aggregator project need pom as packaging

Anvay picture Anvay · Sep 11, 2013 · Viewed 36.6k times · Source

My project has different modules.

  • Each module has a pom.xml which specifies jar packaging.
  • Each pom refers to common parent.
  • In the parent module there is also a pom.xml which includes all the modules.

When I tried to package using the pom.xml of the parent module, it shows the error - "Packaging jar is invalid Aggregator project need pom as packaging".

What can I do to make an executable jar of the application from maven?

Answer

ben75 picture ben75 · Sep 11, 2013

To make things short: if your parent-aggregator project don't contains source code (and it's a good practice), just add this to your parent pom.xml:

<packaging>pom</packaging>

If the parent project contains source code, I strongly suggest you to:

  • move this code in a new module (let's call it commons)
  • make commons a child module of your parent project
  • add the commons module as a dependency of all other modules requiring it (maybe all of them)
  • add <packaging>pom</packaging> in the parent pom.xml