Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
223 views
in Technique[技术] by (71.8m points)

Specifying Maven's local repository location as a CLI parameter

Is it possible to set the location of the local Maven repository as argument on the Maven command line?

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

I've tried

  • -DlocalRepository="..."
  • $mvn invoker:run -s settings.xml clean install -DskipTests -DlocalRepositoryPath=
  • -Dsettings.localRepository

but none of these options works.

So I think I have to decide whether I will be modifying a third party settings.xml or move my local repo to ~

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

use maven property maven.repo.local:

mvn -Dmaven.repo.local=$HOME/.my/other/repository clean install

No modifications to settings.xml are necessary.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...