You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Binil Thomas <bi...@gmail.com> on 2006/11/09 09:59:02 UTC

Passing Maven Variable as a system property to the tests

Hi all,

The Surefire plugin documentation
(http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html)
mentions:

[snip]
Take note that String valued properties can only be passed as system
properties. Any attempt to pass any other maven variable type (i.e. List or
a URL variable) will cause the variable expression to be passed literally
(unevaluated).
[/snip]

In my test, I need to get the value of the maven variable
${project.build.outputDirectory} as a String (I need to generate some file
at the end of the test, and I need to create this file in
${project.build.outputDirectory). How do I force the evaluation of the
variable first, and then pass it to the test a system property?

This was discussed in the thread
http://www.nabble.com/Passing-maven-variables-as-system-properties-tf1256766s177.html#a3332659,
but not properly answered.

Thanks,
Binil
-- 
View this message in context: http://www.nabble.com/Passing-Maven-Variable-as-a-system-property-to-the-tests-tf2600462s177.html#a7254591
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: Passing Maven Variable as a system property to the tests

Posted by Dan Tran <da...@gmail.com>.
I think you got stucked with this, just like me.

File a jira againt surefire plugin to support Map as additional
configuration
( beside Properties) , that will solve all the problems.

-D



On 11/13/06, Binil Thomas <bi...@gmail.com> wrote:
>
>
>
> dan tran wrote:
> >
> > ${basedir}/target could be the work around
> >
> > -D
> >
>
> I did not try this, but by replacing ${project.build.outputDirectory} with
> ${basedir}/target we end up shifting the problem of evaluating
> ${project.build.outputDirectory} with one of evaluating ${basedir} rt?
> Also, using File f = new File("target") will get my the target directory,
> but I wanted my test not to break if someone configures the output
> directory
> to be something other than target.
>
> Thanks,
> Binil
> --
> View this message in context:
> http://www.nabble.com/Passing-Maven-Variable-as-a-system-property-to-the-tests-tf2600462s177.html#a7316114
> 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: Passing Maven Variable as a system property to the tests

Posted by Binil Thomas <bi...@gmail.com>.

dan tran wrote:
> 
> ${basedir}/target could be the work around
> 
> -D
> 

I did not try this, but by replacing ${project.build.outputDirectory} with
${basedir}/target we end up shifting the problem of evaluating
${project.build.outputDirectory} with one of evaluating ${basedir} rt?
Also, using File f = new File("target") will get my the target directory,
but I wanted my test not to break if someone configures the output directory
to be something other than target.

Thanks,
Binil
-- 
View this message in context: http://www.nabble.com/Passing-Maven-Variable-as-a-system-property-to-the-tests-tf2600462s177.html#a7316114
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: Passing Maven Variable as a system property to the tests

Posted by Dan Tran <da...@gmail.com>.
${basedir}/target could be the work around

-D


On 11/9/06, Binil Thomas <bi...@gmail.com> wrote:
>
>
> Hi all,
>
> The Surefire plugin documentation
> (
> http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html
> )
> mentions:
>
> [snip]
> Take note that String valued properties can only be passed as system
> properties. Any attempt to pass any other maven variable type (i.e. List
> or
> a URL variable) will cause the variable expression to be passed literally
> (unevaluated).
> [/snip]
>
> In my test, I need to get the value of the maven variable
> ${project.build.outputDirectory} as a String (I need to generate some file
> at the end of the test, and I need to create this file in
> ${project.build.outputDirectory). How do I force the evaluation of the
> variable first, and then pass it to the test a system property?
>
> This was discussed in the thread
>
> http://www.nabble.com/Passing-maven-variables-as-system-properties-tf1256766s177.html#a3332659
> ,
> but not properly answered.
>
> Thanks,
> Binil
> --
> View this message in context:
> http://www.nabble.com/Passing-Maven-Variable-as-a-system-property-to-the-tests-tf2600462s177.html#a7254591
> 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: Passing Maven Variable as a system property to the tests

Posted by diroussel <na...@diroussel.xsmail.com>.
I'm just guessing here, but since only string properties are passed you need
to define a string property which is based on the non-string property. 
Perhaps you could define:
outDir=${project.build.outputDirectory}

Perhaps you could define this in a profile, or in project.properties or
something?

David


Binil Thomas wrote:
> 
> Hi all,
> 
> The Surefire plugin documentation
> (http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html)
> mentions:
> 
> [snip]
> Take note that String valued properties can only be passed as system
> properties. Any attempt to pass any other maven variable type (i.e. List
> or a URL variable) will cause the variable expression to be passed
> literally (unevaluated).
> [/snip]
> 
> In my test, I need to get the value of the maven variable
> ${project.build.outputDirectory} as a String (I need to generate some file
> at the end of the test, and I need to create this file in
> ${project.build.outputDirectory). How do I force the evaluation of the
> variable first, and then pass it to the test a system property?
> 
> This was discussed in the thread
> http://www.nabble.com/Passing-maven-variables-as-system-properties-tf1256766s177.html#a3332659,
> but not properly answered.
> 
> Thanks,
> Binil
> 

-- 
View this message in context: http://www.nabble.com/Passing-Maven-Variable-as-a-system-property-to-the-tests-tf2600462s177.html#a7356447
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