maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Søren Krogh Neigaard <Soeren.Krogh.Neiga...@systematic.com>
Subject RE: Read properties from pom.xml from Java
Date Fri, 05 Feb 2010 08:50:04 GMT
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
soeren.krogh.neigaard@systematic.com
www.systematic.com


-----Original Message-----
From: Martin Höller [mailto:martin@xss.co.at] 
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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Mime
View raw message