You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Peter Donald <pe...@realityforge.org> on 2003/02/15 04:13:07 UTC

Properties defined in project.xml?

Hi,

It looks like you can define properties in the project.xml but it does not 
seem to work? I tried to add

<project>
...
    <properties>
        <blah>true</blah>
    </properties>
</project>

and I expected the property blah to be set to value true but running a simple 
target like

    <goal name="test">
        <echo message="blah=${blah}"/>
    </goal>

Indicates it wasn't set. So what am I doing wrong?

Also how does this interact with inheritance .. ie will sub-projects inherit 
the properties?

-- 
Cheers,

Peter Donald
-----------------------------------------------------------------------
|  I thought there was a knob on the TV to turn up the intelligence.  |
|      There's a knob called "brightness", but it doesn't work.       |
----------------------------------------------------------------------- 



Re: Properties defined in project.xml?

Posted by Peter Donald <pe...@realityforge.org>.
On Sun, 16 Feb 2003 12:59, dion@multitask.com.au wrote:
> I haven't tried it, but I think these properties are available as
> ${pom.getProperty('blah')} at this point.

Okay. If I add the following in it sorta works but fails on certain 
properties. If you look at below property section and run jelly script 
over it then it fails to print out values for maven.repo.remote and 
maven.javadoc.links. Any ideas?

    <goal name="copyProperties">
        <j:set var="_props" value="${pom.resolvedProperties()}"/>
        <j:forEach items="${_props.keySet().iterator()}" var="_key">
            <j:set var="_val">${_props.get(_key)}</j:set>
            <echo message="Setting ${_key} to ${_val}"/>
            <j:set var="${_key}" value="${_val}"/>
        </j:forEach>
    </goal>

    <properties>
       <maven.checkstyle.properties>${basedir}/../../tools/checkstyle/checkstyle.properties</maven.checkstyle.properties>
        <maven.checkstyle.license.exists>true</maven.checkstyle.license.exists>
        <maven.repo.remote>http://www.ibiblio.com/maven,http://spice.sourceforge.net/maven,file:../lib</maven.repo.remote>
        <maven.javadoc.links>http://avalon.apache.org/api/, http://java.sun.com/j2se/1.3/docs/api/</maven.javadoc.links>
        <maven.javadoc.additionalparam>-tag avalon.service</maven.javadoc.additionalparam>
    </properties>

> Again, untested, but AFAIK, if the child project specifies a properties
> section, it completely overrides the parent definitions.
>
> HTH,

yep. Though I would love to see a future version of maven allowing a property 
section that acted exactly like project.properties but was inherited. Currently
I just copy project.proeprties around into all the different projects which would
be great to get rid of :)

I would also like its format to be something like

<property name="X" value="Y"/>

because that seems so much easier to use IMHO.

-- 
Cheers,

Peter Donald
*-------------------------------------------------*
|   An eye for eye only ends up making the whole  | 
|      world blind.  - Gandhi                     |
*-------------------------------------------------*


Re: Properties defined in project.xml?

Posted by di...@multitask.com.au.
Peter Donald <pe...@realityforge.org> wrote on 15/02/2003 02:13:07 PM:

> Hi,
> 
> It looks like you can define properties in the project.xml but it does 
not 
> seem to work? I tried to add
> 
> <project>
> ...
>     <properties>
>         <blah>true</blah>
>     </properties>
> </project>
> 
> and I expected the property blah to be set to value true but running a 
simple 
> target like
> 
>     <goal name="test">
>         <echo message="blah=${blah}"/>
>     </goal>

I haven't tried it, but I think these properties are available as 
${pom.getProperty('blah')} at this point.

> Indicates it wasn't set. So what am I doing wrong?
> 
> Also how does this interact with inheritance .. ie will sub-projects 
inherit 
> the properties?

Again, untested, but AFAIK, if the child project specifies a properties 
section, it completely overrides the parent definitions.

HTH,
--
dIon Gillard, Multitask Consulting
Blog:      http://www.freeroller.net/page/dion/Weblog
Work:      http://www.multitask.com.au