title: How to programatically invoke a maven dependency plugin
body: <p>I am trying to invoke maven-dependency-plugin programatically. i am using maven 3 version. the problem is that when i invoke it through pluginManager.executeMojo(session, execution), i receive the following error message:</p>
  
  <pre><code>[ERROR] **The parameters 'project', 'local', 'remoteRepos',
  'reactorProjects' for goal
  org.apache.maven.plugins:maven-dependency-plugin:2.1:unpack are
  missing or invalid**
  **org.apache.maven.plugin.PluginParameterException: The parameters 'project',
  'local', 'remoteRepos', 'reactorProjects' for goal
  org.apache.maven.plugins:maven-dependency-plugin:2.1:unpack are missing or
  invalid**
          at org.apache.maven.plugin.internal.DefaultMavenPluginManager
          .populatePluginFields(DefaultMavenPluginManager.java:518)
          at org.apache.maven.plugin.internal.DefaultMavenPluginManager
          .getConfiguredMojo(DefaultMavenPluginManager.java:471)
          at org.apache.maven.plugin.DefaultBuildPluginManager
          .executeMojo(DefaultBuildPluginManager.java:99)
          at com.sap.ldi.qi.osgi.OSGiManifesrMfHandlerMojo
          .invokeMavenDependencyPlugin(OSGiManifesrMfHandlerMojo.java:139)
          at com.sap.ldi.qi.osgi.OSGiManifesrMfHandlerMojo
          .execute(OSGiManifesrMfHandlerMojo.java:100)
          at org.apache.maven.plugin.DefaultBuildPluginManager
          .executeMojo(DefaultBuildPluginManager.java:110)
          at org.apache.maven.lifecycle.internal.MojoExecutor
          .execute(MojoExecutor.java:144)
          at org.apache.maven.lifecycle.internal.MojoExecutor
          .execute(MojoExecutor.java:87)
          at org.apache.maven.lifecycle.internal.MojoExecutor
          .execute(MojoExecutor.java:79)
  -- many lines stripped from stack trace --
  [INFO] ----------------------------------------------------------------------
  [INFO] BUILD FAILURE
  [INFO] ----------------------------------------------------------------------
  [INFO] Total time: 17.938s
  [INFO] Finished at: Mon Nov 22 10:27:42 EET 2010
  [INFO] Final Memory: 12M/23M
  [INFO] ----------------------------------------------------------------------
  [ERROR] Failed to execute goal
  com.sap.ldi.qi:osgi-manifest-handler-plugin:0.0.1-SNAPSHOT:handle
  (osgi-manifest-handler plugin) on project com.sap.ldi.demo.calc
  .cmd.tests: The parameters 'project', 'local', 'remoteRepos',
  'reactorProjects' for goal
  org.apache.maven.plugins:maven-dependency-plugin:2.1:unpack are missing
  or invalid -&gt; [Help 1]
  -- stripped rest --
  </code></pre>
  
  <p>As I know, the only required parameter for the unpack goal of maven dependency plugin is artifactItems. I set the plugin configuration by using PluginExecution.setConfiguration() method. It seems that this plugin configuration is not correctly set.
  Do you have any idea why this exception is thrown?</p>
  
  <p>Here is the configuration that I am using:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;artifactItems&gt;
      &lt;artifactItem&gt;
        &lt;groupId&gt;com.sap.ldi.demo.calc&lt;/groupId&gt;
        &lt;artifactId&gt;com.sap.ldi.demo.calc.cmd&lt;/artifactId&gt;
        &lt;version&gt;0.1.2-SNAPSHOT&lt;/version&gt;
        &lt;type&gt;jar&lt;/type&gt;
        &lt;overWrite&gt;true&lt;/overWrite&gt;
        &lt;outputDirectory&gt;target/demo-calc-stuff&lt;/outputDirectory&gt;
        &lt;includes&gt;**/*.*&lt;/includes&gt;
      &lt;/artifactItem&gt;
    &lt;/artifactItems&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>One correction from my side. The used Maven version is not Maven 3.0 but Maven 3.0-beta-1. I see that <code>BuildPluginManager.loadPlugin()</code> in version 3.0-beta-1 has two args, and the same method in version 3.0 has three. 
  I am wondering, does anyone tried to invoke a maven plugin programatically with maven 3.0 or maven 3.0-beta-1. I am still trying to invoke it with maven 3.0-beta-1, but it still returns the same exception as pasted above.</p>