Discussion:
Passing Maven Variable as a system property to the tests
Binil Thomas
2006-11-09 08:59:02 UTC
Permalink
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.
Dan Tran
2006-11-09 10:39:14 UTC
Permalink
${basedir}/target could be the work around

-D
Post by Binil Thomas
Hi all,
The Surefire plugin documentation
(
http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html
)
[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
--
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.
---------------------------------------------------------------------
Binil Thomas
2006-11-13 12:29:52 UTC
Permalink
Post by Dan Tran
${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.
Dan Tran
2006-11-13 16:52:27 UTC
Permalink
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
Post by Binil Thomas
Post by Dan Tran
${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
--
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.
---------------------------------------------------------------------
diroussel
2006-11-15 11:58:21 UTC
Permalink
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
Post by Binil Thomas
Hi all,
The Surefire plugin documentation
(http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html)
[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.
Loading...