Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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?

like image 268
Cogsy Avatar asked Feb 09 '09 00:02

Cogsy


People also ask

Does Maven allow third party plugins?

plugins for prefix-to-artifactId mappings for the plugins it needs to perform a given build. However, as previously mentioned, the user may have a need for third-party plugins.

What is the difference between plugin and pluginManagement tags?

pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one.

What is the correct syntax for executing a Maven plugin?

Usage of a Maven Plugin xml you can use the shorthand notation to execute the plugin: mvn <prefix>:<goal> , commonly the “prefix” is the artifact ID minus the “-maven-plugin”. For example mvn example:version .


2 Answers

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.

like image 55
Matthew McCullough Avatar answered Sep 23 '22 19:09

Matthew McCullough


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?

like image 1
Daniel S. Avatar answered Sep 23 '22 19:09

Daniel S.