Thanks for sending me a sample project Wayne. You are correct - it works
fine for your project. However, I've stared at your project and mine for
the last 15 minutes and I still can't figure out what's different. One
thing that's different is I'm filtering <testResources> rather than
<resources>, but I doubt that's it. Also, I don't have filtering turned on
in my root pom.xml, but rather in my core module. I tried moving things in
yours and it still works. Doh!
I tried running "mvn help:active-profiles" on both projects. Mine has the
same results as yours.
Now that I'm writing this, one thing comes to mind that could be the
problem:
In my root pom.xml, I have:
<properties>
<jdbc.url>localhost.for.mysql</jdbc.url>
</properties>
<profiles>
<profile>
<id>sqlserver</id>
<activation><activeByDefault>true</activeByDefault</activation>
<properties>
<jdbc.url>localhost.for.sqlserver</jdbc.url>
</properties>
</profile>
</profiles>
So it's possible that my "sqlserver" profile is overriding my profiles.xml.
Is there any way to order these or is it better to move my default
<properties> into a profile for mysql?
Thanks,
Matt
Wayne Fay wrote:
>
> I have no idea... I made a little test project to see what happens and
> it seems to work like I said, and not like you're experiencing, so I
> guess something else is up on your side (??).
>
> I will go ahead and send the zip directly to you Matt as I know
> attachments generally don't get passed through this mailing list...
> But please reply to this email (on list) so we can keep the
> conversation public, if you don't mind.
>
> Wayne
>
> On 3/13/07, mraible <[EMAIL PROTECTED]> wrote:
>>
>> I'm seeing some strange behavior with this. I've added a profiles.xml in
>> the
>> root of my project. Its contents are:
>>
>> <profiles>
>> <profile>
>> <id>xp</id>
>> <activation>
>> <activeByDefault>true</activeByDefault>
>> </activation>
>> <properties>
>>
>> <jdbc.url><![CDATA[jdbc:jtds:sqlserver://xpbox:1433/database]]></jdbc.url>
>> </properties>
>> </profile>
>> </profiles>
>>
>> When I cd into "core" and run "mvn test", the correct "jdbc.url" property
>> is
>> put into my filtered properties file. However, when I run "mvn test"
>> from
>> the top-level directory, it uses the value from pom.xml.
>>
>> If I move the contents of profiles.xml to ~/.m2/settings.xml, everything
>> works fine, but I'm back to my same problem where this is a global
>> property
>> override, and I'm only looking to override for this one project.
>>
>> Any ideas why this happens?
>>
>> Thanks,
>>
>> Matt
>>
>>
>> mraible wrote:
>> >
>> > Thanks for the tip - I was able to use a profiles.xml file in my local
>> > project directory to get the behavior I wanted. Now I'm only overriding
>> > the property for a single project, and as long as I don't check it in
>> to
>> > SVN, everyone else retains the default behavior from pom.xml. Another
>> > thing I tried was to use <file> activation in settings.xml (because
>> there
>> > are different files in the 2 Maven projects), but that didn't seem to
>> > work. Here's what I used:
>> >
>> > <activation>
>> > <file>
>> > <exists>${basedir}/lib/install.sh</exists>
>> > </file>
>> > </activation>
>> >
>> > Thanks for the help Wayne - you solved my problem.
>> >
>> > Matt
>> >
>> >
>> > Wayne Fay wrote:
>> >>
>> >> Have you considered using a profiles.xml file (checked into SCM) which
>> >> contains settings specific to each person's environment? Then you
>> >> would use -Pmrmac which would specify the SQL server on another box,
>> >> while -Pmrxp would specify a local SQL server etc.
>> >>
>> >> This profiles.xml file would be available for everyone to read/write
>> >> but they would be responsible to only edit their piece of the config.
>> >> And you could have a generic config that is used for the common
>> >> developer environment with generic data. I'm not sure if this would
>> >> solve all your problems, though, as it would require you to copy this
>> >> profile.xml file to multiple locations in your SCM and potentially
>> >> keep them all in-sync.
>> >>
>> >> Wayne
>> >>
>> >> On 3/12/07, mraible <[EMAIL PROTECTED]> wrote:
>> >>>
>> >>> I've read this page quite a few times and the answer still doesn't
>> jump
>> >>> out
>> >>> at me. If I have two Maven projects that are completely unrelated,
>> but
>> >>> they
>> >>> use the same property name - how do I override this property's value
>> for
>> >>> one
>> >>> project, but not for the other?
>> >>>
>> >>> In other words, I want "jdbc.url" to have "localhost" for most
>> projects
>> >>> on
>> >>> my system. And in the SVN version of this other project, I have
>> >>> "localhost". However, because I need to connect to a Windows/SQL
>> Server
>> >>> box
>> >>> for this one project, I need to change <jdbc.url> to have "xpboxname"
>> >>> instead of localhost. If I use any sort of system properties, that
>> >>> applies
>> >>> to all projects. If I modify the pom.xml, that changes things for
>> >>> everyone
>> >>> (which doesn't need to happen because I'm on the only one on a Mac).
>> >>>
>> >>> I'm all for a workaround, but the only two options I see right now
>> are:
>> >>>
>> >>> 1. Comment out the <activeByDefault> setting in pom.xml when I want
>> to
>> >>> work
>> >>> on other projects (not the one that needs XP).
>> >>> 2. Change /etc/hosts so localhost resolves to my XP box.
>> >>>
>> >>> Thanks for any advice,
>> >>>
>> >>> Matt
>> >>>
>> >>>
>> >>> Wayne Fay wrote:
>> >>> >
>> >>> > It might be useful to review this documentation to make sure you're
>> >>> > doing it "the one true way". ;-)
>> >>> >
>> >>> >
>> >>>
>> http://maven.apache.org/guides/introduction/introduction-to-profiles.html
>> >>> >
>> >>> > Wayne
>> >>> >
>> >>> > On 3/12/07, mraible <[EMAIL PROTECTED]> wrote:
>> >>> >>
>> >>> >> Don't worry - I am doing things "The Maven Way" with properties in
>> >>> the
>> >>> >> root
>> >>> >> pom.xml. However, for this particular application, I need to
>> >>> override a
>> >>> >> property in settings.xml (I'm on a Mac and need to connect to a
>> SQL
>> >>> >> Server
>> >>> >> instance not on "localhost"). The problem is, I have another
>> >>> application
>> >>> >> that uses the same property name (this can't be that rare, can
>> it?).
>> >>> So
>> >>> >> when
>> >>> >> I override it in settings.xml, it overrides all my projects that
>> use
>> >>> that
>> >>> >> property name.
>> >>> >>
>> >>> >> Matt
>> >>> >>
>> >>> >>
>> >>> >>
>> >>> >> Wayne Fay wrote:
>> >>> >> >
>> >>> >> > You are really not encouraged to use application-specific
>> >>> properties
>> >>> >> > in a settings.xml file, as your builds will not be portable.
>> >>> Instead,
>> >>> >> > these kinds of properties should be placed directly in the pom
>> >>> (parent
>> >>> >> > or children as appropriate) of the project you are working on.
>> >>> >> >
>> >>> >> > I use a similar process for our Ant builds, with
>> project-specific
>> >>> >> > properties in my user home loaded first, then all-projects
>> >>> properties,
>> >>> >> > etc. I'm pretty sure this is a common pattern across Ant users.
>> >>> >> >
>> >>> >> > Wayne
>> >>> >> >
>> >>> >> > On 3/12/07, mraible <[EMAIL PROTECTED]> wrote:
>> >>> >> >>
>> >>> >> >> Since there's been no answers to this question, I'll assume the
>> >>> answer
>> >>> >> is
>> >>> >> >> "No, it's not possible to use settings.xml to have
>> >>> >> application-specific
>> >>> >> >> properties."
>> >>> >> >>
>> >>> >> >> Matt
>> >>> >> >>
>> >>> >> >>
>> >>> >> >> mraible wrote:
>> >>> >> >> >
>> >>> >> >> > I have a number of properties for database settings in my
>> root
>> >>> >> pom.xml:
>> >>> >> >> >
>> >>> >> >> > <!-- Database settings -->
>> >>> >> >> >
>> >>> >> >> >
>> >>> >> >>
>> >>> >>
>> >>>
>> <dbunit.dataTypeFactoryName>org.dbunit.dataset.datatype.DefaultDataTypeFactory</dbunit.dataTypeFactoryName>
>> >>> >> >> >
>> >>> <dbunit.operation.type>CLEAN_INSERT</dbunit.operation.type>
>> >>> >> >> >
>> >>> >> >> >
>> >>> >> >>
>> >>> >>
>> >>>
>> <hibernate.dialect>org.hibernate.dialect.MySQLInnoDBDialect</hibernate.dialect>
>> >>> >> >> > <jdbc.groupId>mysql</jdbc.groupId>
>> >>> >> >> >
>> <jdbc.artifactId>mysql-connector-java</jdbc.artifactId>
>> >>> >> >> > <jdbc.version>5.0.3</jdbc.version>
>> >>> >> >> >
>> >>> >> >>
>> <jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
>> >>> >> >> >
>> >>> >> >> >
>> >>> >> >>
>> >>> >>
>> >>>
>> <jdbc.url><![CDATA[jdbc:mysql://localhost/tutorial?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8]]></jdbc.url>
>> >>> >> >> > <jdbc.username>root</jdbc.username>
>> >>> >> >> > <jdbc.password></jdbc.password>
>> >>> >> >> >
>> >>> >> >> > This works great when I have a single project. However, I've
>> >>> >> started
>> >>> >> >> to
>> >>> >> >> > develop two applications with this setup, and I need to
>> locally
>> >>> >> >> override
>> >>> >> >> > the jdbc.url for one of my projects. Is it possible to do
>> this
>> >>> on
>> >>> >> an
>> >>> >> >> > application-specific basis w/o affecting both applications.
>> >>> AFAIK,
>> >>> >> >> > settings.xml doesn't have anything fancy like (does it?):
>> >>> >> >> >
>> >>> >> >> > <activation>
>> >>> >> >> > <property>
>> >>> >> >> > <name>${pom.artifactId}</name>
>> >>> >> >> > <value>projecttoactivatefor</value>
>> >>> >> >> > </property>
>> >>> >> >> > </activation>
>> >>> >> >> >
>> >>> >> >> > With Ant, I was able to accomplish this using:
>> >>> >> >> >
>> >>> >> >> > <!-- Load user overrides -->
>> >>> >> >> > <property
>> >>> >> >> file="${user.home}/.${ant.project.name}-build.properties"/>
>> >>> >> >> > <property file="${user.home}/.build.properties"/>
>> >>> >> >> > <property file="build.properties"/>
>> >>> >> >> >
>> >>> >> >> > Thanks,
>> >>> >> >> >
>> >>> >> >> > Matt
>> >>> >> >> >
>> >>> >> >>
>> >>> >> >> --
>> >>> >> >> View this message in context:
>> >>> >> >>
>> >>> >>
>> >>>
>> http://www.nabble.com/Is-it-possible-to-have-application-specific-properties-in-settings.xml--tf3363611s177.html#a9441555
>> >>> >> >> Sent from the Maven - Users mailing list archive at Nabble.com.
>> >>> >> >>
>> >>> >> >>
>> >>> >> >>
>> >>> ---------------------------------------------------------------------
>> >>> >> >> 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/Is-it-possible-to-have-application-specific-properties-in-settings.xml--tf3363611s177.html#a9444290
>> >>> >> Sent from the Maven - Users mailing list archive at Nabble.com.
>> >>> >>
>> >>> >>
>> >>> >>
>> ---------------------------------------------------------------------
>> >>> >> 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/Is-it-possible-to-have-application-specific-properties-in-settings.xml--tf3363611s177.html#a9444655
>> >>> Sent from the Maven - Users mailing list archive at Nabble.com.
>> >>>
>> >>>
>> >>> ---------------------------------------------------------------------
>> >>> 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/Is-it-possible-to-have-application-specific-properties-in-settings.xml--tf3363611s177.html#a9466189
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> 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/Is-it-possible-to-have-application-specific-properties-in-settings.xml--tf3363611s177.html#a9468015
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]