将 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 中的元素
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
但这些选项都不起作用.
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 ~
推荐答案
use maven property maven.repo.local
:
use maven property maven.repo.local
:
mvn -Dmaven.repo.local=$HOME/.my/other/repository 全新安装
无需修改 settings.xml
.
这篇关于将 Maven 的本地存储库位置指定为 CLI 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!