You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Victor Calvello <vc...@gmail.com> on 2011/01/18 00:28:18 UTC

Overriding properties from command line arguments

Hi guys!

I have a problem with something I took for granted until now :P
What I need is to override a property value by passing a new value from the
command line.
For example, I have something like this in my pom.xml:
...
<properties>
   <myProp>myDefault</myProp>
</properties>
...
and then I run a goal with some arguments...let's say... mvn
help:effective-pom -DmyProp=myValue
So, what I was expecting was to override myDefault with myValue but that's
not happening.

Is that the correct behavior? If that's the way it works, how can I do what
I want? (maybe profiles?)

Thanks in advance,
Vic

Re: Overriding properties from command line arguments

Posted by Anders Hammar <an...@hammar.net>.
I think you're confusing Maven properties and system properties. myProp as
defined within the properties section is a Maven property. You cannot
override that through a Java system property (-DmyProp).
However, in your POM you could reference your myProp property through
${myProp}. If you execute Maven through "mvn install -DmyProp=blabla", the
${myProp} reference should pick up the Java system property you define
('blabla') instead of the Maven property defined in the POM.

/Anders
On Tue, Jan 18, 2011 at 00:28, Victor Calvello <vc...@gmail.com> wrote:

> Hi guys!
>
> I have a problem with something I took for granted until now :P
> What I need is to override a property value by passing a new value from the
> command line.
> For example, I have something like this in my pom.xml:
> ...
> <properties>
>   <myProp>myDefault</myProp>
> </properties>
> ...
> and then I run a goal with some arguments...let's say... mvn
> help:effective-pom -DmyProp=myValue
> So, what I was expecting was to override myDefault with myValue but that's
> not happening.
>
> Is that the correct behavior? If that's the way it works, how can I do what
> I want? (maybe profiles?)
>
> Thanks in advance,
> Vic
>