How to clear Maven cache

Issue

My Maven cache is growing and I need to clear it out. How can I delete/clear my Maven cache?

Environment

Resolution

Local Maven Repository location

When a Maven build is executed, Maven automatically downloads all the dependency jars into the local repository.
Usually this folder is named .m2/repository.

  • To clear/delete your local maven repository cache, simply delete the .m2/repository folder.

  • You can find the default Local Maven Repository for each operating system below:

Operating SystemLocal Maven Repository
Linux/home/<User_Name>/.m2
MacOS/Users/<User_name>/.m2
WindowsC:\Users\<User_Name>\.m2
  • Additionally, if you are using the Maven Integration plugin you can find the Local Maven Repository inside the Jenkins UI by going to Manage Jenkins > Configure System > Local Maven Repository under Maven Project Configuration

How_to_clean_up_Maven_cache/local_maven_repository.png

  • The local repository path can also be configured in Maven setting.xml (either the global or the user one). See Maven documentation for more details.

  • Finally the local repository path can be overridden by the Maven Pipeline plugin using the mavenLocalRepo parameter.

Have more questions?

0 Comments

Please sign in to leave a comment.