创建项目特定的Maven设置 [英] Create project-specific Maven settings
问题描述
对于所有定义了默认配置文件以及服务器和镜像的Maven项目,我都有一个通用的settings.xml
文件.如何使用特定于项目的设置来忽略默认设置?
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?
我可以指向一个特定的Maven项目的本地settings.xml
文件吗?
Can I point to a local settings.xml
file for one specific Maven project?
通过带有--settings
参数的本地设置文件也可以,但是没有永久的方法吗?
Passing a local settings file with --settings
parameter also works but isn't there a way to do this permanently?
推荐答案
我想我已经解决了这个问题,您需要一个最新的Maven版本,我使用的是Maven 3.5.2,但该功能是在Maven中引入的 3.3.1 我相信,不确定.
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.
想法是使用本地.mvn
文件夹(在父项目的文件夹中),在这里可以配置几项内容,例如JVM选项,始终使用的maven选项,等等.
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.
对于maven选项,只需在.mvn
文件夹内创建一个内容为--settings ./.mvn/local-settings.xml
的文件maven.config
,就应该如此.当然local-settings.xml
应该是有效的Maven设置文件.
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.
这是Maven项目根文件夹中的结构:
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)
这篇关于创建项目特定的Maven设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!