You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jimisola Laursen <li...@jimisola.com> on 2006/07/12 14:32:28 UTC
Passing plugin build configuration from pom to a custom bean
Hi!
I am having problem passing parameters from the pom to a bean in my maven
plugin.
I've read the section about "Parameter Types With Multiple Values" on
http://maven.apache.org/guides/plugin/guide-java-plugin-development.html,
but still can't get it to work. It would really help with some documentation
on this matter.
E.g.:
- the section on "Other Object Classes: This category covers any class
which does not implement java.util.Map, java.util.Collection, or
java.util.Dictionary." leaves a lot in the dark
- "implementation hint" is mentioned in "If the XML contains an
implementation hint, that is used", but what is it aka how do I hint?
Anyway, what I want to accomplish is fairly simple and I've simplified it as
much as possible (I think).
I have a Bean:
public class MyBean
{
String outputFile;
public String getOutputFile()
{
return this.outputFile;
}
public void setOutputFile(String outputFile)
{
this.outputFile = outputFile;
}
}
NOTE: I don't want to/cannot have outputFile on the top level, since I there
will be other bean, e.g. MyOtherBean, that contain a outputFile
variable/parameter as well.
MyMojo extends AbstractMojo and has:
/**
* Configures MyBean
* @parameter expression="${mybean}";
*/
private MyBean myBean;
How do I configure this in my pom.xml? It fails with this:
<build>
<plugins>
<plugin>
<groupId>se.example.mymojo</groupId>
<artifactId>mymojo-maven-plugin</artifactId>
<configuration>
<mybean>
<outputFile>stdout</outputFile>
</mybean>
</configuration>
<executions>
<execution>
<id>mybean-exec</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
While debugging I know that:
1. the plugin runs
2. mybean != null
3. mybean.getOutputFile() == null
What do I need to do to get this working?
I would really appreciate an answer on this issue since I am currently stuck
here.
Regards,
Jimisola
--
View this message in context: http://www.nabble.com/Passing-plugin-build-configuration-from-pom-to-a-custom-bean-tf1930560.html#a5287739
Sent from the Maven - Users forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Passing plugin build configuration from pom to a custom bean
Posted by Jimisola Laursen <li...@jimisola.com>.
These is some documentation on this:
http://maven.apache.org/guides/mini/guide-configuring-plugins.html
However, I find that some of this documentation is non-user documentation
(Java implementation details on e.g. mapping of complex objects and
getters/setters) and would have been better of in "Guide to Developing Java
Plugins".
Regards,
Jimisola
--
View this message in context: http://www.nabble.com/Passing-plugin-build-configuration-from-pom-to-a-custom-bean-tf1930560.html#a5292442
Sent from the Maven - Users forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Passing plugin build configuration from pom to a custom bean
Posted by Jimisola Laursen <li...@jimisola.com>.
Found the solution, but this should definetly be in the documentation.
I thought that I'd seen this sort of configuration before.. and yes the
Maven Dependency Plugin uses it for artifact item (see
http://mojo.codehaus.org/dependency-maven-plugin/howto.html):
<configuration>
<artifactItems>
<artifactItem>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<type>jar</type>
<outputDirectory>${project.build.directory}/alternateLocation</location>
<destFileName>optional-new-name.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/wars</outputDirectory>
</configuration>
I suspected that I needed to add javadoc annotations to my bean - which I
got confirmed by the Dependency plugin:
public class ArtifactItem
{
/**
* Group Id of Artifact
* @parameter
* @required
*/
private String groupId;
[...]
/**
* @return Returns the artifactId.
*/
public String getArtifactId()
{
return artifactId;
}
/**
* @param artifactId The artifactId to set.
*/
public void setArtifactId( String artifact )
{
this.artifactId = artifact;
}
[...]
}
One of the mojos looks has this section:
/**
* Collection of ArtifactItems to work on. (ArtifactItem contains
groupId, artifactId, version, type, location, destFile, markerFile and
overwrite.)
* See "How To Use" and "Javadoc" for details.
* @parameter
* @required
*/
private ArrayList artifactItems;
(The Dependency Maven Plugin source code is Copyright 2005-2006 Brian Fox
and licensed under the Apache License, Version 2.0).
Regards,
Jimisola
--
View this message in context: http://www.nabble.com/Passing-plugin-build-configuration-from-pom-to-a-custom-bean-tf1930560.html#a5288122
Sent from the Maven - Users forum at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org