Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Eclipse's "clean project" and Maven's "mvn clean" in m2e

Tags:

I use M2e + Eclipse + Maven and I would like to know what the difference is between:

  • running "mvn clean" in a terminal and
  • running "clean project" from Eclipse?

Can anyone please advise?

like image 430
balteo Avatar asked Jan 13 '12 15:01

balteo


People also ask

What is mvn Eclipse clean?

First, it deletes previously generated Eclipse files (like . project and . classpath and . settings ) and then generates new ones, thus, effectively updating them. It may be useful if you introduced some changes in pom.

What does Eclipse clean project do?

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

What does mvn clean compile do?

mvn clean: Cleans the project and removes all files generated by the previous build. mvn compile: Compiles source code of the project. mvn test-compile: Compiles the test source code.

What does mvn clean mean?

mvn clean. Clears the target directory into which Maven normally builds your project. mvn package. Builds the project and packages the resulting JAR file into the target directory.


2 Answers

From some quick tests, it seems that Eclipse's clean project is only clearing out the folders that are set as output folder in the project's preferences, whereas maven's clean is deleting the /target folder completely.

like image 118
Giorgos Dimtsas Avatar answered Oct 05 '22 11:10

Giorgos Dimtsas


I have the following entry in my pom.xml file:

<plugin> <artifactId>maven-clean-plugin</artifactId> <version>2.4.1</version> <configuration>     <excludeDefaultDirectories>true</excludeDefaultDirectories>     <filesets>         <fileset>             <directory>target</directory>             <excludes>                 <exclude>classes/db/**</exclude>             </excludes>         </fileset>     </filesets>     <verbose>true</verbose> </configuration> 

When I do a mvn clean from the command line, the directory that I want kept (classes/db in the output directory) is not deleted, as I expect. However, when I do a Clean in Eclipse, the directory does get removed.

like image 37
Peter Lynch Avatar answered Oct 05 '22 11:10

Peter Lynch