maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kenney Westerhof <ken...@apache.org>
Subject Re: Reconfiguring a plugin from within another plugin?
Date Thu, 06 Jul 2006 12:56:08 GMT
On Thu, 6 Jul 2006, Rinku wrote:

Hi,

> Hi ,
>
> I am not sure about 'updating' plugin configuration from another one;
> but to obtain a reference to JAR plugin, you could try something like
> below (from the maven-eclipse-plugin sources):

The code below was a bit of a hack of mine to get access to another
plugin's configuration. It really is not ideal, and it certainly won't get
you access to a live instance of another plugin.

Maven doesn't allow one plugin to be called by another because the
controlling entity is the lifecycle. If plugin A could call plugin B
then you'd get ant-like spaghetti really soon. :)

Although there is a way: fork a custom lifecycle. The release plugin
for instance (release:perform) actually manages to call
mvn deploy site site:deploy.

But usually when this problem arises there's a bad separation of concerns
somewhere, and there's usually a better way of doing it.

The given problem is a hard one.. You basically want a plugin for
the jar plugin, or the archiver.

I think that the archiver needs some modification to allow for a custom
ManifestFactory component. You could then create a components.xml and
replace the ManifestFactory with your own implementation, although I'm not
sure that it will be used if it's in a different plugin than the
maven-jar-plugin.

Another solution would be to just create the manifest yourself using a
mojo, and then have people configure the maven-jar-plugin to specify
the newly created MANIFEST.MF - possibly the archiver will merge that with
the one it generates itself, although I haven't had any success with that.

More ideas?

-- Kenney


> ======== <snip> =======
>     public static String getPluginSetting( MavenProject project, String
> artifactId, String optionName,
>                                            String defaultValue )
>     {
>         for ( Iterator it =
> project.getModel().getBuild().getPlugins().iterator(); it.hasNext(); )
>         {
>             Plugin plugin = (Plugin) it.next();
>
>             if ( plugin.getArtifactId().equals( artifactId ) )
>             {
>                 Xpp3Dom o = (Xpp3Dom) plugin.getConfiguration();
>
>                 if ( o != null && o.getChild( optionName ) != null )
>                 {
>                     return o.getChild( optionName ).getValue();
>                 }
>             }
>         }
>
>         return defaultValue;
>     }
> ======== </snip> ========
>
>
> Russell, Mark wrote:
> > I have a custom plugin that generates a bunch of code, and the final jar
> > that includes this code needs to have certain manifest entries based on
> > the generated code.
> >
> > Unfortunately the code it generates is somewhat variable so manually
> > setting the entries in the pom would be rather error prone (which is one
> > thing I'm expending a great deal of effort to prevent).
> >
> > At the moment I'm hoping that I could somehow get a reference to the jar
> > plugin from within my custom code and modify its configuration or get
> > the pom configuration and modify it before the jar plugin is invoked.
> > Alternately I'll have to write a custom jar plugin that references a
> > singleton class to get some of its configuration (which I'd rather not
> > do since that is a really bad way to do things)
> >
> > MAR
> >
> > -----Original Message-----
> > From: Rinku [mailto:rahul.thakur.xdev@gmail.com]
> > Sent: Wednesday, July 05, 2006 3:55 PM
> > To: Maven Developers List
> > Subject: Re: Reconfiguring a plugin from within another plugin?
> >
> >
> > What is your use case? - may be there is another way to do it.
> >
> > Cheers,
> > Rahul
> >
> > Russell, Mark wrote:
> >
> >> Is it possible to reconfigure a plugin from within another plugin? (ie
> >> could a plugin bound to the initialize phase modify the configuration
> >>
> > of
> >
> >> a plugin bound to the package phase?)
> >>
> >>
> >>
> >> If so, how would I do it?
> >>
> >>
> >>
> >> MAR
> >>
> >>
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>

--
Kenney Westerhof
http://www.neonics.com
GPG public key: http://www.gods.nl/~forge/kenneyw.key

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Mime
View raw message