Is there a way to disable the local maven repository?

ぃ、小莉子 提交于 2019-12-10 11:17:49

问题


This may sound crazy but we have our developers all working on the same Linux machine, this machine also has nexus installed as our maven repo. Effectively everyone ends up with artefacts in their ~/.m2/ folder which are also duplicated in the nexus server.

Is it possible to simply tell maven to only look at the artefacts in nexus?

I have for the moment set the property <localRepository>/path/to/global/repo</localRepository> in our global maven config, but unsure if this could cause a problem if two users are grabbing the same file at the same time.

We do this because the company won't buy us powerful workstations so we all ssh to our development server.


回答1:


I wouldn't want to point my local repo to the nexus datastore, because then installs would update the repository datastore behind nexus' back.

However you could set up a single "machine" local repo separate to the nexus datastore,
and then for each user change the ~/.m2/repository directory to be a symlink pointing to the "machine" local repo.

At least then you'll only have 2 copies of the repo.

Concurrent installs and downloads, are still likely to clobber one another, but this can be fixed with an annoying redo.

Update:

There is a new solution available.

Installation of the TEAM (Takari Extensions for Apache Maven) extensions, provides a thread-safe local repository and an improved algorithm for multi module builds.

See http://takari.io/book/30-team-maven.html#concurrent-safe-local-repository




回答2:


I'm not sure if this directly answers your concern, but it looks like what you're doing is correct.

From http://maven.apache.org/settings.html

localRepository: This value is the path of this build system's local repository. The default value is ${user.home}/.m2/repository. This element is especially useful for a main build server allowing all logged-in users to build from a common local repository.




回答3:


Use the --offline option at command line.



来源:https://stackoverflow.com/questions/5238769/is-there-a-way-to-disable-the-local-maven-repository

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