Anyone? :-) Thanks, Eric
> -----Ursprüngliche Nachricht----- > Von: Lewis, Eric [mailto:[email protected]] > Gesendet: Mittwoch, 18. Februar 2009 17:25 > An: Maven Users List > Betreff: Confused about selecting a profile from profiles.xml > > Hi > > I'm confused about how profiles.xml files work. > > Here's my case: > > I want to filter a JEE datasource file depending on the > target platform > (development, integration etc.). For this I've defined all > those target > platforms as Maven profiles with their specific properties in > my Master > POM: > > <profiles> > <profile> > <id>development</id> > <properties> > > <datasource.esv.application.url>dev</datasource.esv.application.url> > > <datasource.esv.application.user>dev_user</datasource.esv.appl ication.us > er> > > <datasource.esv.application.password>dev_pw</datasource.esv.ap plication. > password> > </properties> > </profile> > <profile> > <id>integration</id> > <properties> > > <datasource.esv.application.url>int</datasource.esv.application.url> > > <datasource.esv.application.user>int_user</datasource.esv.appl ication.us > er> > > <datasource.esv.application.password>int_pw</datasource.esv.ap plication. > password> > </properties> > </profile> > ... (more profiles) > </profiles> > > Running this Master POM with > mvn help:active-profiles help:effective-pom -Pintegration > shows the following > > The following profiles are active: > > - local (source: pom) > - integration (source: pom) > - local (source: settings.xml) > - integration (source: settings.xml) > - local (source: settings.xml) > > (my default profile in settings.xml is 'local') > > and > > <datasource.esv.application.password>int_pw</datasource.esv.ap plication. > password> > > <datasource.esv.application.url>int</datasource.esv.application.url> > > <datasource.esv.application.user>int_user</datasource.esv.appl ication.us > er> > > > So, everything's ok. > > Now, I'd like to outsource the datasource configuration into its own > profiles.xml file, because the team for the production DBs > doesn't want > us to know the passwords for staging and production DBs. > > So, my idea is to have the profiles for developers (local, > development, > integration) already filled in the profiles.xml, but to leave the > profiles for the production team (staging, production) blank in that > file. Then they can fill in the configuration locally and run a local > build which creates the configuration for those DBs, which they then > deploy. > > Ok, so I create a profiles.xml (cutting and pasting from the > Master POM) > and fill in everything, just to test: > > <?xml version="1.0" encoding="UTF-8"?> > <profiles> > <profile> > <id>local</id> > <properties> > > <datasource.esv.application.url>loc</datasource.esv.application.url> > > <datasource.esv.application.user>loc_user</datasource.esv.appl ication.us > er> > > <datasource.esv.application.password>loc_pw</datasource.esv.ap plication. > password> > </properties> > </profile> > <profile> > <id>development</id> > <properties> > > <datasource.esv.application.url>dev</datasource.esv.application.url> > > <datasource.esv.application.user>dev_user</datasource.esv.appl ication.us > er> > > <datasource.esv.application.password>dev_pw</datasource.esv.ap plication. > password> > </properties> > </profile> > <profile> > <id>integration</id> > <properties> > > <datasource.esv.application.url>int</datasource.esv.application.url> > > <datasource.esv.application.user>int_user</datasource.esv.appl ication.us > er> > > <datasource.esv.application.password>int_pw</datasource.esv.ap plication. > password> > </properties> > </profile> > <profile> > <id>staging</id> > <properties> > > <datasource.esv.application.url>sta</datasource.esv.application.url> > > <datasource.esv.application.user>sta_user</datasource.esv.appl ication.us > er> > > <datasource.esv.application.password>sta_pw</datasource.esv.ap plication. > password> > </properties> > </profile> > <profile> > <id>production</id> > <properties> > > <datasource.esv.application.url>pro</datasource.esv.application.url> > > <datasource.esv.application.user>pro_user</datasource.esv.appl ication.us > er> > > <datasource.esv.application.password>pro_pw</datasource.esv.ap plication. > password> > </properties> > </profile> > </profiles> > > > Now, I do the same > mvn help:active-profiles help:effective-pom -Pintegration > > What do I get? > ... > [WARNING] Overriding profile: 'local' (source: pom) with new instance > from source: profiles.xml > [WARNING] Overriding profile: 'development' (source: pom) with new > instance from source: profiles.xml > [WARNING] Overriding profile: 'integration' (source: pom) with new > instance from source: profiles.xml > [WARNING] Overriding profile: 'staging' (source: pom) with > new instance > from source: profiles.xml > [WARNING] Overriding profile: 'production' (source: pom) with new > instance from source: profiles.xml > ... > The following profiles are active: > > - local (source: profiles.xml) > - development (source: profiles.xml) > - integration (source: profiles.xml) > - staging (source: profiles.xml) > - production (source: profiles.xml) > - local (source: settings.xml) > - integration (source: settings.xml) > - local (source: settings.xml) > ... > > <datasource.esv.application.password>pro_pw</datasource.esv.ap plication. > password> > > <datasource.esv.application.url>pro</datasource.esv.application.url> > > <datasource.esv.application.user>pro_user</datasource.esv.appl ication.us > er> > > > Seems like *all* profiles are taken from profiles.xml even though I > specify the profile to use. And the last profile from > profiles.xml seems > to win. > > I just don't understand it. I mean, if I have a parent and a child POM > where properties are overriden for different profiles, it > works, so why > not here? > > Thanks for any enlightment! :-) > > Best regards, > Eric > > --------------------------------------------------------------------- > 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]
