Maven plugin creates local maven repository - how to clean up SNAPSHOTS

I am using the maven plugin to publish locally built SNAPSHOT artifacts into a Nexus managed SNAPSHOT respository. We have noticed that when we run the build locally, gradle/maven plugin creates a local .m2 repository and downloads all the SNAPSHOTS to this.

My concern is that over time this repository will grow and eventually take up a lot of space on the local machine.

This is also happening on our CI server where space is at a premium.

My question is :

Is there a way to configure gradle or the maven plugin to manage this local repository to remove old SNAPSHOTS ???

Gradle maintains its own dependency cache under ‘~/.gradle’, and doesn’t download any snapshots into the local Maven repository. There isn’t currently a built-in way to purge Gradle’s dependency cache.


Thanks for the reply.

I know gradle has it’s own local repository in ~/.gradle, but the maven plugin used by gradle has it’s own local repository in a ~/.m2 folder. This is the folder I’m concerned about.

Gradle’s Maven plugin shouldn’t download anything into .m2. It just publishes the artifacts built by Gradle.


I’m not sure the maven plugin is downloading anything into .m2 it seems to store the artifact it is trying to upload in the .m2 repository when it executes the uploadArchives task.

This is the uploadArchives task for the maven plugin that creates the entry in the .m2 repository. I’m using gradle 1.11

Would you be able to test this and confirm my observations? e.g.

uploadArchives {

repositories {

mavenDeployer {

repository(url: nexusServer+’/nexus/content/repositories/releases/’) {

authentication(userName: nexusUser, password: nexusPassword);


snapshotRepository(url: nexusServer+’/nexus/content/repositories/snapshots/’) {

authentication(userName: nexusUser, password: nexusPassword);


pom.groupId = “com.mycompany”


} }

Hey Paul,
yes I can conform this. Currently uploadArchives leaks the artifacts into the ~/.m2 repository. This is a known issue (see



Hi René

Ok thanks, good to see it’s been reported. I’ll follow the issue.

cheers Paul