You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Vadim <de...@gmail.com> on 2009/09/29 12:00:43 UTC
Communication between plugins
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/%3C4669508E.1020903@apache.org%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.
Re: Communication between plugins
Posted by Stephen Connolly <st...@gmail.com>.
it's still going to suffer from the plugin classloading issue, i.e. if
somebody wants to use a newer version of the plugin you have extended, then
either your plugin breaks or they get the version you extended
2009/9/30 Jörg Schaible <jo...@gmx.de>
> Neroon wrote at Dienstag, 29. September 2009 23:27:
>
> > Have you had a look at the following?
> > http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin/
> >
> > I haven't actually tried it, but it looks promising. The information is
> > from this issue:
> > http://jira.codehaus.org/browse/MNG-3042
>
> This does not solve the technical limitations, it simply opens the can of
> worms a lot easier. However, it's your build ...
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: Communication between plugins
Posted by Jörg Schaible <jo...@gmx.de>.
Neroon wrote at Dienstag, 29. September 2009 23:27:
> Have you had a look at the following?
> http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin/
>
> I haven't actually tried it, but it looks promising. The information is
> from this issue:
> http://jira.codehaus.org/browse/MNG-3042
This does not solve the technical limitations, it simply opens the can of
worms a lot easier. However, it's your build ...
- Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Communication between plugins
Posted by Vadim <de...@gmail.com>.
Thanks for the answers, I will describe the solution I'll choose.
On Wed, Sep 30, 2009 at 12:27 AM, Neroon <ne...@nurfuerspam.de> wrote:
> Have you had a look at the following?
> http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin/
>
> I haven't actually tried it, but it looks promising. The information is
> from
> this issue:
> http://jira.codehaus.org/browse/MNG-3042
>
> Cheers
>
> Am Dienstag, 29. September 2009 schrieb Vadim:
> > 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/%3C4669508E.1020903@apache.org%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.
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: Communication between plugins
Posted by Neroon <ne...@nurfuerspam.de>.
Have you had a look at the following?
http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin/
I haven't actually tried it, but it looks promising. The information is from
this issue:
http://jira.codehaus.org/browse/MNG-3042
Cheers
Am Dienstag, 29. September 2009 schrieb Vadim:
> 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/%3C4669508E.1020903@apache.org%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.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Communication between plugins
Posted by Roland Asmann <Ro...@cfc.at>.
On Tuesday 29 September 2009 14:19, Jörg Schaible wrote:
> Roland Asmann wrote at Dienstag, 29. September 2009 13:12:
> > OK, so maybe I should've written a bit more about what I meant.
> >
> > I indeed meant to create a normal jar-dependency on the plugin and write
> > your own plugin. However, that plugin could very well extend the mojo
> > from the original and use any other classes from the extended plugin. I
> > mean, it's just java!
>
> No you cannot! Every plugin is loaded only once. If you derive from a
> plugin, you will load the other one implicitly. So, what happens now, if
> your user want/have to use the original plugin in a different version than
> the version required by the derived plugin? You will easily break one of
> the two plugins and give your user a hard time, really!
Really? I had no idea... Good to know. I'll be developing a couple of plugins
in my company over the next couple of weeks, so that's a thing to remember!
>
> > And sharing the data is nice, but if you need something from an existing
> > plugin, you'd have to convince the authors of that plugin to write it for
> > you. So that doesn't solve anything!
>
> You can copy the source as long as the functionality is not separated into
> an own artifact.
>
> - Jörg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
--
Roland Asmann
CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien
Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Communication between plugins
Posted by Jörg Schaible <jo...@gmx.de>.
Roland Asmann wrote at Dienstag, 29. September 2009 13:12:
> OK, so maybe I should've written a bit more about what I meant.
>
> I indeed meant to create a normal jar-dependency on the plugin and write
> your own plugin. However, that plugin could very well extend the mojo from
> the original and use any other classes from the extended plugin. I mean,
> it's just java!
No you cannot! Every plugin is loaded only once. If you derive from a
plugin, you will load the other one implicitly. So, what happens now, if
your user want/have to use the original plugin in a different version than
the version required by the derived plugin? You will easily break one of
the two plugins and give your user a hard time, really!
> And sharing the data is nice, but if you need something from an existing
> plugin, you'd have to convince the authors of that plugin to write it for
> you. So that doesn't solve anything!
You can copy the source as long as the functionality is not separated into
an own artifact.
- Jörg
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Communication between plugins
Posted by Roland Asmann <Ro...@cfc.at>.
OK, so maybe I should've written a bit more about what I meant.
I indeed meant to create a normal jar-dependency on the plugin and write your
own plugin. However, that plugin could very well extend the mojo from the
original and use any other classes from the extended plugin. I mean, it's
just java!
And sharing the data is nice, but if you need something from an existing
plugin, you'd have to convince the authors of that plugin to write it for
you. So that doesn't solve anything!
On Tuesday 29 September 2009 13:05, Stephen Connolly wrote:
> That guess would be wrong.
>
> You cannot extend plugins in a different group id. you need to create a
> standard jar dependency and have your plugins be thin wrappers on top of
> the jar dependency.
>
> If multiple plugins need to share data, AFAIK they should store that data
> in MavenSession
>
> -Stephen
>
> 2009/9/29 Roland Asmann <Ro...@cfc.at>
>
> > My guess would be to write a plugin that depends on this plugin... Then
> > you should be able to connect to all the public and (if you extend a
> > class) protected methods... Or do you have a reason why that would/could
> > not work?
> >
> > On Tuesday 29 September 2009 12:00, Vadim 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-d
> >
> > >ependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/Bu
> > >ildC lasspathMojo.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/%3C46
> >
> > >69508E.1020903@apache.org%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.
> >
> > --
> > Roland Asmann
> >
> > CFC Informationssysteme Entwicklungsgesellschaft m.b.H
> > Bäckerstrasse 1/2/7
> > A-1010 Wien
> > FN 266155f, Handelsgericht Wien
> >
> > Tel.: +43/1/513 88 77 - 27
> > Fax.: +43/1/513 88 62
> > Email: Roland.Asmann@cfc.at
> > Web: www.cfc.at
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
--
Roland Asmann
CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien
Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Communication between plugins
Posted by Stephen Connolly <st...@gmail.com>.
That guess would be wrong.
You cannot extend plugins in a different group id. you need to create a
standard jar dependency and have your plugins be thin wrappers on top of the
jar dependency.
If multiple plugins need to share data, AFAIK they should store that data in
MavenSession
-Stephen
2009/9/29 Roland Asmann <Ro...@cfc.at>
> My guess would be to write a plugin that depends on this plugin... Then you
> should be able to connect to all the public and (if you extend a class)
> protected methods... Or do you have a reason why that would/could not work?
>
>
> On Tuesday 29 September 2009 12:00, Vadim 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-d
>
> >ependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/BuildC
> >lasspathMojo.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/%3C46
> >69508E.1020903@apache.org%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.
>
> --
> Roland Asmann
>
> CFC Informationssysteme Entwicklungsgesellschaft m.b.H
> Bäckerstrasse 1/2/7
> A-1010 Wien
> FN 266155f, Handelsgericht Wien
>
> Tel.: +43/1/513 88 77 - 27
> Fax.: +43/1/513 88 62
> Email: Roland.Asmann@cfc.at
> Web: www.cfc.at
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
Re: Communication between plugins
Posted by Roland Asmann <Ro...@cfc.at>.
My guess would be to write a plugin that depends on this plugin... Then you
should be able to connect to all the public and (if you extend a class)
protected methods... Or do you have a reason why that would/could not work?
On Tuesday 29 September 2009 12:00, Vadim 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-d
>ependency-plugin-2.1/src/main/java/org/apache/maven/plugin/dependency/BuildC
>lasspathMojo.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/%3C46
>69508E.1020903@apache.org%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.
--
Roland Asmann
CFC Informationssysteme Entwicklungsgesellschaft m.b.H
Bäckerstrasse 1/2/7
A-1010 Wien
FN 266155f, Handelsgericht Wien
Tel.: +43/1/513 88 77 - 27
Fax.: +43/1/513 88 62
Email: Roland.Asmann@cfc.at
Web: www.cfc.at
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Communication between plugins
Posted by Mark Bargen <ba...@dor.state.ma.us>.
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/%3C4669508E.1020903@apache.org%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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org