2

Our repository has several projects which have very large pom.xml files with many dependencies and plugin configurations in each.

Does there exist any way of specifying our pom.xml outside of the standard xml on the Maven website?

The closest solution I know of is to abuse inheritance and separate dependencies and plugin configuration into parent projects, but this can only take us so far.

When the pom file splitting for Maven 3 is released it will relieve some of the pain, but my preferred solution would be a scripting language which could do the following:

  • specify dependencies as a single line instead of 5/6,
  • allow for simple reuse of plugin configurations between projects, and
  • be easily usable by new developers
Community
  • 1
  • 1
idle
  • 1,117
  • 9
  • 17
  • 1
    Not really an answer, but have you considered using Gradle instead? – JB Nizet Jul 09 '12 at 21:57
  • 1
    It's not an abuse, it's what pom inheritance was meant for. – Nicola Musatti Jul 09 '12 at 22:12
  • From a quick reading Gradle looks really good, and I will look at using it for the next project that I set up, but this current project is too reliant on specific Maven plugins to be transitioned without a lot of pain. – idle Jul 09 '12 at 22:13
  • Sadly, polyglot maven seems to have gone away. It had such promise in allowing you to use other languages (ie groovy, jython) to specify your .pom file, and then it would convert to xml. – Matt Jul 10 '12 at 03:01

2 Answers2

1

The pom inheritance is not the only method. Did you already try to use a POM like a "bill of materials" (BOM) and them importing it with the scope import?

You can find more information about this in the Importing Dependencies section of this page. It will allow a simple reuse of plugin configuration between projects.

Benoit
  • 1,995
  • 1
  • 13
  • 18
  • From the examples I have been able to find, it looks like this only allows for dependencyManagement to be separated. In the final pom files I would still need to list all of the dependency artifacts (if not the version numbers). Have you successfully pulled plugin configurations out using this method? – idle Jul 09 '12 at 22:47
1

I've found that one of the simplest way to simplify pom-files is to split the compilation phase from the deployment phase instead of e.g. using a lot of profiles.

In other words, you have a project for compiling each module in the simplest possible way. Generate a jar or a war file with the default name!

Then you have a project for each individual "deployment" - i.e. deploying to the test server - with all the various configuration snippets. Then "mvn clean package" redeploys.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347
  • The problem with our project is that almost all of the pom is dedicated to the compilation phase. There are 92 dependencies and 10 plugin configurations in one of our projects. Most of the plugins are tasks like generating JPA metamodels or compiling GWT source. For the sake of separation of concerns I would like to, for instance, pull the Hibernate/JPA dependencies and the JPA metamodel generation out into a separate bite-sized unit. – idle Jul 09 '12 at 22:52