You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Stanley Lee <ma...@gmail.com> on 2008/03/26 19:23:19 UTC

How to inject configuration parameter through command line?

For a plugin having configuration like
<configuration>
  <param1>foo</param1>
  <param2>bar</param2>
</configuration>

Is it possible to set/change/override parameters through command-line? I
tried -DpluginName.param1=value1, but doesn't work. Any suggestions?

Thanks!

Re: How to inject configuration parameter through command line?

Posted by Damian Carrillo <da...@gmail.com>.
On Wed, Mar 26, 2008 at 1:23 PM, Stanley Lee <ma...@gmail.com> wrote:
> For a plugin having configuration like
>  <configuration>
>   <param1>foo</param1>
>   <param2>bar</param2>
>  </configuration>
>
>  Is it possible to set/change/override parameters through command-line? I
>  tried -DpluginName.param1=value1, but doesn't work. Any suggestions?
>
>  Thanks!
>

If you use replacement variables like so:

<configuration>
  <param1>${value1}</param1>
  <param2>${value2}</param2>
</configuration>

you can then supply the properties on the command line like so:

$ mvn -Dvalue1=willy -Dvalue2=wonka

or you can even introduce those properties into the pom like this here:

<project>
  ...
  <properties>
    <value1>willy</value1>
    <value2>wonka</value2>
  </properties>
  ...
</project>

-- 
Damian Carrillo

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


Re: How to inject configuration parameter through command line?

Posted by Stanley Lee <ma...@gmail.com>.
Thanks! Simon and Damian,

That's exactly what I want.

Best

Stan

On Wed, Mar 26, 2008 at 2:55 PM, simon <si...@chello.at> wrote:

>
> On Wed, 2008-03-26 at 14:23 -0400, Stanley Lee wrote:
> > For a plugin having configuration like
> > <configuration>
> >   <param1>foo</param1>
> >   <param2>bar</param2>
> > </configuration>
> >
> > Is it possible to set/change/override parameters through command-line? I
> > tried -DpluginName.param1=value1, but doesn't work. Any suggestions?
>
>  <configuration>
>   <param1>${val1}</param1>
>   <param2>${val2}</param2>
>  </configuration>
>
>  <properties>
>   <val1>foo</val1>
>   <val2>bar</val2>
>  </properties>
>
>
> Then foo and bar are the defaults, but
>  -Dval1=baz
> should override val1.
>
> Regards,
> Simon
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: How to inject configuration parameter through command line?

Posted by simon <si...@chello.at>.
On Wed, 2008-03-26 at 14:23 -0400, Stanley Lee wrote:
> For a plugin having configuration like
> <configuration>
>   <param1>foo</param1>
>   <param2>bar</param2>
> </configuration>
> 
> Is it possible to set/change/override parameters through command-line? I
> tried -DpluginName.param1=value1, but doesn't work. Any suggestions?

 <configuration>
   <param1>${val1}</param1>
   <param2>${val2}</param2>
 </configuration>

 <properties>
   <val1>foo</val1>
   <val2>bar</val2>
 </properties>


Then foo and bar are the defaults, but 
  -Dval1=baz
should override val1.

Regards,
Simon



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