Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cleaning Maven m2e .cache directory

Tags:

maven

m2e

My Maven installation (Windows 7 64-bit) has a .cache directory that is almost 3.5GB! It contains only a m2e directory. (I'm running Eclipse 4.3M7 with m2e.) Surely all the things inside aren't needed at present, and moreover I don't even know what this stuff is! I could find no Maven documentation of a .cache directory online.

So what are the .m2/repository/.cache and .m2/repository/.cache/m2e directories? Why do they have so much stuff from years ago? How do I dispose of all the stuff that's not needed anymore?

like image 310
Garret Wilson Avatar asked May 08 '13 13:05

Garret Wilson


People also ask

How to clean the Maven cache?

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).

How to clean Maven cache in Eclipse?

We can do a setting in the eclipse ide to disable . cache folder to increase. Disable this option and you will get rid of . cache problem!

Where is Maven cache stored?

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.


3 Answers

In contrast to the other answers, make sure to keep .m2/*.xml (your settings) and .m2/repository (not strictly necessary to keep, but Maven will have to download half the Internet again).

Now, as for that .cache folder: if you open Eclipse, M2Eclipse will sometimes run a job akin to "Downloading repository indexes". These indexes allow you to quickly find an artifact using M2E's "Add dependency" wizard if you only know (part of) its artifact id. It needs to put the downloaded index files somewhere, and according to http://dev.eclipse.org/mhonarc/lists/m2e-users/msg02486.html the .cache folder is where they go:

Also note that m2e keeps at least three copies of each repository index. The original .gz files downloaded from remote repositories. A shared lucene instance used to optimize time spent processing gz files. And per-workspace lucene indexes. The first two are stored under local repository .cache/m2e directory, the last one is per-workspace.

The Lucene stuff they're talking about are extra optimized search databases, this makes it faster for M2E to search a given artifact if you only enter a partial artifact id or group id.

If I read http://dev.eclipse.org/mhonarc/lists/m2e-users/msg01708.html correctly then it should be safe to remove them:

m2e caches lucene index in two places. Per-workspace indexes are stored under .metadata/.plugins/org.eclipse.m2e.core/nexus and there is also global cache in ~/.m2/repository/.cache/m2e/${m2e.version}.

Try cleaning the caches and see if the problem goes away.

Keep in mind though that M2E will notice the missing folder the next time you open Eclipse, so be prepared to wait while it downloads all repository indexes again!

like image 168
JBert Avatar answered Sep 23 '22 05:09

JBert


We can do a setting in the eclipse ide to disable .cache folder to increase.

Window->Preferences->Maven->Download repository index updates on startup

Disable this option and you will get rid of .cache problem!

like image 25
dragonfly Avatar answered Sep 22 '22 05:09

dragonfly


The m2e directory is the Eclipse Maven plugin's cache, not Maven's.

like image 26
Georgemc Avatar answered Sep 21 '22 05:09

Georgemc