本文介绍了Maven源插件jar和jar-no-fork目标之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你能否详细解释一下jar和jar-no-fork目标之间的区别?

Could you give me a detail explanation about the difference between jar and jar-no-fork goal?

我是从官方网站看到的,但我无法得到一个明确的想法。

I see it from official site, but I can not get a clear idea for this.

推荐答案

我的解释: jar 目标意味着从命令行运行( mvn source:jar ), jar-no-fork 是指绑定到生命周期。

My interpretation: the jar goal is meant to be run from the command line (mvn source:jar), the jar-no-fork is meant to be bound to the lifecycle.

如果你看一下 c $ c> jar 目标的> docs关键短语是在执行自身之前调用生命周期阶段generate-sources的执行。如果您将POM配置为在生命周期中运行 source:jar 目标,Maven将重新运行所有绑定的目标 generate-sources 及其前身。如果您有许多插件绑定到验证或初始化阶段,那么所有这些目标都将运行两次,从而延长了构建时间。

If you look at the docs for the jar goal the key phrase is "Invokes the execution of the lifecycle phase generate-sources prior to executing itself." If you configure your POM to run the source:jar goal as part of the lifecycle, Maven will re-run all of the goals bound to generate-sources and its predecessors. If you have many plugin goals bound to the validate or initialize phases all of those will run twice, lengthening the time of your build.

相比之下, jar-no-fork 是您附加到构建生命周期的内容,因为它希望受到约束到 generate-sources 之后的某个阶段,并且不会再次运行绑定目标。

In contrast, jar-no-fork is what you attach to the build lifecycle because it expects to be bound to a phase somewhere after generate-sources and will not run the bound goals again.

我已验证此行为通过使用 -X 运行Maven 3并查看运行的插件执行。

I have verified this behavior by running Maven 3 with -X and reviewing the plugin executions that run.

这篇关于Maven源插件jar和jar-no-fork目标之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!