DesirePRG
DesirePRG

Reputation: 6378

Maven submodule with pom packaging?

does it make sense to have a maven submodule (which doesn't have any submodules to itself) to have a pom packaging?

Is there any use of doing that at some instance?

If not does it mean that all my last level submodules should have a packaging which is not pom?

Upvotes: 0

Views: 1406

Answers (2)

rec
rec

Reputation: 10895

Typically, there is a certain lifecycle associated with the packaging, e.g. the "jar" packaging will run the maven-compiler-plugin during the "compile" phase, etc.

If you choose "pom", then there is a very limited default lifecycle - I guess only the the "install" and "deploy" plugins are bound to the respective phases. You could probably use it if you want to have more control over what happens in a build.

Typically, you only would use "pom" packaging for aggregator modules (those that have submodules).

For more details on packagings and the Maven lifecycle, you can refer to Maven: The Complete Reference - 4.2. Package-specific Lifecycles

As a real-world where I actually use "pom" packaging in a submodule:

In some projects, I have a submodule called "PROJECT-doc" which contains asciidoc documentation that I compile to HTML and PDF as part of the build. These modules have the "pom" packaging - there is no Java code to compile, no JAR to build, and no unit tests to run - just the documentation is built. I manually bind the "asciidoctor-maven-plugin" to the "generate-resources" and that's it.

Upvotes: 1

Niklas P
Niklas P

Reputation: 3507

I think the main question is the use of packaging pom in maven - this question was answered here: What is "pom" packaging in maven?

The short form is: yes, you shouldn't have a module without submodules that uses packaging pom.

Upvotes: 0

Related Questions