25

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?

balteo
  • 23,602
  • 63
  • 219
  • 412

2 Answers2

22

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.

Giorgos Dimtsas
  • 12,019
  • 3
  • 29
  • 40
  • Do you know where are located the output folders and how I can access the project's preferences? – balteo Jan 13 '12 at 16:57
  • @balteo Right click on the project in the project explorer view and then click properties. On the popup, choose the 'Java Build Path' on the left, then choose the 'Source' tab. There you will find the output path for each source folder. – Giorgos Dimtsas Jan 13 '12 at 18:02
5

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.

Peter Lynch
  • 51
  • 1
  • 1
  • 4
    +1: This seems to confirm Giorgos Dimtsas answer, as the classes folder is normally configured as output in eclipse. – Jan Mar 16 '12 at 08:58