5

I have maven multi-modules project. At the parent level, i have some java files. And in the parent pom.xml, at the package phase i do some stuff.

Usually, when i run mvn package at parent level, the package phase of parent pom will be run and all the modules will be packaged as well.

I am looking for a way that allow me to do these (when i run mvn package):

  • allow me to run only paren pom.xml (the script at the package phase), not the modules. This is the 1st priority.
  • allow me to run paren pom.xml and some particular modules (like module 1, module 2 BUT not module 3 , module 4).

Can i use profile for those issue?

Thanks.

paweloque
  • 18,466
  • 26
  • 80
  • 136
David
  • 3,538
  • 9
  • 39
  • 50

3 Answers3

13

While I agree with the fact that you may not have optimal project structure, the answer is that Maven 2.2.1 has an option "--non-recursive" which satisfies your first requirement:

-N,--non-recursive    Do not recurse into sub-projects

So something like this:

mvn --non-recursive clean compile 
Brad Lee
  • 629
  • 7
  • 11
1

Why do you want to have java code on the top level? In my opinion this is not a very good idea. Have your code in the subprojects and let the top-level project be responsible for holding the general information and configuration of the entire project.

If you have some base-library code in the top-level project now, you can put it in a sub-project and set up dependencies between the projects.

paweloque
  • 18,466
  • 26
  • 80
  • 136
  • I have several multi-module projects where site documentation is in /src/site/markdown in the root of the project (same level as parent pom). Being able to run 'mvn site -N' means I can iterate on my rendered documentation without having to build every sub-module. – efelton Nov 10 '17 at 20:28
0

Take a look at Maven parent pom vs modules pom

The nature of your question indicates that your project structure may not be optimal.

Community
  • 1
  • 1
Yuriy Zubarev
  • 2,821
  • 18
  • 24