Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split my maven pom into different files

I do not want to change my project/module structure. Its just my pom file is getting large and complex (due to lots of dependencies) and want to separate it into easily navigable sub files ... is this easy ?

I am looking for something similar to the import resource available for spring context definition files.

like image 360
NimChimpsky Avatar asked May 12 '13 09:05

NimChimpsky


People also ask

Can a Maven project have multiple pom files?

Yes you can use Maven Profiles to manage this. Obviously you can tweak this approach to suit your needs however works best.

What is aggregator pom?

To simplify building multiple projects, you can optionally create an aggregate Maven project. This consists of a single POM file (the aggregate POM), usually in the parent directory of the individual projects. The POM file specifies which sub-projects (or modules) to build and builds them in the specified order.

Is there a POM file for every project?

It should be noted that there should be a single POM file for each project. All POM files require the project element and three mandatory fields: groupId, artifactId, version. Projects notation in repository is groupId:artifactId:version.

Where do pom files go?

The pom. xml is placed in the projects root-folder.


1 Answers

You have a couple of options for breaking up your pom files:

  • Create a parent pom to move things like the plugins, pluginManagment and dependencyManagement sections into. This separates these sections out from the files where you are actually defining what dependencies a module will use. You can find some good examples here.
  • Use dependency management imports to modularise your dependencyManagment section, you can see an example here. This allows you to do things like separate the dependency management of third party dependencies from your own projects dependencies.
like image 158
Leesrus Avatar answered Sep 20 '22 22:09

Leesrus