Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I remove a cached local artifact that maven fetched?

After running maven commands, the jboss artifact sits cached in my local repo /.m2. However, it's the wrong copy, and we have updated our artifactory on the local server. How do I remove this cached copy? (other than manually deleting the jboss folder from the /.m2/repository/org folder). Is there a maven command to do so? Also, I was wondering how exactly the local repository is structured, is it according to groupId, artifactId, version (GAV) in any way?

like image 744
Siddhartha Avatar asked Jul 09 '13 17:07

Siddhartha


People also ask

How do I delete an artifact in Maven?

If you want to explicitly remove a single artifact from the cache, use purge-local-repository with the manualInclude parameter. For example, from the command line: mvn dependency:purge-local-repository -DmanualInclude="groupId:artifactId, ..."

How do I clear my local repository cache?

Local Maven Repository location To clear/delete your local maven repository cache, simply delete the . m2/repository folder. The local repository path can also be configured in Maven setting. xml (either the global or the user one).

Where is Maven local cache?

The first place that Maven looks for artifacts is in the local repository, which is the local cache where Maven stores all of the artifacts it has downloaded or found elsewhere. The default location of the local repository is the . m2/repository/ directory under the user's home directory.

Which command can you use to clear up old artifacts in a Maven project?

When running mvn install on a local multi module project it builds and install the projects artifacts into the local repo. mvn clean seems to clean up my project specific target directories.


1 Answers

Snapshot artifacts can be force-updated by using -U option with mvn when building a project with the dependency. Maven will take the newest snapshot available of the specified version. You have to deploy the fixed snapshot artifact to the repository before. The newest snapshot is determined by the timestamp attached to the file name of the jar.

However, release versions are not updated. Once a release artifact has been downloaded and verified, you must remove it manually if you replaced it on a remote repository. Generally, you should never replace release version artifacts. Rather you should always release a new version (and possibly delete the erroneous version from the repository) and change the pom.xml files of projects which use this artifact.

For the structure of the local/remote repository, see links below.

References:

  • Force maven update
  • maven artifact repository directory structure specs
  • Maven repository layout
like image 154
nif Avatar answered Sep 20 '22 15:09

nif