26

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?

Rich Seller
  • 83,208
  • 23
  • 172
  • 177
Cogsy
  • 5,584
  • 4
  • 35
  • 47

2 Answers2

41

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.

Jesse Glick
  • 24,539
  • 10
  • 90
  • 112
Matthew McCullough
  • 17,160
  • 7
  • 39
  • 38
  • 7
    See http://stackoverflow.com/questions/4243686/how-to-programatically-invoke-a-maven-dependency-plugin/5761554#5761554 for an updated version of Mojo Executor for Maven 3. – Gili Apr 23 '11 at 01:38
1

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?

Community
  • 1
  • 1
Daniel S.
  • 628
  • 6
  • 12