为什么在验证阶段调用 jfrog maven artifactory 插件?

Why does jfrog maven artifactory plugin is invoked at validation phase?

Here 是jfrom artifactory 插件概述。他们告诉:

The plugin's invocation phase is "validate" by default and we recommend you don't change it so the plugin is called as early as possible in the lifecycle of your Maven build.

据我了解(我错了吗?)这个插件是用来部署maven项目的。所以这个插件应该 "wait" 直到所有测试都通过,编译源代码并打包和部署工件只在 delploy 阶段,不是吗?

问题:为什么链接到验证阶段?

我查看了插件的 source code 并找到了这一行:

String deployGoals = 'deploy,maven-deploy-plugin'

此字段用于 recordBuildInfo 方法。此方法注册 class BuildInfoRecorder as listener which calls the real deploy method when the session ends.

实际上 artifactory-maven-plugin 应用了与通常的 mojo(Maven 目标)实现不同的模式:它依赖于 Maven Lifecycle listeners/extensions.

看看它的 github repository,魔力实际上是:

  • 确保跳过 maven-deploy-plugin default binding by setting the maven.deploy.skip 属性 到 true
  • 向构建会话添加自定义 Maven 侦听器,BuildInfoRecorderLifecycleParticipant
  • 然后在适当的时候通过其插件有效地deploys

必须绑定到 validate 阶段才能有效地跳过默认的 deploy 行为并注册自己的侦听器。