“mvn clean install”如何?与“mvn install”不同吗?
mvn clean install
和 mvn install
之间有什么区别?
What is the difference between mvn clean install
and mvn install
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
clean
是 Maven 中它自己的构建生命周期阶段(可以将其视为操作或任务)。mvn clean install
告诉 Maven 在运行每个模块的install
阶段之前在每个模块中执行clean
阶段。这样做的目的是清除您拥有的所有已编译文件,确保您真正从头开始编译每个模块。
clean
is its own build lifecycle phase (which can be thought of as an action or task) in Maven.mvn clean install
tells Maven to do theclean
phase in each module before running theinstall
phase for each module.What this does is clear any compiled files you have, making sure that you're really compiling each module from scratch.
Maven 允许您在命令行上指定目标或生命周期阶段(或两者)。
clean
和install
是 两个不同生命周期的两个不同阶段,其中绑定了不同的插件目标(默认情况下或明确地 根据约定,
clean
阶段的目的是使构建可重现,即它会清理以前构建创建的任何内容。在大多数情况下,它通过调用clean:clean< 来实现这一点/code>
,删除绑定到
${project.build.directory}
的目录(通常称为“target”)Maven lets you specify either goals or lifecycle phases on the command line (or both).
clean
andinstall
are two different phases of two different lifecycles, to which different plugin goals are bound (either per default or explicitly in your pom.xml)The
clean
phase, per convention, is meant to make a build reproducible, i.e. it cleans up anything that was created by previous builds. In most cases it does that by callingclean:clean
, which deletes the directory bound to${project.build.directory}
(usually called "target")你可以使用maven调用多个
target目标。mvn clean install
首先调用clean
,然后调用install
。您必须手动清理,因为清理不是标准的target目标,并且不会在每次安装时自动执行。clean 删除目标文件夹 - 它删除所有类文件、java 文档、jar、报告等。如果你不
clean
,那么maven只会“做必须做的事情”,就像当相应的源文件没有改变时它不会编译类(简而言之)。我们在 ant 中将其称为目标,在 maven 中将其称为目标
You can call more than one
targetgoal with maven.mvn clean install
callsclean
first, theninstall
. You have to clean manually, because clean is not a standardtargetgoal and not executed automatically on every install.clean
removes the target folder - it deletes all class files, the java docs, the jars, reports and so on. If you don'tclean
, then maven will only "do what has to be done", like it won't compile classes when the corresponding source files haven't changed (in brief).we call it target in ant and goal in maven
坚持 Maven 术语:
生命周期
默认生命周期
http://maven.apache.org/guides /introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
To stick with the Maven terms:
lifecycle
default lifecycle
http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference
@Andreas_D 也是如此,此外,如果您说将项目中的 Spring 从一个版本更新到另一个版本而不进行清理,那么您最终将在您的工件中得到这两个版本。在使用 Maven 进行 Flex 开发时经常遇到这个问题。
Ditto for @Andreas_D, in addition if you say update Spring from 1 version to another in your project without doing a clean, you'll wind up with both in your artifact. Ran into this a lot when doing Flex development with Maven.