You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by trant <mm...@webatrocity.com> on 2011/05/18 18:14:19 UTC

How do I add filtered properties to my pom.xml?

I use the following setup to have maven inject filtered property values into
my application configuration files, such as the Spring
applicationContext.xml:

File System:
src/main/filters/filter-test.properties
src/main/filters/filter-live.properties
src/main/resources/applicationContext.xml

and in my pom.xml I do this:

// use profiles to setup env property value as either test or live
...
  <build>
    <filters>
      <filter>${basedir}/src/main/filters/filter-${env}.properties</filter>
    </filters>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
  </build>

Now this works fine, but I would like to have my filter property files also
have properties entered into my pom.xml itself.

For example, later in my pom.xml I use a weblogic deployment plugin which
deploys my war to the server. This of course requires properties which are
environment specific. I wish I could have these properties in my separate
filter-<env>.properties files as well, because right now the only thing I
seem to get working is if I set these properties within my profiles setup. I
dont want it in the pom.xml though, I want maven to load them from my
environment specific property file.

Is there any way I can do this?

So that when I configure my weblogic plugin with for example:
          <adminServerHostName>${weblogic.host.name}</adminServerHostName>

And I ran the pom.xml with my "test" profile activated, then maven should
pull the value of that property from my filter-test.properties file:
weblogic.host.name=testserver

or whatever.

--
View this message in context: http://maven.40175.n5.nabble.com/How-do-I-add-filtered-properties-to-my-pom-xml-tp4406945p4406945.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: How do I add filtered properties to my pom.xml?

Posted by trant <mm...@webatrocity.com>.
Martin,

Thank you for that link. 

It works!

--
View this message in context: http://maven.40175.n5.nabble.com/How-do-I-add-filtered-properties-to-my-pom-xml-tp4406945p4407382.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: How do I add filtered properties to my pom.xml?

Posted by Martin Gainty <mg...@hotmail.com>.
http://haroon.sis.utoronto.ca/zarar/properties-maven-plugin/index.html

Martin 
______________________________________________ 
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.




> Date: Wed, 18 May 2011 09:14:19 -0700
> From: mmorpg@webatrocity.com
> To: users@maven.apache.org
> Subject: How do I add filtered properties to my pom.xml?
> 
> I use the following setup to have maven inject filtered property values into
> my application configuration files, such as the Spring
> applicationContext.xml:
> 
> File System:
> src/main/filters/filter-test.properties
> src/main/filters/filter-live.properties
> src/main/resources/applicationContext.xml
> 
> and in my pom.xml I do this:
> 
> // use profiles to setup env property value as either test or live
> ...
>   <build>
>     <filters>
>       <filter>${basedir}/src/main/filters/filter-${env}.properties</filter>
>     </filters>
>     <resources>
>       <resource>
>         <directory>src/main/resources</directory>
>         <filtering>true</filtering>
>       </resource>
>   </build>
> 
> Now this works fine, but I would like to have my filter property files also
> have properties entered into my pom.xml itself.
> 
> For example, later in my pom.xml I use a weblogic deployment plugin which
> deploys my war to the server. This of course requires properties which are
> environment specific. I wish I could have these properties in my separate
> filter-<env>.properties files as well, because right now the only thing I
> seem to get working is if I set these properties within my profiles setup. I
> dont want it in the pom.xml though, I want maven to load them from my
> environment specific property file.
> 
> Is there any way I can do this?
> 
> So that when I configure my weblogic plugin with for example:
>           <adminServerHostName>${weblogic.host.name}</adminServerHostName>
> 
> And I ran the pom.xml with my "test" profile activated, then maven should
> pull the value of that property from my filter-test.properties file:
> weblogic.host.name=testserver
> 
> or whatever.
> 
> --
> View this message in context: http://maven.40175.n5.nabble.com/How-do-I-add-filtered-properties-to-my-pom-xml-tp4406945p4406945.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
 		 	   		  

Re: How do I add filtered properties to my pom.xml?

Posted by Rafael Vanderlei <ra...@gmail.com>.
I believe it would work if you changed a little bit the way you configure
the filters... you could have a profile for each filter you want to use
(instead of using the ${env} property to determine the filter you will
use).. so it would be something like:

<profile>
   <id>env.test</id>
   <activation>
      <property>
         <name>env</name>
         <value>test</value>
      </property>
   </activation>
   <build>
      <fillters>
         <filter>${basedir}/src/main/filters/filter-test.properties</filter>
      </filters>
   </build>
</profile>
<profile>
   <id>env.live</id>
   <activation>
      <property>
         <name>env</name>
         <value>live</value>
      </property>
   </activation>
   <build>
      <fillters>
         <filter>${basedir}/src/main/filters/filter-live.properties</filter>
      </filters>
   </build>
</profile>


This way, when ${env} is evaluated to "test", the "env.test" profile will be
activated and properties defined in
${basedir}/src/main/filters/filter-test.properties will be available. While
when ${env} is evaluated to "live", the "env.live" profile will be activated
and properties defined in ${basedir}/src/main/filters/filter-live.properties
will be available.

On Wed, May 18, 2011 at 1:14 PM, trant <mm...@webatrocity.com> wrote:

> I use the following setup to have maven inject filtered property values
> into
> my application configuration files, such as the Spring
> applicationContext.xml:
>
> File System:
> src/main/filters/filter-test.properties
> src/main/filters/filter-live.properties
> src/main/resources/applicationContext.xml
>
> and in my pom.xml I do this:
>
> // use profiles to setup env property value as either test or live
> ...
>  <build>
>    <filters>
>      <filter>${basedir}/src/main/filters/filter-${env}.properties</filter>
>    </filters>
>    <resources>
>      <resource>
>        <directory>src/main/resources</directory>
>        <filtering>true</filtering>
>      </resource>
>  </build>
>
> Now this works fine, but I would like to have my filter property files also
> have properties entered into my pom.xml itself.
>
> For example, later in my pom.xml I use a weblogic deployment plugin which
> deploys my war to the server. This of course requires properties which are
> environment specific. I wish I could have these properties in my separate
> filter-<env>.properties files as well, because right now the only thing I
> seem to get working is if I set these properties within my profiles setup.
> I
> dont want it in the pom.xml though, I want maven to load them from my
> environment specific property file.
>
> Is there any way I can do this?
>
> So that when I configure my weblogic plugin with for example:
>          <adminServerHostName>${weblogic.host.name}</adminServerHostName>
>
> And I ran the pom.xml with my "test" profile activated, then maven should
> pull the value of that property from my filter-test.properties file:
> weblogic.host.name=testserver
>
> or whatever.
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/How-do-I-add-filtered-properties-to-my-pom-xml-tp4406945p4406945.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>