孩子完成后,家长执行目标
我有一个多模块 Maven 项目(多层嵌套)。通常,当我执行 Maven 构建(例如 mvn install
或其他)时,maven 将在处理子项目之前运行父项目的所有目标。
我希望能够定义一个在父级上运行的目标,但要等到所有子级都已处理完毕为止。有办法做到这一点吗?
具体来说,我想要做的是运行一个 exec:exec 目标,该目标会在文件系统中递归查找测试结果文件,并将它们复制到一个中央位置,以便由我们的 CI 系统(cruisecontrol)进行聚合。因此,也欢迎解决此问题的替代解决方案:)
更新:我忘记提及一个要求:无论构建是否成功,我都需要运行 exec 目标。
I have a multi-module maven project (several levels of nesting). Normally, when I execute a maven build (like mvn install
or whatever), maven will run all the goals for the parent project before proceeding with the children.
I want to be able to define a goal that runs on the parent, but not until all of the children have been processed. Is there a way to do this?
Specifically, what I want to do is run an exec:exec
goal which recurses down the filesystem looking for test result files and copies them to a central location for aggregation by our CI system (cruisecontrol). So, alternative solutions to this problem are also welcome :)
UPDATE: I forgot to mention one requirement: I need the exec goal to run regardless of whether the build is successful or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为不可能在多模块构建结束时从父级做一些事情(这不是事情的工作方式)。但是,您是否考虑根据所有子项目添加一个模块(可能是 pom 类型)(因此它将是反应器构建中的“最后一个”项目)并在此运行
exec:exec
模块?我可能会错过一些东西,因为我不明白为什么这不起作用。I don't think it's possible to do things from the parent at the end of a multi-modules build (this is just not how things work). However, did you consider adding a module (that could be of type pom) depending on all child projects (so it will be the "last" project in a reactor build) and run
exec:exec
in this module? I may be missing something be I don't see why this wouldn't work.根据其他答案和我自己的后续调查,我所描述的内容似乎不可能用 Maven 实现。
但是,我能够解决我的问题,尽管该解决方案特定于巡航控制。基本上,我将执行目标绑定到预站点阶段,然后在 Cruisecontrol 配置中将预站点指定为
sitegoal
。sitegoal
在主要目标之后运行,并且无论构建是否成功都会这样做。我想其他 CI 系统也提供类似的东西。
Based on the other answers and my own subsequent investigation, it doesn't look like what I described is possible with Maven.
However, I was able to solve my problem, although the solution is specific to cruisecontrol. Basically, I bound my exec goal to the pre-site phase then specified pre-site as the
sitegoal
in my cruisecontrol configuration. Thesitegoal
runs after the main goal, and does so regardless of whether the build succeeds or not.I imagine other CI systems offer something similar..
听起来更像是一个报告插件。创建 Maven 插件实际上非常简单。
Sounds more like a reporting plugin. Creating a Maven plugin is actually quite easy.
为什么不将 antrun 复制步骤附加到每个子项目的验证阶段以将结果复制到父位置。然后,您可以在父级中执行类似的步骤来执行 CI 聚合。
或者,您可以让每个子项目使用类似的技术进行自己的 CI 集成。
我们目前使用该技术为 jar 等生成 websphere ejb 存根。
Why not have a antrun copy step attached to the verify phase of each sub project to copy the results up to the parent location. You could then have a similiar step in the parent to do the CI aggregation.
Alternatively, you could have each sub project do its own CI integration using a simliar techneque.
We currenyly use the technique to generate websphere ejb stubs for a jar, amongst other things.