tags:

views:

29

answers:

2

I have a small (4 module) maven project with the root pom in pom packaging. Right now, I have a impl module that contains the main methods and setup. This does lead to some issues, eg building a single jar for the entire project, (possible) huge dependency list containing all modules, and confusion trying to trace back to the main method for future developers.

So I'm thinking: Is it best practice to put this kind of stuff in the root project, or should it stay in its own module? Would there be any disadvantages of putting it in root (eg plugin issues)?

+1  A: 

AFAIK, the parent module of a multi-module project has to have type "pom" and that would preclude putting any code or other resources into it.

Certainly, I wouldn't try this.

If you want to have all of your classes, etc assembled into a single JAR, there are other ways of doing this. For example, take a look at the Maven Shade Plugin.

Stephen C
+1  A: 

This does lead to some issues, eg building a single jar for the entire project

There are solutions for this (e.g. using a dedicated module and the Maven Assembly Plugin or the Maven Shade Plugin).

(possible) huge dependency list containing all modules,

I didn't understand what you're referring to here.

and confusion trying to trace back to the main method for future developers.

Just document things if nobody can transmit the information.

So I'm thinking: Is it best practice to put this kind of stuff in the root project, or should it stay in its own module? Would there be any disadvantages of putting it in root (eg plugin issues)?

Stephen is correct, aggregating and/or parent POMs must have a packaging of type pom and you can't put any code in them.

Pascal Thivent
"(possible) huge dependency list containing all modules" means that the impl module has to have dependencies to almost all the modules. If a maven project gets large, your talking a huge dependency list in the impl module
TheLQ
@TheLQ Well, yes, the impl module would have to declare dependencies on its direct dependencies. But I'm not sure to understand the problem with that. And I'm not sure that moving dependencies declaration outside a given module would make things "better".
Pascal Thivent