eclipse m2e中Eclipse的“clean project”和Maven的“mvn clean”的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8853098/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 17:33:50  来源:igfitidea点击:

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

eclipsemavenm2eclipsem2e

提问by balteo

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

我使用 M2e + Eclipse + Maven,我想知道它们之间有什么区别:

  • running "mvn clean" in a terminaland
  • running "clean project" from Eclipse?
  • 在终端中运行“mvn clean”
  • 从 Eclipse 运行“干净的项目”

Can anyone please advise?

任何人都可以请指教吗?

采纳答案by Giorgos Dimtsas

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

从一些快速测试来看,Eclipse 似乎clean project只清除了项目首选项中设置为输出文件夹的文件夹,而 mavenclean则完全删除了 /target 文件夹。

回答by Peter Lynch

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

我的 pom.xml 文件中有以下条目:

<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 doesget removed.

当我从命令行执行 mvn clean 时,我想要保留的目录(输出目录中的类/db)没有被删除,正如我所期望的。但是,当我在 Eclipse 中执行 Clean 时,该目录确实被删除了。