Anthony Kong
Anthony Kong

Reputation: 40624

maven: Is it possible to override location of local repository via the use of command line option or env variable?

Currently we specify the location of local repository in the settings.xml. Is it possible to override this setting via command line or env variable, such that I can use an alternative location sometimes?

Upvotes: 86

Views: 73567

Answers (2)

Michael
Michael

Reputation: 6499

Use the localRepository setting in your settings.xml file. Example:

<settings>
  <localRepository>/repo</localRepository>
  ...
</settings>

See here for more info.

You can also set the repository via the command line using "-Dmaven.repo.local=" such as:

mvn -U clean install -Dmaven.repo.local=C:\tmp

Upvotes: 19

Raghuram
Raghuram

Reputation: 52635

You would need to specify the maven.repo.local parameter to do this.

mvn package -Dmaven.repo.local=/alternate/repo/location

Here is a related SO question.

Upvotes: 149

Related Questions