James Russo wrote at Dienstag, 8. September 2009 04:33:

> Hello,
> 
>     In my ~/.m2/settings.xml I have:
> 
> <settings>
>   <profiles>
>     <profile>
>       <id>setup_database_password</id>
>       <activation>
>         <activeByDefault>true</activeByDefault>
>       </activation>
>       <properties>
>         <environment.type>dev</environment.type>
>         <database.password>secret</database.password>
>       </properties>
>     </profile>
>   </profiles>
> </settings>
> 
> 
> So, this should set environment.type to "dev".

Not necessarily. "activeByDefault" means active, if no other profile has
been specified.

> Then in one of my sub-projects pom (beneath parent, not sure that
> matters though) I have this:
> 
>         <profiles>
>                 <profile>
>                         <id>setup_database_properties</id>
>                         <activation>
>       <property>
>           <name>environment.type</name>
>           <value>dev</value>
>         </property>
> 
>                         </activation>
>                         <properties>
>                                 
> <database.driverClassName>com.mysql.jdbc.Driver</database.driverClassName>
>                                 
> <database.url>jdbc:postgresql://localhost/dbname</database.url>
>                                 <database.user>dbuser</database.user>
>                         </properties>
>                 </profile>
>         </profiles>
> 
> However, when I run help:active-profiles I am only seeing the one
> profile (from ~/.m2/settings.xml) activated? I would expect that the
> profile in
> my pom.xml file would be activated since the environment value is set.

No, profiles cannot be activated by properties set in other profiles. It is 
a limitation of the profile mechanism.
 
> If I specify -Denvironment.type=dev on the command line, it works as
> expected?

No, because then the profile in settings.xml is no longer "by default" as
explained above.

> If I change activation to !environment it works as well. Seems 
> like it is just not
> picking up properties added by ~/.m2/settings.xml.

Simply activate both profiles when "environment.type" is set to "dev".

> thanks for any help or suggestions on how I might make this work.
> Obviously my goal is to simple keep database password out of svn and the
> project.

Why do you set it in a profile at all? Your settings.xml is private to you.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to