Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create project-specific Maven settings

Tags:

maven

I have a general settings.xml file for all Maven projects where a default profile and servers and mirrors are defined. How can I use project-specific settings to ignore the default?

Can I point to a local settings.xml file for one specific Maven project?

Passing a local settings file with --settings parameter also works but isn't there a way to do this permanently?

like image 432
Vincent Avatar asked Apr 01 '17 12:04

Vincent


People also ask

How do I change settings in Maven?

Navigate to path {M2_HOME}\conf\ where M2_HOME is maven installation folder. Open file settings. xml in edit mode in some text editor. Update the desired path in value of this tag.

What is Mvn settings xml?

A Maven settings. xml file defines values that configure Maven execution in various ways. Most commonly, it is used to define a local repository location, alternate remote repository servers, and authentication information for private repositories.

Where can I find settings xml Maven?

The Maven settings file, settings. xml , is usually kept in the . m2 directory inside your home directory.


1 Answers

I think I have a solution to that problem, you need a recent maven version, I'm using maven 3.5.2 but the feature was introduced in maven 3.3.1 I believe, not sure.

The idea is to use the local .mvn folder (in the parent project's folder) where it is possible to configure several things like JVM options, maven options that are always used, etc.

For maven options just create a file maven.config inside the .mvn folder with the content --settings ./.mvn/local-settings.xml, and that should be about it. Of course the local-settings.xml should be a valid maven settings file.

Here's the structure within the maven project root folder :

parent-mvn-project    ├── .mvn    │   ├── local-settings.xml    │   └── maven.config    ├── submodule-A (if any submodules)    └── submodule-B (if any submodules) 
like image 139
Brice Avatar answered Oct 31 '22 00:10

Brice