I have been looking for a solution too, but I didn't find one. Even in ANT,
if you define a variable, you can reference that variable from within the
ant script and from JAVA (JUnit tests) gu using the
System.getProperty("whatever_name...");
In Maven my workaround was to create a profile in settings.xml, and I
defined my own variables there. Then I've applied a filter to a given
property file and by doing that maven plugs in the values defined in
settings.xml. The end product is to have a property file that contains the
name=value pair that I want, and the only way that I can access that
information from JAVA is to define that file as a property file.
I know this thread has been quite for quite a while, but is there a better
way to achieve that?
thanks,
alex
mmistroni wrote:
>
> Hello,
> not sure about maven2, but in maven1 i was using following (espeically
> for
> junit)
>
> maven.junit.sysproperties=db.url db.user db.password db.driver db.seedfile
> maven.final.name
>
>
> is there a similar thing for maven2?
>
> rgds
> marco
>
>
> On 3/11/06, Simon Kitching <[EMAIL PROTECTED]> wrote:
>>
>> Thanks Hermod, you've helped me make *some* progress.
>>
>> It appears the problem is that the variable name I'm using is not
>> recognised, so the original expression is passed unaltered.
>>
>> ${pom.name} works fine for example (expanded)
>>
>> However none of the following work:
>> ${project.build.outputDirectory}
>> ${project.build.directory}
>> ${pom.build.directory}
>>
>> Anyone know what the magic variable name is for passing the
>> outputDirectory (ie dir where main java src gets compiled to) to the
>> unit tests as a system property?
>>
>> Thanks,
>>
>> Simon
>>
>> On Fri, 2006-03-10 at 11:47 +0100, [EMAIL PROTECTED] wrote:
>> > Hi
>> >
>> > Try project.build.directory
>> >
>> > Hermod
>> >
>> > -----Original Message-----
>> > From: Simon Kitching [mailto:[EMAIL PROTECTED]
>> > Sent: Friday, March 10, 2006 3:53 AM
>> > To: [email protected]
>> > Subject: Passing maven variables as system properties
>> >
>> >
>> > Hi,
>> >
>> > I'm trying to store some maven vars into system properties so I can
>> > access them from unit test code:
>> >
>> > <plugin>
>> > <groupId>org.apache.maven.plugins</groupId>
>> > <artifactId>maven-surefire-plugin</artifactId>
>> > <configuration>
>> > <systemProperties>
>> > <property>
>> > <name>core-static</name>
>> > <value>${project.build.outputDirectory}/</value>
>> > </property>
>> > <property>
>> > <name>core-static-tests</name>
>> > <value>${project.build.testOutputDirectory}/</value>
>> > </property>
>> > </systemProperties>
>> > </configuration>
>> > </plugin>
>> > </plugins>
>> >
>> > However the value of
>> > System.getProperty("core-static")
>> > is literally "${project.build.outputDirectory}", not the expanded
>> value.
>> >
>> > Does anyone know how I can pass the value of this expression?
>> >
>> > Thanks,
>> >
>> > Simon
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> >
>> >
>> > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>> * *
>> >
>> > This email with attachments is solely for the use of the individual or
>> > entity to whom it is addressed. Please also be aware that DnB NOR
>> cannot
>> > accept any payment orders or other legally binding correspondence with
>> > customers as a part of an email.
>> >
>> > This email message has been virus checked by the virus programs used
>> > in the DnB NOR Group.
>> >
>> > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
>> * *
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Passing-maven-variables-as-system-properties-tp3332659s177p16508273.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]