You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Igor Romanov <ig...@jlctech.ru> on 2008/02/07 22:55:02 UTC
How to override POM properties from CLI
Hello,
I have properties in a POM file I need to be able to override with
command line –D option,
to run build in a different environments. How can I do this? Simple
example below doesn't work
as I expect it should, i.e. test.txt will contain FALSE after running
c:\temp\module> mvn -Dtest.result=PASS process-test-resources
What am I doing in a wrong way?
Sample project:
----------------------
module/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<test.result>FAIL</test.result>
</properties>
<build>
<testResources>
<testResource>
<directory>${basedir}/src/test/resources</directory>
<filtering>true</filtering>
<includes>
<include>*.txt</include>
</includes>
</testResource>
</testResources>
</build>
</project>
module/src/test/resources/test.txt
This test ${test.result}
--
Igor.
Re: How to override POM properties from CLI
Posted by Arnaud HERITIER <ah...@gmail.com>.
I already noticed this problem and I think it is a bug.
I don't know if an issue is open.
Arnaud
On Thu, Feb 21, 2008 at 7:43 AM, avalon <av...@friendofpooh.com> wrote:
>
> That's ugly!
>
> If one can't override properties then for example testing against
> different
> databases from an automated build system is a real pain. So first one
> needs
> to create profiles for all supported databases to be able to retrieve the
> jdbc driver. Then how many additional profiles for all combinations one
> needs? And then for developers' local runs?
>
> Please, anybody aware how to override pom properties?
>
>
> Wayne Fay wrote:
> >
> > You should put the properties in different profiles, and then specify
> > which profile using -Penv1 when running Maven.
> >
> > Wayne
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-to-override-POM-properties-from-CLI-tp15344487s177p15605671.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
..........................................................
Arnaud HERITIER
..........................................................
OCTO Technology - aheritier AT octo DOT com
www.octo.com | blog.octo.com
..........................................................
ASF - aheritier AT apache DOT org
www.apache.org | maven.apache.org
...........................................................
Re: How to override POM properties from CLI
Posted by avalon <av...@friendofpooh.com>.
That's ugly!
If one can't override properties then for example testing against different
databases from an automated build system is a real pain. So first one needs
to create profiles for all supported databases to be able to retrieve the
jdbc driver. Then how many additional profiles for all combinations one
needs? And then for developers' local runs?
Please, anybody aware how to override pom properties?
Wayne Fay wrote:
>
> You should put the properties in different profiles, and then specify
> which profile using -Penv1 when running Maven.
>
> Wayne
>
--
View this message in context: http://www.nabble.com/How-to-override-POM-properties-from-CLI-tp15344487s177p15605671.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How to override POM properties from CLI
Posted by avalon <av...@friendofpooh.com>.
Paul Gier wrote:
>
> This seems to work ok for me. I tried it locally and my profile
> properties
> override my pom properties, and cli props defined with -D override both
> pom and
> profile properties. I tried with maven 2.0.6 and 2.0.8.
> Can you attach a small zipped project to a jira issue that reproduces the
> problem?
>
http://jira.codehaus.org/browse/MNG-3417
--
View this message in context: http://www.nabble.com/How-to-override-POM-properties-from-CLI-tp15344487s177p15633399.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How to override POM properties from CLI
Posted by Paul Gier <pg...@redhat.com>.
This seems to work ok for me. I tried it locally and my profile properties
override my pom properties, and cli props defined with -D override both pom and
profile properties. I tried with maven 2.0.6 and 2.0.8.
Can you attach a small zipped project to a jira issue that reproduces the problem?
Igor Romanov wrote:
> Thank you for reply.
> Are you saying that properties specified in POM can not be overridden with
> -D option?
>
> Igor
>
>
> Wayne Fay wrote:
>> You should put the properties in different profiles, and then specify
>> which profile using -Penv1 when running Maven.
>>
>> Wayne
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How to override POM properties from CLI
Posted by Igor Romanov <Ig...@jlctech.com>.
Thank you for reply.
Are you saying that properties specified in POM can not be overridden with
-D option?
Igor
Wayne Fay wrote:
>
> You should put the properties in different profiles, and then specify
> which profile using -Penv1 when running Maven.
>
> Wayne
>
--
View this message in context: http://www.nabble.com/How-to-override-POM-properties-from-CLI-tp15344487s177p15347745.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: How to override POM properties from CLI
Posted by Wayne Fay <wa...@gmail.com>.
You should put the properties in different profiles, and then specify
which profile using -Penv1 when running Maven.
Wayne
On 2/7/08, Igor Romanov <ig...@jlctech.ru> wrote:
> Hello,
>
> I have properties in a POM file I need to be able to override with
> command line –D option,
> to run build in a different environments. How can I do this? Simple
> example below doesn't work
> as I expect it should, i.e. test.txt will contain FALSE after running
>
> c:\temp\module> mvn -Dtest.result=PASS process-test-resources
>
> What am I doing in a wrong way?
>
> Sample project:
> ----------------------
>
> module/pom.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project>
> <modelVersion>4.0.0</modelVersion>
> <groupId>com.test</groupId>
> <artifactId>test</artifactId>
> <version>1.0</version>
> <packaging>jar</packaging>
>
> <properties>
> <test.result>FAIL</test.result>
> </properties>
>
> <build>
> <testResources>
> <testResource>
> <directory>${basedir}/src/test/resources</directory>
> <filtering>true</filtering>
> <includes>
> <include>*.txt</include>
> </includes>
> </testResource>
> </testResources>
> </build>
> </project>
>
> module/src/test/resources/test.txt
>
> This test ${test.result}
>
> --
> Igor.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org