You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Christophe Grosjean <Ch...@arhs-developments.com> on 2006/03/30 17:37:39 UTC

configuration mappings for complex objects

Hi,

 

A question  about the configuration mappings... Does the mapping of
Maven project properties to Mojo fields also

work for any complex objects used to configure the plugin?

 

In other words, in the following code, will the 'project' field of the
ComplexObject parameter be assigned ?

 

 

 

public class SomeMojo extends AbstractMojo {

 

      /**

      * @parameter

      */

      private ComplexObject complexObject;

 

}

 

public class ComplexObject {

 

      /**

     * The maven project.

*

* @parameter expression="${project}"

* @required

* @readonly

*/

      private MavenProject project;

 

}

 

Thanks for your answer,

 

Christophe

 

 


Re: configuration mappings for complex objects

Posted by Stephane Nicoll <st...@gmail.com>.
Pfiou, I am bit tired and I read your mail way too fast.

You can't specify dependency injections parameters in your ComplexObject.
Those tags are only allowed in your Mojo.

s/

On 4/8/06, Stephane Nicoll <st...@gmail.com> wrote:
>
> Hi Christophe,
>
> Good to see that you're using maven in your organisation.
>
> Yes, it is possible to map complex types in Mojo. However, you need to pay
> attention to the following:
>
> - The ComplexObject needs to be public with a default public constructor
> and needs to be in the same package as your Mojo
> - Notation is a bit different, I would have a look to the maven2 EAR
> plugin [1] which has this kind of functionnality
>
> In any case, running mvn in debug will output what maven (plexus actually)
> is doing with your parameter regarding DI.
>
> A book is about to be released and it will contain a chapter about plugin
> development.
>
> Cheers,
> Stéphane
>
> [1] http://svn.apache.org/viewcvs.cgi/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/
> (see EarModule and subclasses)
>
>
>
> On 3/30/06, Christophe Grosjean <Christophe.Grosjean@arhs-developments.com
> > wrote:
>
> >  Hi,
> >
> >
> >
> > A question  about the configuration mappings… Does the mapping of Maven
> > project properties to Mojo fields also
> >
> > work for any complex objects used to configure the plugin?
> >
> >
> >
> > In other words, in the following code, will the 'project' field of the
> > ComplexObject parameter be assigned ?
> >
> >
> >
> >
> >
> >
> >
> > public class SomeMojo extends AbstractMojo {
> >
> >
> >
> >       /**
> >
> >       * @parameter
> >
> >       */
> >
> >       private ComplexObject complexObject;
> >
> >
> >
> > }
> >
> >
> >
> > public class ComplexObject {
> >
> >
> >
> >       /**
> >
> >      * The maven project.
> >
> > *
> >
> > * @parameter expression="${project}"
> >
> > * @required
> >
> > * @readonly
> >
> > */
> >
> >       private MavenProject project;
> >
> >
> >
> > }
> >
> >
> >
> > Thanks for your answer,
> >
> >
> >
> > Christophe
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> > For additional commands, e-mail: dev-help@maven.apache.org
> >
> >
>
>
> --
> .::You're welcome ::.
>



--
.::You're welcome ::.

Re: configuration mappings for complex objects

Posted by Stephane Nicoll <st...@gmail.com>.
Hi Christophe,

Good to see that you're using maven in your organisation.

Yes, it is possible to map complex types in Mojo. However, you need to pay
attention to the following:

- The ComplexObject needs to be public with a default public constructor and
needs to be in the same package as your Mojo
- Notation is a bit different, I would have a look to the maven2 EAR plugin
[1] which has this kind of functionnality

In any case, running mvn in debug will output what maven (plexus actually)
is doing with your parameter regarding DI.

A book is about to be released and it will contain a chapter about plugin
development.

Cheers,
Stéphane

[1]
http://svn.apache.org/viewcvs.cgi/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/(see
EarModule and subclasses)



On 3/30/06, Christophe Grosjean <Ch...@arhs-developments.com>
wrote:
>
>  Hi,
>
>
>
> A question  about the configuration mappings… Does the mapping of Maven
> project properties to Mojo fields also
>
> work for any complex objects used to configure the plugin?
>
>
>
> In other words, in the following code, will the 'project' field of the
> ComplexObject parameter be assigned ?
>
>
>
>
>
>
>
> public class SomeMojo extends AbstractMojo {
>
>
>
>       /**
>
>       * @parameter
>
>       */
>
>       private ComplexObject complexObject;
>
>
>
> }
>
>
>
> public class ComplexObject {
>
>
>
>       /**
>
>      * The maven project.
>
> *
>
> * @parameter expression="${project}"
>
> * @required
>
> * @readonly
>
> */
>
>       private MavenProject project;
>
>
>
> }
>
>
>
> Thanks for your answer,
>
>
>
> Christophe
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>


--
.::You're welcome ::.