You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by thuss2 <th...@greatschools.net> on 2008/11/20 22:09:54 UTC

Re: Making properties accessible in pom.xml

I'm pleased to say that to solve this problem I found the
maven-properties-plugin which has been working great for me:

http://arsenalist.com/2007/02/07/maven-properties-plugin-download/

-Todd


Jason van Zyl-2 wrote:
> 
> 
> On 17 Feb 07, at 1:35 PM 17 Feb 07, thuss2 wrote:
> 
>>
>> We're in the process of migrating from Maven 1 to Maven 2 so we'd  
>> prefer to
>> leave the actual database connection in a database.properties file and
>> reference those values in the pom. However, as far as I can tell  
>> you can
>> only hard code properties in the properties section of the POM, you  
>> can't
>> tell it to read properties from a .properties file?!
>>
> 
> No. The reasoning being we want the POM to be the single source of  
> information which is why we got rid of the pom.properties file and  
> trying to sync all the various files presented some difficulty so now  
> all we move around is the POM.
> 
> You can still have a plugin pull from a properties file if you like,  
> and you can specify profiles which define different properties for  
> different scenerios. As much as possible we've made it so that  
> external sources of information don't influence the POM. But we have  
> user settings and profiles.xml and warn strongly about their use in  
> making builds portable between users.
> 
> Jason.
> 
>> Thanks,
>> Todd
>> --
>> http://gabrito.com
>>
>>
>> Wayne Fay wrote:
>>>
>>> You can add properties directly into the pom.xml:
>>> http://maven.apache.org/pom.html#Properties
>>>
>>> I personally prefer to use profiles for this kind of thing, though.
>>>
>>> Wayne
>>>
>>> On 2/15/07, thuss2 <th...@greatschools.net> wrote:
>>>>
>>>> We're in the process of migrating from Maven 1 to Maven 2.  
>>>> Currently we
>>>> have
>>>> a database.properties file that contains all of our database  
>>>> connection
>>>> information. Is there any easy to make those properties  
>>>> accessible from
>>>> within pom.xml so that I can do:
>>>>
>>>> <driver>${jdbc.driver_class}</driver>
>>>>
>>>> I tried adding the property file in the filters section, however,  
>>>> that
>>>> seems
>>>> to only make the properties accessible to specified resource  
>>>> files within
>>>> the resource section. It does not seem to make the property  
>>>> available for
>>>> use in pom.xml. Perhaps I'm missing something simple.
>>>>
>>>> Thanks,
>>>> Todd
>>>> http://gabrito.com
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Making-properties-accessible-in-pom.xml- 
>>>> tf3236898s177.html#a8996414
>>>> 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
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>>> For additional commands, e-mail: users-help@maven.apache.org
>>>
>>>
>>>
>>
>> -- 
>> View this message in context: http://www.nabble.com/Making- 
>> properties-accessible-in-pom.xml-tf3236898s177.html#a9022598
>> 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
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 



-- 
View this message in context: http://www.nabble.com/Making-properties-accessible-in-pom.xml-tp8996414p20610080.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: Making properties accessible in pom.xml

Posted by thuss2 <th...@greatschools.net>.
Great points Stephen! I'm only using this plugin in one particular use case
where we need a property in maven that's stored in a property file but as
you point out it does not affect the build plan. In general though I think
its best to do it the "maven way" and make Maven the definitive source and
not use this plugin. But for folks that have a legacy code base use case,
having this plugin available can sure make the migration path to Maven 2
easier!

-Todd


Stephen Connolly-2 wrote:
> 
> 2008/11/20 thuss2 <th...@greatschools.net>
> 
>>
>> I'm pleased to say that to solve this problem I found the
>> maven-properties-plugin which has been working great for me:
>>
>> http://arsenalist.com/2007/02/07/maven-properties-plugin-download/
>>
>> -Todd
>>
>>
>>
> Beware, that plugin suffers from a fatal flaw:
> 
> Plugins execute after the build plan has been constructed.
> 
> Thus it can only provide properties for things which do not affect the
> build
> plan.
> 
> So, while you'll get some mileage out of that plugin.... ultimately you'll
> end up frustrated when you hit one of the places where property
> subsitution
> takes place during determination of the build plan.
> 
> Also, the property substitution will only take place *when* the plugin is
> run, so if you invoke another plugin directly outside of a lifecycle goal,
> you'll get no substitution...
> 
> -Stephen
> 
> 

-- 
View this message in context: http://www.nabble.com/Making-properties-accessible-in-pom.xml-tp8996414p20610367.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: Making properties accessible in pom.xml

Posted by Stephen Connolly <st...@gmail.com>.
2008/11/20 thuss2 <th...@greatschools.net>

>
> I'm pleased to say that to solve this problem I found the
> maven-properties-plugin which has been working great for me:
>
> http://arsenalist.com/2007/02/07/maven-properties-plugin-download/
>
> -Todd
>
>
>
Beware, that plugin suffers from a fatal flaw:

Plugins execute after the build plan has been constructed.

Thus it can only provide properties for things which do not affect the build
plan.

So, while you'll get some mileage out of that plugin.... ultimately you'll
end up frustrated when you hit one of the places where property subsitution
takes place during determination of the build plan.

Also, the property substitution will only take place *when* the plugin is
run, so if you invoke another plugin directly outside of a lifecycle goal,
you'll get no substitution...

-Stephen