On Mon, Apr 2, 2012 at 7:55 AM, Gillet Thomas (2) < [email protected]> wrote:
> Seems my first post was really not clear. Trying to make it simpler: > > Basically, my main concern is to be able to package separately parts of > the POM: > - plugin configuration and/or dependencies (previously the "type POM") > - distribution management information (previously the "deployment POM") > Yes, this is a clear and obvious thing to want to do. You are not crazy for wanting to be able to do this. But you can't do it in Maven (to the best of my knowledge). You can get close though. You can make a grandparent pom.xml with non-project but company-specific information in it (company name, maybe the location of your Nexus, various domain- and project-independent properties). Ideally this pom.xml changes rarely, if ever. Do not be tempted to load it up with plugin version specifiers and dependency information; this is really just common boilerplate, and that's it. You can then make several child poms beneath it that inherit from it that contain various plugin or pluginManagement stanzas--maybe one, for example, combines together plugins that are useful for JPA development (or whatever) and you don't want to keep specifying those plugins over and over and over again for your various JPA projects. Just an example. You can repeat this as many levels deep as you want. Finally at the end of the inheritance stack here you would have a project pom.xml that would inherit from one of these "type" poms. This would allow you to pick and choose which effective combinations of plugins and pluginManagement (and/or dependencies, etc.) you might want for that project (maybe one project needs the But there will come a time when you discover you want a mix of several of these pom.xmls. Maven has no way to import sections from another pom.xml (sure wish it did, or that it could permit this sort of thing via magic XML namespaces or xinclude or something; I'm no W3C XML wonk so I don't know fully what's possible here). Nor does it offer a way to have a project extend from several poms at once. For dependencies (and this one took me probably about a year before I fully got it), recall that dependencies are transient, so in this one case you can actually declare a dependency on an artifact of <type>pom</type>. Think about that for a moment. If *that* artifact (a pom file) in turn declares a pile of dependencies, then THOSE dependencies will be pulled in transitively. This is a nice hack--and it is a hack--that allows you to at *least* group dependencies into bundles that you can suck in fairly conveniently, and, to your point, maintain separately (something that I think maybe got lost in your original request). There is no equivalent hack for plugins to my knowledge. I've usually done a moderately deep inheritance stack and then pretty much just deal with the duplicate code after that. I hope this helps you out. Just another user's data point; always interested to hear better approaches. Best, Laird -- http://about.me/lairdnelson
