Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Packaging jar is invalid Aggregator project need pom as packaging

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?

like image 704
Anvay Avatar asked Sep 11 '13 06:09

Anvay


People also ask

What is the difference between POM and jar packaging?

POM is the simplest packaging type. The artifact that it generates is itself only, rather than a JAR, SAR, or EAR. There is no code to test or compile, and there are no resources the process. The default goals for projects with POM packaging are shown in Table 4.3, “Default Goals for POM Packaging”.

What is POM and jar?

“pom” packaging is nothing but the container, which contains other packages/modules like jar, war, and ear. if you perform any operation on outer package/container like mvn clean compile install. then inner packages/modules also get clean compile install. no need to perform a separate operation for each package/module.

What is the use of packaging packaging in Maven?

The packaging type is an important aspect of any Maven project. It specifies the type of artifact the project produces. Generally, a build produces a jar, war, pom, or other executable. Maven offers many default packaging types and also provides the flexibility to define a custom one.


1 Answers

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
like image 114
ben75 Avatar answered Sep 20 '22 01:09

ben75