0

I have a system that accepts plugins to let users add functionality to a management system. The plugin is basically just a zip file with in a certain format (ie file x in this dir, y in that dir). Currently I use the maven-assembly-plugin plugin to make the zip.

The problem is that it is awkward to keep all my plugins in sync and to let others make a plugin since they need the correct assembly.xml

Therefore I've been trying to make a custom packaging type so developers can make a plugin like this:

<groupId>com.example</groupId>
<artifactId>example</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>plugin</packaging> //not a standard type

This is mostly working but the ugly thing now is that each plugin always depends on certain APIs in the core system. Therefore they all basically have the same dependencies.

Is it possible for a mojo to inject dependencies into a user of the mojo? This seems to say it can't: http://maven.40175.n5.nabble.com/How-to-inject-dependencies-from-a-mojo-td83025.html

mlathe
  • 2,375
  • 1
  • 23
  • 42
  • Have you read the answer in the thread you've mentioned? – khmarbaise Mar 27 '13 at 07:46
  • @khmarbaise yes, but that was 5+ years ago. Who knows what happened since then. – mlathe Mar 27 '13 at 19:46
  • 1
    I came across a pretty obvious and simple solution. I make a "pom" project that contains the dependencies, and ask that the developer includes that pom as a dependency. That solves my issue nicely since i can centralize the dependencies in one place and each "plugin" can transitively get to the core api dependencies if they want. Easy Peasy. – mlathe Mar 27 '13 at 22:12

1 Answers1

0

Answered in comments:

I came across a pretty obvious and simple solution. I make a "pom" project that contains the dependencies, and ask that the developer includes that pom as a dependency. That solves my issue nicely since i can centralize the dependencies in one place and each "plugin" can transitively get to the core api dependencies if they want. Easy Peasy. – mlathe Mar 27 '13 at 22:12

pjanssen
  • 1,065
  • 13
  • 35
  • 1
    I am trying to do the same. One question: When you say "and ask that the developer includes that pom as a dependency", where should the POM be included as dependency? (1) in the POM of the plugin, or (2) in the POM that is consuming the plugin? – dc95 Oct 25 '16 at 01:14