You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Geir Gullestad Pettersen <ge...@gmail.com> on 2011/04/15 10:37:33 UTC

Setting properties in pom.xml from command line

Hi,

Is it possible to inject properties into pom.xml from the command line at
runtime?

consider this dependency:

    <dependencies>
        <dependency>
            <groupId>mygroup</groupId>
            <artifactId>myartifact</artifactId>
            <version>${mygroup-myartifact.version}</version>
            <type>war</type>
        </dependency>
    </dependencies>

${mygroup-myartifact.version} can of course be set in the <properties> tag,
but I need to be able to change the version number without changing pom.xml.
This should peferrably be done from command line - is there a way to set
properties from commandline?

Thanks,
Geir

Re: Setting properties in pom.xml from command line

Posted by Benson Margulies <bi...@gmail.com>.
Anders,

What other suggestion do you have for testing that a something works
with multiple versions of something else?

I completely agree that running 'install' let alone 'deploy' with a
profile that changes a version is a really bad idea. But it's an
effective mechanism for compatibility testing.

/benson


On Fri, Apr 15, 2011 at 6:33 AM, Anders Hammar <an...@hammar.net> wrote:
> Yes, but I still don't think this is a good idea for dependencies. What will
> happen is that the dependency declared in the pom being deploy is not what
> was used during build. Can lead to strange things IMO.
>
> /Anders
>
> On Fri, Apr 15, 2011 at 12:14, Kristian Rosenvold <
> kristian.rosenvold@gmail.com> wrote:
>
>>
>> The trick is to give the artifact a *default* version in properties so you
>> can override from the command line but still build without any command line
>> options;
>>
>> <properties>
>> <mygroup-myartifact.version>1.1</mygroup-myartifact.version>
>> <properties>
>>
>>
>> Then you can build with  -Dmygroup-myartifact.version=1.2-SNAPSHOT
>>
>>
>> Kristian
>>
>> Den 15.04.2011 11:16, skrev Anders Hammar:
>>
>>  Yes, it is. "-Dmygroup-myartifact.version=xxx"
>>>
>>> However, for your example it would be a very bad thing as your pom will
>>> not
>>> be consumable by any client.
>>>
>>> /Anders
>>>
>>> On Fri, Apr 15, 2011 at 10:37, Geir Gullestad Pettersen<geirgp@gmail.com
>>> >wrote:
>>>
>>>  Hi,
>>>>
>>>> Is it possible to inject properties into pom.xml from the command line at
>>>> runtime?
>>>>
>>>> consider this dependency:
>>>>
>>>>    <dependencies>
>>>>        <dependency>
>>>>            <groupId>mygroup</groupId>
>>>>            <artifactId>myartifact</artifactId>
>>>>            <version>${mygroup-myartifact.version}</version>
>>>>            <type>war</type>
>>>>        </dependency>
>>>>    </dependencies>
>>>>
>>>> ${mygroup-myartifact.version} can of course be set in the<properties>
>>>>  tag,
>>>> but I need to be able to change the version number without changing
>>>> pom.xml.
>>>> This should peferrably be done from command line - is there a way to set
>>>> properties from commandline?
>>>>
>>>> Thanks,
>>>> Geir
>>>>
>>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>

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


Re: Setting properties in pom.xml from command line

Posted by Anders Hammar <an...@hammar.net>.
Yes, but I still don't think this is a good idea for dependencies. What will
happen is that the dependency declared in the pom being deploy is not what
was used during build. Can lead to strange things IMO.

/Anders

On Fri, Apr 15, 2011 at 12:14, Kristian Rosenvold <
kristian.rosenvold@gmail.com> wrote:

>
> The trick is to give the artifact a *default* version in properties so you
> can override from the command line but still build without any command line
> options;
>
> <properties>
> <mygroup-myartifact.version>1.1</mygroup-myartifact.version>
> <properties>
>
>
> Then you can build with  -Dmygroup-myartifact.version=1.2-SNAPSHOT
>
>
> Kristian
>
> Den 15.04.2011 11:16, skrev Anders Hammar:
>
>  Yes, it is. "-Dmygroup-myartifact.version=xxx"
>>
>> However, for your example it would be a very bad thing as your pom will
>> not
>> be consumable by any client.
>>
>> /Anders
>>
>> On Fri, Apr 15, 2011 at 10:37, Geir Gullestad Pettersen<geirgp@gmail.com
>> >wrote:
>>
>>  Hi,
>>>
>>> Is it possible to inject properties into pom.xml from the command line at
>>> runtime?
>>>
>>> consider this dependency:
>>>
>>>    <dependencies>
>>>        <dependency>
>>>            <groupId>mygroup</groupId>
>>>            <artifactId>myartifact</artifactId>
>>>            <version>${mygroup-myartifact.version}</version>
>>>            <type>war</type>
>>>        </dependency>
>>>    </dependencies>
>>>
>>> ${mygroup-myartifact.version} can of course be set in the<properties>
>>>  tag,
>>> but I need to be able to change the version number without changing
>>> pom.xml.
>>> This should peferrably be done from command line - is there a way to set
>>> properties from commandline?
>>>
>>> Thanks,
>>> Geir
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Setting properties in pom.xml from command line

Posted by Kristian Rosenvold <kr...@gmail.com>.
The trick is to give the artifact a *default* version in properties so 
you can override from the command line but still build without any 
command line options;

<properties>
<mygroup-myartifact.version>1.1</mygroup-myartifact.version>
<properties>


Then you can build with  -Dmygroup-myartifact.version=1.2-SNAPSHOT


Kristian

Den 15.04.2011 11:16, skrev Anders Hammar:
> Yes, it is. "-Dmygroup-myartifact.version=xxx"
>
> However, for your example it would be a very bad thing as your pom will not
> be consumable by any client.
>
> /Anders
>
> On Fri, Apr 15, 2011 at 10:37, Geir Gullestad Pettersen<ge...@gmail.com>wrote:
>
>> Hi,
>>
>> Is it possible to inject properties into pom.xml from the command line at
>> runtime?
>>
>> consider this dependency:
>>
>>     <dependencies>
>>         <dependency>
>>             <groupId>mygroup</groupId>
>>             <artifactId>myartifact</artifactId>
>>             <version>${mygroup-myartifact.version}</version>
>>             <type>war</type>
>>         </dependency>
>>     </dependencies>
>>
>> ${mygroup-myartifact.version} can of course be set in the<properties>  tag,
>> but I need to be able to change the version number without changing
>> pom.xml.
>> This should peferrably be done from command line - is there a way to set
>> properties from commandline?
>>
>> Thanks,
>> Geir
>>


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


Re: Setting properties in pom.xml from command line

Posted by Anders Hammar <an...@hammar.net>.
Yes, it is. "-Dmygroup-myartifact.version=xxx"

However, for your example it would be a very bad thing as your pom will not
be consumable by any client.

/Anders

On Fri, Apr 15, 2011 at 10:37, Geir Gullestad Pettersen <ge...@gmail.com>wrote:

> Hi,
>
> Is it possible to inject properties into pom.xml from the command line at
> runtime?
>
> consider this dependency:
>
>    <dependencies>
>        <dependency>
>            <groupId>mygroup</groupId>
>            <artifactId>myartifact</artifactId>
>            <version>${mygroup-myartifact.version}</version>
>            <type>war</type>
>        </dependency>
>    </dependencies>
>
> ${mygroup-myartifact.version} can of course be set in the <properties> tag,
> but I need to be able to change the version number without changing
> pom.xml.
> This should peferrably be done from command line - is there a way to set
> properties from commandline?
>
> Thanks,
> Geir
>