You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Sebastian Oerding <oe...@match2blue.com> on 2010/08/27 10:16:32 UTC

using properties from external files in pom.xml

Hello,

I want to use properties from external files in a pom.xml? Is this 
possible? It doesn't seem to be.

For example, I have a tomcat.properties with
tomcat.manager.url=SOME_URL
and so on. I use this properties file as filter. To check this issue I 
included bla.properties with
bla=${tomcat.manager.url}

The war is built as expected containing bla.properties with
bla=SOME_URL
but when trying to use ${tomcat.manager.url} in the pom.xml (for cargo 
plugin to deploy the war to tomcat)
deplyoment fails due to an empty url which looks like that the property 
is not resolved.

With kind regards Sebastian

-- 
Sebastian Oerding
Senior Developer
Sun Certified Java Programmer

match2blue software development GmbH
Leutragraben 1
07743 Jena
Germany

Tel.:  +49(0) 3641 573 3474
Fax:   +49(0) 3641 573 3488
Mobil: +49(0) 176 96 036 136

oerding@match2blue.com
www.match2blue.com

Geschäftsführer: Michael Selle
Registernummer:  HRB 503726
Registergericht: Amtsgericht Jena


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


Re: using properties from external files in pom.xml

Posted by Dirk Olmes <di...@xanthippe.ping.de>.
On 08/27/2010 06:11 PM, Wayne Fay wrote:
>> Looks like this maven plugin could feet your needs :
>> http://haroon.sis.utoronto.ca/zarar/properties-maven-plugin/index.html
> 
> Since Stephen hasn't given his usual response to this thread yet, I
> will go ahead and copy/paste it in...
> 
>>> 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...

One more warning: the pluing only provides the properties in the POM
it's called from. If you call the plugin from a parent pom, thild POMs
won't see the properties - this behaviour is definitely different from
properties defined directly inside the parent POM.

-dirk

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


Re: using properties from external files in pom.xml

Posted by Stephen Connolly <st...@gmail.com>.
On 27 August 2010 17:11, Wayne Fay <wa...@gmail.com> wrote:

> > Looks like this maven plugin could feet your needs :
> > http://haroon.sis.utoronto.ca/zarar/properties-maven-plugin/index.html
>
> Since Stephen hasn't given his usual response to this thread yet, I
> will go ahead and copy/paste it in...
>
>
Yes thanks for that Wayne... I should really keep it in the pastebin for
rapid paste through

-Stephen



> >> 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...
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: using properties from external files in pom.xml

Posted by Wayne Fay <wa...@gmail.com>.
> Looks like this maven plugin could feet your needs :
> http://haroon.sis.utoronto.ca/zarar/properties-maven-plugin/index.html

Since Stephen hasn't given his usual response to this thread yet, I
will go ahead and copy/paste it in...

>> 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...

Wayne

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


Re: using properties from external files in pom.xml

Posted by lukewpatterson <lu...@gmail.com>.

Frederic Camblor wrote:
> 
> Looks like this maven plugin could feet your needs :
> http://haroon.sis.utoronto.ca/zarar/properties-maven-plugin/index.html
> 

you can probably get what you're looking for by using that properties plugin
(making sure it runs before cargo), and then rather than adding the property
directly in the <configuration> section, use properties plugin to set the
_expression_ the parameter is mapped to

that is, assuming that the parameter is mapped to an expression

e.g. enforcer has a "skip" parameter [1], which is mapped to the expression
${enforcer.skip}, so if you don't directly configure skip in enforcer's
configuration section, but instead have the properties set the
"enforcer.skip" expression before enforcer runs, when enforcer loads you'll
see the value from the file

properties listed directly in the POM get resolved before the plugin runs,
and the plugin will get the same as seen when running help:effective-pom

i think that's how it will work, anyways

how advisable this route is?  i don't know.  will it "work"?  maybe, i think
so


[1]
http://maven.apache.org/plugins/maven-enforcer-plugin/enforce-mojo.html#skip
-- 
View this message in context: http://maven.40175.n5.nabble.com/using-properties-from-external-files-in-pom-xml-tp2739646p2740121.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: using properties from external files in pom.xml

Posted by Frederic Camblor <fc...@gmail.com>.
Hi,

Looks like this maven plugin could feet your needs :
http://haroon.sis.utoronto.ca/zarar/properties-maven-plugin/index.html

