dm3 wrote:
> 
> Hello,
> In my plugin I need to construct a classpath containing artifacts in the
> pom
> of the project being analyzed. There's a maven-dependency-plugin which
> already does the specified task
> (BuildClasspathMojo<http://svn.apache.org/viewvc/maven/plugins/tags/maven-dependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/BuildClasspathMojo.java?view=markup>).
> The question is: how do I reuse this functionality in my plugin?
> 
> I've searched unsuccessfully for the explanation on how the interop
> between
> different maven plugins should happen.
> This<http://mail-archives.apache.org/mod_mbox/maven-users/200706.mbox/%[email protected]%3e>thread
> mentions that directly invoking mojos from plugins is a bad practice
> as it increases coupling between plugins and prohibits reuse (as plugins
> should be merely maven-specific wrappers of existing functionality). Some
> form of context, shared between plugins is mentioned, but I failed to find
> any documentation on how to use it.
> However (as I understood - and I might be wrong) this context is only
> shared
> between plugins configured in the pom and can't be used by plugins
> invoking
> other plugins directly.
> 
> I would be grateful if someone could point me in right direction.
> 
> 

I've recently run into similar concerns in a different context (filtering,
and writing additional artifacts, etc.).  

At first I tried to tackle the problem in a the same mannerr as you seem to
be, first trying to communicate between plugins, and then trying to figure
out how to extend a plugin that provided the base functionality that I
needed.  It didn't take me long to realize that this approach would be
perilous.

However, when I actually opened the code of the plugins that implemented the
functionality I wanted to leverage, I found that those plugins were actually
making extensive use of either (1) Maven Shared components, such as
maven-filtering and maven-archiver, or (2) Plexus components, and I could
leverage both the first and the second as I needed without difficulty.

You might want to take a look at the code for the maven-dependency-plugin
and maven-dependency-tree shared component.  I, for one, concluded it would
be easier to write a bit more code and not have to wrangle with all "how to
make it work" stuff that would be involved in directly extending a plugin.

Mark


-- 
View this message in context: 
http://www.nabble.com/Communication-between-plugins-tp25660168p25668799.html
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to