views:

250

answers:

3

Hi - I've asked a similar question in which part of this was addressed, but I'd like to expand in more detail.

When configuring maven to look at internal repositories, is it best to put that information in the project pom or in a user's settings.xml? An explanation on why would be really helpful here.

thanks,

Jeff

A: 

We use the user's settings.xml and include info in the README about what possible other repos may be needed.

In theory a given group-artifact-version is the same no matter which repo it comes from. It works pretty well for us. If you find yourself with two different assets that have the same group-artifact-version identifier, then that indicates you're doing something really bad.

caskey
+2  A: 

I encourage you to put the repository definition in the POM, this way any developer just grab a copy of the code and run Maven to get it compiled, without having to change things in his settings file.

I find the setting.xml file useful just for hacking Maven's behaviour in special situations, for example when one repository is not accessible due to a firewall and you need to use a mirror. But that's my personal opinion. Maven documentation gives you more freedom:

The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml, but should not be bundled to any specific project, or distributed to an audience. These include values such as the local repository location, alternate remote repository servers, and authentication information.

If you have a local repository which is used in every single project you may add that at the settings.xml, just be sure that configuration is well documented, in my current project it's not and new developers struggle at the beginning when they try to compile something.

victor hugo
+3  A: 

You should always try to make the maven project so that it compiles from a clean checkout from source control in your local environment; without a settings.xml. In my opinion this means that you place any overrides to sensible default values in the user's settings.xml file. But the pom should contain sensible values that will work for everyone.

krosenvold
Thanks! I'd like to keep my repository information in a parent pom, but I'm a little hesitant to use a relative path to the parent pom since that would require that the user has the parent project checked out too. But, if I don't a use relative path, then each project's POM must have the repo information so it can at least find the parent POM. Have you dealt with this before?
Jeff Storey
@Jeff Just be sure the parent POM has packaging defined as "pom", this way it will install in the repo as a POM definition
victor hugo