You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Nils Breunese (Jira)" <ji...@apache.org> on 2023/04/11 07:49:00 UTC

[jira] [Comment Edited] (MNG-5659) Project specific settings.xml

    [ https://issues.apache.org/jira/browse/MNG-5659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17710790#comment-17710790 ] 

Nils Breunese edited comment on MNG-5659 at 4/11/23 7:48 AM:
-------------------------------------------------------------

I have previously worked in an environment where everyone was supposed to maintain a global {{\~/.m2/settings.xml}}, but there were always issues with people not having the file, not having the right contents in the file, or the global settings interfering with the build of some third-party project. We like to keep the Maven settings for each project contained in the project repo, so any project will always build right after cloning it, without depending on a global {{~/.m2/settings.xml}} file.

Our in-company project generator generates a {{.mvn/settings.xml}} file with the correct default settings for in-company projects and a {{.mvn/maven.config}} file which includes {{--settings=.mvn/settings.xml}} and this has been working great for us. This lets people add more project-specific settings when they need to, for instance for deployment settings like a username if the project is a library. And nobody needs to have or maintain a global {{~/.m2/settings.xml}} themselves at all.

The only downside of this setup is what I mentioned before: it won't let you run Maven from another directory than the root directory of the project, because of the relative path in {{--settings=.mvn/settings.xml}}. If we could somehow reference a file in the project relative to the project base directory that would no longer be an issue.


was (Author: breun):
I have previously worked in an environment where everyone was supposed to maintain a global {{~/.m2/settings.xml}}, but there were always issues with people not having the file, not having the right contents in the file, or the global settings interfering with the build of some third-party project. We like to keep the Maven settings for each project contained in the project repo, so any project will always build right after cloning it, without depending on a global {{~/.m2/settings.xml}} file.

Our in-company project generator generates a {{.mvn/settings.xml}} file with the correct default settings for in-company projects and a {{.mvn/maven.config}} file which includes {{--settings=.mvn/settings.xml}} and this has been working great for us. This lets people add more project-specific settings when they need to, for instance for deployment settings like a username if the project is a library. And nobody needs to have or maintain a global {{~/.m2/settings.xml}} themselves at all.

The only downside of this setup is what I mentioned before: it won't let you run Maven from another directory than the root directory of the project, because of the relative path in {{--settings=.mvn/settings.xml}}. If we could somehow reference a file in the project relative to the project base directory that would no longer be an issue.

> Project specific settings.xml
> -----------------------------
>
>                 Key: MNG-5659
>                 URL: https://issues.apache.org/jira/browse/MNG-5659
>             Project: Maven
>          Issue Type: New Feature
>          Components: FDPFC
>            Reporter: Joachim Van der Auwera
>            Priority: Major
>             Fix For: Issues to be reviewed for 4.x
>
>         Attachments: mvn.patch
>
>
> It would be useful to have a settings.xml file next to the project pom that could contain project specific settings.  For example, when switching between projects it is sometimes necessary to also change the location of the local repository, or use a different set of repositories and/or mirror settings for each project.
> If a settings.xml file could be included with a project checkout, then the repositories needed for the build could be included (instead of putting them in the pom) along with any other project specific settings.
> The tricky part is intelligently handling multi-module projects.  For a multi-module project I don't want to include a separate settings.xml file for each directory.  So Maven could recursively check each parent directory until it either (1) finds a settings.xml, (2) finds a directory with no pom.xml, or (3) finds the root directory.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)