markvgti
markvgti

Reputation: 4619

Maven: eliminate all but latest version of library in local repo

There's a library that I am using in my project and I have gone through many versions of it during development, so my local Maven repository contains many of the older versions of this library.

I suspect conflicts might be causing some strange issues I have been having, so I want to eliminate all but the latest version of this library from my local maven repository.

How do I do this?

If it makes any difference, I am currently using a SNAPSHOT version of this library (as recommended by its developers).

PS: deleting the entire repository is not a very practical option, as the repo is currently over 1.2G and I have a slow, capped connection.

Upvotes: 1

Views: 269

Answers (2)

Jared
Jared

Reputation: 1897

If you know the dependency coordinates you can delete them manually from the local directory. For example if this was your dependency:

<dependency>
    <groupId>org.glassfish.jersey</groupId>
    <artifactId>jersey-bom</artifactId>
    <version>2.9</version>
</dependency>

On Linux you could run:

rm -rf ~/.m2/repository/org/glassfish/jersey/jersey-bom/

On Windows you can use explorer to delete it or run:

rd /S /Q C:\Users\%username%\.m2\repository\org\glassfish\jersey\jersey-bom\

Upvotes: 2

Sairam Krish
Sairam Krish

Reputation: 11701

purge-local-repository plugin for maven could help in this situation.

Try to execute maven with following command :

mvn clean dependency:purge-local-repository -DreResolve=false -Dverbose=true -DactTransitively=false

Upvotes: 1

Related Questions