You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Cristiano Gavião <cv...@gmail.com> on 2015/05/23 00:32:18 UTC

why the defaultValue is not being injected in @Parameter inside a complex parameter bean?

Hello,

I'm facing a problem and would like a help to figure it out.

I'm developing a mojo (maven 3.3) that contains the following:

@Parameter(required=true)
    private ManifestConfiguration manifest;

and in the bean (in the same package) I have:

@Parameter(defaultValue = "${project.name}")
    private String name;

What is happen is that the default value is not being injected into the
name field, when executing the mojo I'm getting null for it.

The strange is that for other values that I've set in a test POM they are
being injected properly.

Is this supposed to work, right?

thanks,

Cristiano

Re: why the defaultValue is not being injected in @Parameter inside a complex parameter bean?

Posted by Cristiano Gavião <cv...@gmail.com>.
Its true, I did a debug in maven code and found that it is not supported.

So the solution was to call the bean setters from the setters of the mojo.

A good thing is that at least the mojo.xml being generated by takari
lifecicle plugin is considering them and it is also being read by m2e at
eclipse IDE, so I can select the inner parameters using crtrl+space.

anyway, thank you Anton and Karl...

Cristiano

2015-05-23 5:33 GMT-03:00 Anton Tanasenko <at...@gmail.com>:

> Hi,
>
> @Parameter annotations are only supported in the mojo itself, not in any
> nested parameter beans.
>
> 2015-05-23 11:22 GMT+03:00 Karl Heinz Marbaise <kh...@gmx.de>:
>
> > Hi,
> >
> > On 5/23/15 12:32 AM, Cristiano Gavião wrote:
> >
> >> Hello,
> >>
> >> I'm facing a problem and would like a help to figure it out.
> >>
> >> I'm developing a mojo (maven 3.3) that contains the following:
> >>
> >> @Parameter(required=true)
> >>      private ManifestConfiguration manifest;
> >>
> >> and in the bean (in the same package) I have:
> >>
> >> @Parameter(defaultValue = "${project.name}")
> >>      private String name;
> >>
> >> What is happen is that the default value is not being injected into the
> >> name field, when executing the mojo I'm getting null for it.
> >>
> >
> > has the tag name being set in the project where you executing the plugin?
> >
> >
> > <project>
> >  ..
> >  <name>WhatEver</name>
> >  ..
> > </project>
> >
> >
> >> The strange is that for other values that I've set in a test POM they
> are
> >> being injected properly.
> >>
> >> Is this supposed to work, right?
> >>
> >
> > May be you can show the code or having it on github or bitbuchet so we
> can
> > take a look...
> >
> >
> >> thanks,
> >>
> >> Cristiano
> >>
> >>
> > Kind regards
> > Karl Heinz Marbaise
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
> >
> >
>
>
> --
> Regards,
> Anton.
>



-- 
"Tudo vale a pena se a alma não é pequena..."

Re: why the defaultValue is not being injected in @Parameter inside a complex parameter bean?

Posted by Anton Tanasenko <at...@gmail.com>.
Hi,

@Parameter annotations are only supported in the mojo itself, not in any
nested parameter beans.

2015-05-23 11:22 GMT+03:00 Karl Heinz Marbaise <kh...@gmx.de>:

> Hi,
>
> On 5/23/15 12:32 AM, Cristiano Gavião wrote:
>
>> Hello,
>>
>> I'm facing a problem and would like a help to figure it out.
>>
>> I'm developing a mojo (maven 3.3) that contains the following:
>>
>> @Parameter(required=true)
>>      private ManifestConfiguration manifest;
>>
>> and in the bean (in the same package) I have:
>>
>> @Parameter(defaultValue = "${project.name}")
>>      private String name;
>>
>> What is happen is that the default value is not being injected into the
>> name field, when executing the mojo I'm getting null for it.
>>
>
> has the tag name being set in the project where you executing the plugin?
>
>
> <project>
>  ..
>  <name>WhatEver</name>
>  ..
> </project>
>
>
>> The strange is that for other values that I've set in a test POM they are
>> being injected properly.
>>
>> Is this supposed to work, right?
>>
>
> May be you can show the code or having it on github or bitbuchet so we can
> take a look...
>
>
>> thanks,
>>
>> Cristiano
>>
>>
> Kind regards
> Karl Heinz Marbaise
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>


-- 
Regards,
Anton.

Re: why the defaultValue is not being injected in @Parameter inside a complex parameter bean?

Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi,

On 5/23/15 12:32 AM, Cristiano Gavião wrote:
> Hello,
>
> I'm facing a problem and would like a help to figure it out.
>
> I'm developing a mojo (maven 3.3) that contains the following:
>
> @Parameter(required=true)
>      private ManifestConfiguration manifest;
>
> and in the bean (in the same package) I have:
>
> @Parameter(defaultValue = "${project.name}")
>      private String name;
>
> What is happen is that the default value is not being injected into the
> name field, when executing the mojo I'm getting null for it.

has the tag name being set in the project where you executing the plugin?


<project>
  ..
  <name>WhatEver</name>
  ..
</project>

>
> The strange is that for other values that I've set in a test POM they are
> being injected properly.
>
> Is this supposed to work, right?

May be you can show the code or having it on github or bitbuchet so we 
can take a look...

>
> thanks,
>
> Cristiano
>

Kind regards
Karl Heinz Marbaise

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