将Maven的本地存储库位置指定为CLI参数 [英] Specifying Maven's local repository location as a CLI parameter
问题描述
是否可以将本地Maven存储库的位置设置为Maven命令行上的参数?
Is it possible to set the location of the local Maven repository as argument on the Maven command line?
问题是我没有使用~/.m2/repository
中的默认值.但是,我签出了一些使用-s settings.xml
用其自己的设置构建的项目.该settings.xml未指定我的本地存储库,因此Maven再次使用~/.m2/repository
...我想使用非默认本地存储库位置,而不必在项目的settings.xml中添加<localRepository>
元素
The thing is that I don't use the default one in ~/.m2/repository
. However I checked out some project that is being built with its own settings with -s settings.xml
. That settings.xml doesn't specify my local repository, so Maven uses uses ~/.m2/repository
again... I would like to use a non-default local repository location without having to add a <localRepository>
element in the project's settings.xml
我尝试过
-
-DlocalRepository="..."
-
$mvn invoker:run -s settings.xml clean install -DskipTests -DlocalRepositoryPath=
-
-Dsettings.localRepository
-DlocalRepository="..."
$mvn invoker:run -s settings.xml clean install -DskipTests -DlocalRepositoryPath=
-Dsettings.localRepository
但是这些选项都不起作用.
but none of these options works.
所以我认为我必须决定是否要修改第三方settings.xml或将本地存储库移至~
So I think I have to decide whether I will be modifying a third party settings.xml or move my local repo to ~
推荐答案
使用maven属性maven.repo.local
:
mvn -Dmaven.repo.local=$HOME/.my/other/repository clean install
无需修改settings.xml.
No modifications to settings.xml are necessary.
这篇关于将Maven的本地存储库位置指定为CLI参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!