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

故事扮演 提交于 2019-12-17 10:25:41

问题


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?


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/9123004/maven-is-it-possible-to-override-location-of-local-repository-via-the-use-of-co

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!