<http://haroon.sis.utoronto.ca/zarar/properties-maven-plugin/index.html>I
planned to use it in a near future but I'm asking myself some questions :
When this plugin is plugged in ?
In the earlier phase of the lifecycle, it could be plugged on the validate
phase ... what if properties were needed earlier (for example, properties
won't be usable for parent pom variabilisation) ?
Is validate phase sufficient for variabilized dependencies and its
resolution ?

To my mind, this plugin is useful since it allows us to share parameters
between poms without having to use pom inheritance (for me, pom inheritance
should not be done for properties sharing !.. It should be done for
behaviour sharing)

My 2 cents,
Frédéric

On Fri, Aug 27, 2010 at 10:54 AM, Armin Ehrenfels <
Armin.Ehrenfels@t-online.de> wrote:

> Hi,
>
> http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
>
> HTH
>
> Armin
>
>
> Am 27.08.2010 10:16, schrieb Sebastian Oerding:
>
>  Hello,
>>
>> I want to use properties from external files in a pom.xml? Is this
>> possible? It doesn't seem to be.
>>
>> For example, I have a tomcat.properties with
>> tomcat.manager.url=SOME_URL
>> and so on. I use this properties file as filter. To check this issue I
>> included bla.properties with
>> bla=${tomcat.manager.url}
>>
>> The war is built as expected containing bla.properties with
>> bla=SOME_URL
>> but when trying to use ${tomcat.manager.url} in the pom.xml (for cargo
>> plugin to deploy the war to tomcat)
>> deplyoment fails due to an empty url which looks like that the property is
>> not resolved.
>>
>> With kind regards Sebastian
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: using properties from external files in pom.xml

Posted by Armin Ehrenfels <Ar...@t-online.de>.
Ah okay,

in this case, I recommend starting maven from a script (e.g., shell in 
Unix/Linux, .bat in Windows) or a runtime configuration in Eclipse to 
set up your properties.

Regards

Armin

Am 27.08.2010 11:15, schrieb Sebastian Oerding:
> Hi,
>
> thx for the link. But that is exactly NOT what I was trying. I want to 
> define a property in an external file and use this property in a pom.xml.
> The article found under the given location gives an example how to 
> define a property in pom.xml and use it in an external file.
>
> With kind regards Sebastian
>
> On 27.08.2010 10:54, Armin Ehrenfels wrote:
>> Hi,
>>
>> http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html 
>>
>>
>> HTH
>>
>> Armin
>>
>> ---------------------------------------------------------------------
>> 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


Re: using properties from external files in pom.xml

Posted by Sebastian Oerding <oe...@match2blue.com>.
Hi,

thx for the link. But that is exactly NOT what I was trying. I want to 
define a property in an external file and use this property in a pom.xml.
The article found under the given location gives an example how to 
define a property in pom.xml and use it in an external file.

With kind regards Sebastian

On 27.08.2010 10:54, Armin Ehrenfels wrote:
> Hi,
>
> http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
>
> HTH
>
> Armin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>    


-- 
Sebastian Oerding
Senior Developer
Sun Certified Java Programmer

match2blue software development GmbH
Leutragraben 1
07743 Jena
Germany

Tel.:  +49(0) 3641 573 3474
Fax:   +49(0) 3641 573 3488
Mobil: +49(0) 176 96 036 136

oerding@match2blue.com
www.match2blue.com

Geschäftsführer: Michael Selle
Registernummer:  HRB 503726
Registergericht: Amtsgericht Jena


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


Re: using properties from external files in pom.xml

Posted by Armin Ehrenfels <Ar...@t-online.de>.
Hi,

http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

HTH

Armin


Am 27.08.2010 10:16, schrieb Sebastian Oerding:
> Hello,
>
> I want to use properties from external files in a pom.xml? Is this 
> possible? It doesn't seem to be.
>
> For example, I have a tomcat.properties with
> tomcat.manager.url=SOME_URL
> and so on. I use this properties file as filter. To check this issue I 
> included bla.properties with
> bla=${tomcat.manager.url}
>
> The war is built as expected containing bla.properties with
> bla=SOME_URL
> but when trying to use ${tomcat.manager.url} in the pom.xml (for cargo 
> plugin to deploy the war to tomcat)
> deplyoment fails due to an empty url which looks like that the 
> property is not resolved.
>
> With kind regards Sebastian
>


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