Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

use maven property maven.repo.local:

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

No modifications to settings.xml are necessary.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...