Specifying Maven's local repository location as a CLI parameter

Viewed 103735

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 ~

3 Answers
Related