Search code examples
javamaven-3artifactory

Issues after clearing local maven repository


I use the following version of maven (v3.5.4) and I see that I have recently removed the maven local repository (~/.m2/repository) to save some space for an emergency situation thinking that this local copy will also be stored some where in my repository manager (JFrog Artifactory).

$ mvn --version
Apache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-18T00:03:14+05:30)
Maven home: /opt/maven
Java version: 1.8.0_171, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.3.2.el7.x86_64", arch: "amd64", family: 

But after removing the local repository, I have increased the server space and then started compiling few java projects it started failing with dependency errors.

Looking for Clarification on below points?

  • Does this local repository gets stored in the repository manager (JFrog Artifactory) server too? If this doesn't get stored, is there a way to do it so that we will not face this issue again?
  • Do we need to take any precaution before removing the local maven repository (~/.m2/repository)?

Solution

  • The local repository is mainly used as a cache to the remote repository. It will contain any artefact you downloaded from the remote repo as well as the ones you uploaded as part of your builds.

    If you do a mvn install the artefact will only go into the local repo; for mvn deploy it will go to the local repo and to the remote one.

    So "Does this local repository gets stored in artifactory": not automatically. You need to deploy artefacts.

    "Do we need to take any precaution before removing the local maven repository": no. But you will permanently remove all artefacts that are only stored locally. This normally is not a problem because you would deploy artefacts that you want to keep anyhow.