Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does Project>Clean do in Eclipse?

 
Ajay Dhar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does Project>Clean do in Eclipse? Sometimes I have to do this to remove the compile time errors from the screen and other times I have to do this to get my code running without runtime errors. I'm still not sure exactly what this does though. Any help is appreciated.

Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34179
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It removes the .class files and recompiles the project. Basically, it forces a rebuild.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:It removes the .class files and recompiles the project. Basically, it forces a rebuild.


Almost. It removes the products, but the rebuild part is only automatic if you have automatic build turned on. Which is the default, but on occasion I have had to turn it off.
 
Ajay Dhar
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the replies. This is a basic question but what does it mean to build the project?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajay Dhar wrote:Thanks for the replies. This is a basic question but what does it mean to build the project?

For a Java project, it means compiling all Java classes.

From the documentation:

Java builder

The Java builder builds Java programs using a compiler that implements the Java Language Specification. The Java builder can build programs incrementally as individual Java files are saved.

Problems detected by the compiler are classified as either warnings or errors. The existence of a warning does not affect the execution of the program; the code executes as if it were written correctly. Compile-time errors (as specified by the Java Language Specification) are always reported as errors by the Java compiler. For some other types of problems you can, however, specify if you want the Java compiler to report them as warnings, errors or to ignore them. To change the default settings, use the Goto the Java compiler preference page Java > Compiler > Errors/Warnings preference page.

The Java compiler can create CLASS files even in presence of compilation errors. However, in the case of serious errors (for example, references to inconsistent binaries, most likely related to an invalid build path), the Java builder does not produce any CLASS files.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To amplify on this a bit: If you look at your Project Properties dialog, you'll see a topic named "Builders". This is where the Builders for the project are managed. In a Java project, that will include the Java Builder. I have projects that also include a Maven Builder. In fact, you can design and incorporate custom builders into Eclipse as plug-ins, but that's more work than most of us want to do.

The builders are responsible for ensuring that whatever resources they manage are properly built. The Java builder watches over Java source folders and ensures that classes are recompiled as needed.

As I said earlier, building is normally automatic, although you can switch to manual operation of the builders if the situation requires it.

Builders handle the everyday low-level aspects of working with a project and its products, but they're not intended to do everything. Which is why Eclipse also supports specialized builds using Maven and Ant.
 
Scott Izu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would help to know what Project->Clean actually does. Does it call 'mvn clean'?

Also, what does the build step do? Does it call 'mvn compile'?

The reason I am asking is I noticed that the build automatically will not filter my properties file. If I do 'mvn compile' the MAVEN_VERSION=${project.version} from the properties file in src/main/resources is copied to the target/class directory with the ${project.version} flag appropriately substituted. However, from Project->Clean, this does not happen.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Eclipse project clean doesn't run Maven. A Maven Clean is different.

Mostly Eclipse Clean is good for when Eclipse gets a scrambled idea of the state of the project.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic