Maven plugin executing another plugin

2019-01-11 03:40发布

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.

I've added this dependency to my plugin's pom, but I can't get it to execute.

I have this annotation in my plugins main 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?

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-01-11 03:50

Use the Maven Mojo executor by Don Brown of Atlassian fame to run any other arbitrary plugin.

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.

查看更多
闹够了就滚
3楼-- · 2019-01-11 03:55

Have you tried to create your own packaging type? Then you can define your own lifecycle mapping, i.e. 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.

See also: How do I create a new packaging type for Maven?

查看更多
登录 后发表回答