Home » DevOps » Rebuild a Maven repository in 3 steps

About Alex Theedom

Alex Theedom
Alex Theedom is a Senior Java Developer and has recently played a pivotal role in the architectural design and development of a microservice based, custom built lottery and instant win game platform. Alex has experience of Java web application development in a diverse range of fields including finance, e-learning, lottery and software development. He is the co-author of Professional Java EE Design Patterns and many articles.

Rebuild a Maven repository in 3 steps

In this blog post, I will show a way to very quickly rebuild a Maven repository without having to set up a project.

Step 1: Delete all artifacts

Cleanse your Maven repository by deleting the contents of the /.m2/repository directory. Ensure to delete the settings.xml file if so required.

Step 2: Create a dummy POM file

Create the simplest POM file that defines only groupId, artifactId, and version. This is just a basic dummy POM file that you will delete later. Maven needs it to run the purging local repository dependencies command.

1
2
3
4
5
6
7
8
     
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>most-basic-projet</artifactId>
    <version>0.0.0-SNAPSHOT</version>
 
</project>

Step 3: Repopulate the local Maven repository

Run the purge repository Maven command:

mvn dependency:purge-local-repository

The objective of this Maven goal is to remove artifacts from your local maven repository. It will delete and re-resolve artifacts.

Finally, delete the POM file. Now you have a nice clean Maven repo with freshly repopulate artifacts.

Published on Java Code Geeks with permission by Alex Theedom, partner at our JCG program. See the original article here: Rebuild a Maven repository in 3 steps

Opinions expressed by Java Code Geeks contributors are their own.

(0 rating, 0 votes)
You need to be a registered member to rate this.
1 Comment Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments