views:

327

answers:

3

Hi,

we have java and flex projects at work. We currently have 1 base pom that contains the configurations we want to use for both projects. Problem with this is: flex projects inherit configuration for javadoc and pmd for example, which they do not want.

I want to do this a bit more clean and have a real base-pom and then a java-base-pom and a flex-base-pom. But how does this work in a multimodule that has both a flex part and a java part?

We have plugins to our own application where we use the following structure:

  • my-plugin
    • my-plugin-client (flex)
    • my-plugin-server (java)

The my-plugin just contains a pom.xml with section. I would use the my-plugin pom.xml as a parent to both, but then I cannot also use the java base-pom or the flex base-pom also as parent. What would be the best approarch for this?

regards,

Wim

+1  A: 

Just image that pom.xml are in fact Java classes: you can have only one parent (or extends a class), but this parent can also have another parent, and so on.

As I explained here, you must distinguish the parent and aggregation principles in Maven, which means that my-plugin would be considered as an aggregation project, not necessarily a parent project for both my-plugin-client and my-plugin-parent.

So to summarize:

my-plugin will define the base pom for all your projects. Then, you create two new pom projects: java-base-pom and flex-base-pom. They have both my-plugin as parent. Now, my-plugin-client will have java-base-pom as parent, while my-plugin-server will use flex-base-pom for his parent.

This way, my-plugin-client will inherit all properties defined in the my-plugin pom.xml, and also from java-base-pom project.

romaintaz
Maybe I did not make myself clear enough. The base poms should be at the root of the hierarchy because the application itself also depends on it, or any other java module we build. It is just that next to that I also have this plugin structure which would need kind of 2 parents, but this is not possible it seems.
festerwim
+1  A: 

The only way is to have base-pom as parent of java-base-pom and flex-base-pom.

I have similar structure for my spring projects:

base-pom (basic configuration - eclipse, reports, repositories, etc)
|
+ spring-base-pom (spring definitions)
  |
  + spring-jar-base-pom (jar specific definitions)
  |
  + spring-war-base-pom (spring web and servlet dependencies)
    |
    + spring-webapp-base_pom (spring web mvc dependencies)
David Rabinowitz
Agreed. How would multiple parents work anyway - what would happen if both parents had conflicting properties?
matt b
The child overrides the parent, so settings in java-base-pom will override those of base-pom, child1 those of java-base-pom, etc. This way java-base-pom and flex-base-pom are unrelated.
David Rabinowitz
+1  A: 
Pascal Thivent
Thanks for the answer, but like I said in a comment to the other answer, this is not a structure I can use. If nothing else pops up, then pluginManagement might be the only way to do it. Drawback is then that I cannot enforce PMD on all java projects, since it is only in the pluginManagement and the project itself has to add it to his own plugin section.
festerwim
Accepting this as the answer. With the current state of Maven, using pluginManagement will be the best solution.
festerwim