133

What does Eclipse's Project → Clean... tool actually do?

Pops
  • 30,199
  • 37
  • 136
  • 151
Eugene
  • 59,186
  • 91
  • 226
  • 333

4 Answers4

133

It removes whatever already-compiled files are in your project so that you can do a complete fresh rebuild.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
85

Its function depends on the builders that you have in your project (they can choose to interpret clean command however they like) and whether you have auto-build turned on. If auto-build is on, invoking clean is equivalent of a clean build. First artifacts are removed, then a full build is invoked. If auto-build is off, clean will remove the artifacts and stop. You can then invoke build manually later.

Konstantin Komissarchik
  • 28,879
  • 6
  • 61
  • 61
12

There's another problem at work here. The Clean functionality of Eclipse is broken. If you delete files outside of Eclipse it will not pick up on the fact that the files are now missing, and you'll get build errors until you delete the files manually. Even then, that will not necessarily work either, especially if there are a lot of files missing. This happens to me rather often when I check out a branch of code that has had a lot of changes since the last time I built it. In that case, the only recourse I've found is to start a brand new workspace and reload the project from scratch.

ChopperCharles
  • 747
  • 2
  • 9
  • 19
  • 7
    Have you tried refreshing the project? Clean does not check whether the source files exit, it just deletes the compiled classes. In the navigator view right click on your project (or appropriate folder) and select Refresh from the context menu. This will remove any files that have been deleted and add any new ones that are not yet listed in your project. – SteveS May 04 '12 at 12:34
  • 1
    Pressing F5 will also work for refreshing resources, but you must be sure that you have actually selected the files you want to reload from the local file system--in other words, just clicking inside Package Explorer and pressing F5 won't do anything. After doing a refresh of a lot of files, I usually do a Project > Clean. – hotshot309 Jul 27 '12 at 13:59
  • @SteveS mentions that refreshing files in Eclipse will add new files and remove old ones--it will update any changed (or added or removed) files with the file system. If files were changed outside of Eclipse while your workspace was open in Eclipse, Eclipse won't detect the changes and reload the files on its own. It can be maddening when you're compiling from a cached, older copy of files you've changed outside of Eclipse (like image files) but don't see the changes when running your app, if you don't realize that a Refresh is necessary. – hotshot309 Jul 27 '12 at 14:07
-5

I also faced the same issue with Eclipse when I ran the clean build with Maven, but there is a simple solution for this issue. We just need to run Maven update and then build or direct run the application. I hope it will solve the problem.

Andrew Myers
  • 2,754
  • 5
  • 32
  • 40
Randhir
  • 137
  • 2
  • 6