Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Disabling/clearing IDE file cache
Disabling/clearing IDE file cache [message #869508] Thu, 03 May 2012 13:58 Go to next message
David Vergnaud is currently offline David VergnaudFriend
Messages: 2
Registered: May 2012
Junior Member
Hi,
here's a newcomer question for which I have so far been unable to find an answer: is it possible to disable altogether the file caching in Eclipse, or force that it be automatically rebuilt upon e.g. compiling?

I have the following problem on Eclipse Indigo SR1: I have imported several Maven projects that contain many files in a multi-tiered directory structure. Some of these files are resource text files.
Now obviously these files are being cached by Eclipse, and need to be refreshed whenever a change is made outside of Eclipse. Failure to refresh them effectively leads to Eclipse running a program on the outdated content, which may lead to lots of frustration and hours of debugging. What's worse is that, apparently, refreshing the projects on the top-level (i.e. selecting "Refresh" from the contextual menu of the combined projects in the project view) doesn't go all the way into the directory structure, i.e. newly created files are not known and modified files are not updated. One needs to go to the one directory that contains files that have undergone changes and refresh it specifically, and just to be sure each file should be opened and checked lest the dreaded "File out-of-sync" message may still appear.

That is very annoying, therefore my question: can this cache be disabled altogether? I don't really care about performance in that case and don't mind if files have to be fetched from the hard drive each time they are being used in a Java program, what I want is Eclipse using the up-to-date content of my resource files rather than trying to be smart/thrifty.

Thanks for the help!

David
Re: Disabling/clearing IDE file cache [message #869527 is a reply to message #869508] Thu, 03 May 2012 14:38 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Several comments:

Eclipse doesn't maintain a full cache but only a light weight resource model of what folders and files are in the workspace. It is this model that needs refreshing in certain situations.

Whenever resources are manipulated within Eclipse, the model will be updated and all interested parties will be informed. Only when another program directly changes the filesystem without going through the resource API (like Maven does) then a refresh inside the IDE is required (you seem to be aware of this).

Now, using Maven it depends on which Maven plugin performs those file operations. Starting with version 1.0 of the m2e (formerly m2eclipse) plug-in it should actually know what refresh needs to be retriggered after each Maven run. However, m2e knows this only if a connector exists for the specific Maven plugin. But these are questions to which you'll get better advice in the m2e mailing list.

A typical bad interaction is: Maven plugin X modifies some text file under src/main/resources, user expects these to be copied to target/main/classes but since Eclipse may not know about the change it does not copy.

Another unexpected bit: in the Java build path specification the src/main/resources folder typically has a filter (created by m2e) preventing that Eclipse will copy these resources, because m2e assumes that any such copying be performed by the corresponding Maven plug-in.

As to disabling caching of the resource model: to the best of my knowledge it's not possible, and if it could be disabled it would probably make incremental compilation unusable.

On top of the above you might actually be seeing one or two bugs here:
- m2e missing to perform a refresh which it actually should perform
- if an explicit refresh doesn't descend into some sub folders this might be an Eclipse bug. It would be interesting if you have reproducable steps for this part.

best,
Stephan




Re: Disabling/clearing IDE file cache [message #869563 is a reply to message #869527] Thu, 03 May 2012 15:43 Go to previous messageGo to next message
David Vergnaud is currently offline David VergnaudFriend
Messages: 2
Registered: May 2012
Junior Member
Thanks a lot for the reply.

I must admit that some parts of your email are somewhat obscure to me as I am not yet very proficient with the whole Maven process. However, here are a few comments from my part that may help find out where the problem actually comes from:

- I'm only talking about modifications that happen completely outside of Eclipse, not files copied/modified by Maven. This includes files copied/created within the Windows Explorer, files modified in an external text editor, etc.
- Not only the presence of these files, but also their content is being cached and needs refreshing. For instance, if I add a line to a text file in an external editor then this line will still not be read when I run my Java program, until that file is explicitly refreshed in Eclipse (or at least the resource directory that contains it, i.e. simply refreshing the project isn't enough).

I haven't tried actually building the Maven project and checking the contents of the resulting jar file to see whether the resources are up-to-date or not.

It might be worth noting also that these projects are managed by Git. I seldom use the Git GUI within Eclipse though, I rather use the CLI and refresh in Eclipse after switching branches etc. I haven't had any problem with the refreshing within that process, yet it doesn't have much impact on the text resources.

I will try to build an environment where this problem may be reproduced, don't know when I'll have time for that though.

D
Re: Disabling/clearing IDE file cache [message #869689 is a reply to message #869563] Thu, 03 May 2012 20:38 Go to previous message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
The "resource" files have to be on the runtime classpath in order for your Java application to access them at runtime. Eclipse accomplishes this by copying non-java files to the output folder (bin unless you changed it) when it realizes that the file has changed. This is likely what you are seeing with respect to resource files having old data in them.

As Stephen mentioned, Eclipse refreshes traverse down the directory hierarchy to refresh everything below. There shouldn't be any external changes that don't get picked up when you perform a project refresh from the project root.
Previous Topic:Maven project in Eclipse Helios doesn't show error icon/marks
Next Topic:Adapter for the package explorer
Goto Forum:
  


Current Time: Thu Mar 28 14:47:30 GMT 2024

Powered by FUDForum. Page generated in 0.02288 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top