简体   繁体   English

Maven 插件执行另一个插件

[英]Maven plugin executing another plugin

I'm trying to create a new plugin to package my latest project.我正在尝试创建一个新插件来打包我的最新项目。 I'm trying to have this plugin depend on the maven-dependency-plugin to copy all my projects dependencies.我试图让这个插件依赖于 maven-dependency-plugin 来复制我所有的项目依赖项。

I've added this dependency to my plugin's pom, but I can't get it to execute.我已将此依赖项添加到插件的 pom 中,但无法执行。

I have this annotation in my plugins main Mojo:我的插件主 Mojo 中有此注释:

@execute goal="org.apache.maven.plugins:maven-dependency-plugin:copy"

I've tried a few other names for the goal, like dependency:copy and just copy but they all end with a message saying that the required goal was not found in my plugin.我为目标尝试了其他一些名称,例如依赖项:复制和只是复制,但它们都以一条消息结尾,指出在我的插件中找不到所需的目标。 What am I doing wrong?我究竟做错了什么?

Secondary to this is where to I provide configuration info for the dependency plugin?其次是我在哪里提供依赖插件的配置信息?

Use the Maven Mojo executor by Don Brown of Atlassian fame to run any other arbitrary plugin.使用由 Atlassian 著名的 Don Brown 开发的Maven Mojo 执行器来运行任何其他任意插件。

The Mojo Executor provides a way to to execute other Mojos (plugins) within a Maven 2 plugin, allowing you to easily create Maven 2 plugins that are composed of other plugins. Mojo Executor 提供了一种在 Maven 2 插件中执行其他 Mojo(插件)的方法,允许您轻松创建由其他插件组成的 Maven 2 插件。

Have you tried to create your own packaging type?您是否尝试过创建自己的包装类型? Then you can define your own lifecycle mapping, ie bind goals to phases.然后您可以定义自己的生命周期映射,即将目标绑定到阶段。 In this case you can bind the dependency:copy-dependencies goal to your packaging phase and you don't have to wrap the goal into your own Mojo.在这种情况下,您可以将 dependency:copy-dependencies 目标绑定到打包阶段,而不必将目标包装到您自己的 Mojo 中。

See also: How do I create a new packaging type for Maven?另请参阅: 如何为 Maven 创建新的打包类型?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM