See in this case I'm not so much trying to invoke a plugin A from plugin B but rather configure plugin A from plugin B. Though I somewhat agree that this could lead to some really odd things occurring.
Besides generating the manifest myself, the only other possibility I can think of is to basically write my own jar-plugin. Since most of the information I need for the manifest exists in the XML configuration file used by my generator, the jar plugin would just need to read the info from the file and setup the manifest accordingly. I'd considered simply extending the JarMojo, but there doesn't seem to be anyway to access the MavenArchiveConfiguration attribute in the base class (its private and no setter/getters exist) Not sure exactly what I'm going to do yet. Deserves some consideration MAR -----Original Message----- From: Kenney Westerhof [mailto:[EMAIL PROTECTED] Sent: Thursday, July 06, 2006 6:56 AM To: Maven Developers List Subject: Re: Reconfiguring a plugin from within another plugin? 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:[EMAIL PROTECTED] > > 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: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- Kenney Westerhof http://www.neonics.com GPG public key: http://www.gods.nl/~forge/kenneyw.key --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
