Im getting grey hairs :)
I tried with this in my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<systemPropertyVariables>
<db.driver>oracle.jdbc.OracleDriver</db.driver>
<db.url>${database.url}</db.url>
<db.username>${database.username}</db.username>
<db.password>${database.password}</db.password>
</systemPropertyVariables>
</configuration>
</plugin>
And this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
<configuration>
<systemPropertyVariables>
<db.driver>oracle.jdbc.OracleDriver</db.driver>
<db.url>${settings.database.url}</db.url>
<db.username>${settings.database.username}</db.username>
<db.password>${settings.database.password}</db.password>
</systemPropertyVariables>
</configuration>
</plugin>
I also tried with this:
<properties>
<db.driver>oracle.jdbc.OracleDriver</db.driver>
<db.url>${settings.database.url}</db.url>
...
Al of my attempts gives me null :(
Med venlig hilsen / Kind regards
Søren Krogh Neigaard
Systems Engineer
Søren Frichs Vej 39, 8000 Aarhus C
Denmark
Mobile +4541965252
[email protected]
www.systematic.com
-----Original Message-----
From: Martin Höller [mailto:[email protected]]
Sent: 5. februar 2010 09:00
To: Maven Users List
Subject: Re: Read properties from pom.xml from Java
Hi!
Am Freitag, 5. Februar 2010 08:41:02 schrieb Søren Krogh Neigaard:
> I have this in my settings.xml
>
> <settings>
> <profiles>
> <profile>
> <activation>
> <activeByDefault>true</activeByDefault>
> </activation>
> <properties>
> <database.driver>oracle.jdbc.driver.OracleDriver</database.driver>
> <database.url>jdbc:oracle:thin:@myhome:1521:orcl</database.url>
> <database.username>foo</database.username>
> <database.password>bar</database.password>
> </properties>
> </profile>
> </profiles>
> </settings>
>
> And I have tried with these in my pom.xml:
>
> <properties>
> <db.driver>oracle.jdbc.OracleDriver</db.driver>
> <db.url>${database.url}</db.url>
> <db.username>${database.username}</db.username>
> <db.password>${database.password}</db.password>
> </properties>
>
> And this:
>
> <properties>
> <database.driver>oracle.jdbc.OracleDriver</database.driver>
> <database.url>dummy</database.url>
> <database.username>dummy</database.username>
> <database.password>dummy</database.password>
> </properties>
>
> I still get null with System.getProperty
Sorry, I missed one important point: you have to "export" your properties to
become system properties. Do this by configuring the surefire plugin as
described here:
http://maven.apache.org/plugins/maven-surefire-plugin/examples/system-properties.html
I just double checked it, this way it works.
hth,
- martin
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]