You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ronald Albury <ro...@gmail.com> on 2012/06/06 15:23:41 UTC

xmlproperty not expanding

My understanding is that the xmlproperty task is supposed to expand
references to external properties just like the regular property task
does.  However, it does not seem to work for me.  The output below is from
ant 1.7 - however I have downloaded the latest ant and it has the same
issue.

*Here is my ant file:*
<project name="test" default="show">

    <property name="global.demo" value="i am global demo"/>

    <xmlproperty keepRoot="true" file="props.xml"/>
    <property file="props.properties"/>

    <target name="show">
        <echo>ant.version = ${ant.version}</echo>
        <echo>ant.java.version = ${ant.java.version}</echo>
        <echo>java.vendor = ${java.vendor}</echo>
        <echo>java.version = ${java.version}</echo>

        <echo message="cmd.demo property = ${cmd.demo}"/>
        <echo message="global.demo property = ${global.demo}"/>
        <echo message="props.demo property = ${props.demo}"/>
        <echo message="xml.demo property = ${xmlTest.demo}"/>

        <echo message="props.cmd property = ${props.cmd}"/>
        <echo message="props.global property = ${props.global}"/>

        <echo message="xml.cmd property = ${xmlTest.cmd}"/>
        <echo message="xml.global property = ${xmlTest.global}"/>
    </target>

</project>

*Here is the regular property file:*
props.demo = This is properties demo
props.cmd = This is properties with cmd ${cmd.demo}
props.global = This is properties with global ${global.demo}

*Here is the xml property file:*
<xmlTest>
    <demo>This is xmlTest demo</demo>
    <cmd>This is xmlTest with cmd ${cmd.demo}</cmd>
    <global>This is xmlTest with global ${global.demo}</global>
</xmlTest>

*Here is the output  when I run with -Dcmd.demo="i am command demo" *
show:
     [echo] ant.version = Apache Ant version 1.7.1 compiled on June 27 2008
     [echo] ant.java.version = 1.6
     [echo] java.vendor = IBM Corporation
     [echo] java.version = 1.6.0
     [echo] cmd.demo property = i am command demo
     [echo] global.demo property = i am global demo
     [echo] props.demo property = This is properties demo
     [echo] xml.demo property = This is xmlTest demo
     [echo] props.cmd property = This is properties with cmd i am command
demo
     [echo] props.global property = This is properties with global i am
global demo
     [echo] xml.cmd property = This is xmlTest with cmd ${cmd.demo}
     [echo] xml.global property = This is xmlTest with global ${global.demo}

Re: xmlproperty not expanding

Posted by Ronald Albury <ro...@gmail.com>.
Thank you Simon.  I missed that sentence and did get sucked in by the
examples.  There are also a number of postings I found on Google that also
seem it say it works as I expected.

Should this be considered a bug?  It certainly seems like a significant
deficiency to me.  Why should xmlproperty fail to process input when
property does?  I guess I'm just screwed.

Thanks again for taking the time to answer my question.


On Wed, Jun 6, 2012 at 7:38 PM, Simon Murcott <si...@flaxx.net> wrote:

> Hi Ronald, if you look at the manual for XmlProperty you will find the
> following statement:
> "By default, this load does *no* processing of the input. In particular,
> unlike the Property task <http://ant.apache.org/manual/Tasks/property.html
> >,
> property references (i.e., ${foo}) are not resolved."
>
> Unfortunately, the manual adds confusion here as the examples it provides
> do not reflect this statement.
>
> Also have a look at the echoproperties task, it helps a whole heap with
> debugging properties.
>
> http://ant.apache.org/manual/Tasks/xmlproperty.html
> http://ant.apache.org/manual/Tasks/echoproperties.html
>
> On 7 June 2012 01:23, Ronald Albury <ro...@gmail.com> wrote:
>
> > My understanding is that the xmlproperty task is supposed to expand
> > references to external properties just like the regular property task
> > does.  However, it does not seem to work for me.  The output below is
> from
> > ant 1.7 - however I have downloaded the latest ant and it has the same
> > issue.
> >
> > *Here is my ant file:*
> > <project name="test" default="show">
> >
> >    <property name="global.demo" value="i am global demo"/>
> >
> >    <xmlproperty keepRoot="true" file="props.xml"/>
> >    <property file="props.properties"/>
> >
> >    <target name="show">
> >        <echo>ant.version = ${ant.version}</echo>
> >        <echo>ant.java.version = ${ant.java.version}</echo>
> >        <echo>java.vendor = ${java.vendor}</echo>
> >        <echo>java.version = ${java.version}</echo>
> >
> >        <echo message="cmd.demo property = ${cmd.demo}"/>
> >        <echo message="global.demo property = ${global.demo}"/>
> >        <echo message="props.demo property = ${props.demo}"/>
> >        <echo message="xml.demo property = ${xmlTest.demo}"/>
> >
> >        <echo message="props.cmd property = ${props.cmd}"/>
> >        <echo message="props.global property = ${props.global}"/>
> >
> >        <echo message="xml.cmd property = ${xmlTest.cmd}"/>
> >        <echo message="xml.global property = ${xmlTest.global}"/>
> >    </target>
> >
> > </project>
> >
> > *Here is the regular property file:*
> > props.demo = This is properties demo
> > props.cmd = This is properties with cmd ${cmd.demo}
> > props.global = This is properties with global ${global.demo}
> >
> > *Here is the xml property file:*
> > <xmlTest>
> >    <demo>This is xmlTest demo</demo>
> >    <cmd>This is xmlTest with cmd ${cmd.demo}</cmd>
> >    <global>This is xmlTest with global ${global.demo}</global>
> > </xmlTest>
> >
> > *Here is the output  when I run with -Dcmd.demo="i am command demo" *
> > show:
> >     [echo] ant.version = Apache Ant version 1.7.1 compiled on June 27
> 2008
> >     [echo] ant.java.version = 1.6
> >     [echo] java.vendor = IBM Corporation
> >     [echo] java.version = 1.6.0
> >     [echo] cmd.demo property = i am command demo
> >     [echo] global.demo property = i am global demo
> >     [echo] props.demo property = This is properties demo
> >     [echo] xml.demo property = This is xmlTest demo
> >     [echo] props.cmd property = This is properties with cmd i am command
> > demo
> >     [echo] props.global property = This is properties with global i am
> > global demo
> >     [echo] xml.cmd property = This is xmlTest with cmd ${cmd.demo}
> >     [echo] xml.global property = This is xmlTest with global
> ${global.demo}
> >
>

Re: xmlproperty not expanding

Posted by Simon Murcott <si...@flaxx.net>.
Hi Ronald, if you look at the manual for XmlProperty you will find the
following statement:
"By default, this load does *no* processing of the input. In particular,
unlike the Property task <http://ant.apache.org/manual/Tasks/property.html>,
property references (i.e., ${foo}) are not resolved."

Unfortunately, the manual adds confusion here as the examples it provides
do not reflect this statement.

Also have a look at the echoproperties task, it helps a whole heap with
debugging properties.

http://ant.apache.org/manual/Tasks/xmlproperty.html
http://ant.apache.org/manual/Tasks/echoproperties.html

On 7 June 2012 01:23, Ronald Albury <ro...@gmail.com> wrote:

> My understanding is that the xmlproperty task is supposed to expand
> references to external properties just like the regular property task
> does.  However, it does not seem to work for me.  The output below is from
> ant 1.7 - however I have downloaded the latest ant and it has the same
> issue.
>
> *Here is my ant file:*
> <project name="test" default="show">
>
>    <property name="global.demo" value="i am global demo"/>
>
>    <xmlproperty keepRoot="true" file="props.xml"/>
>    <property file="props.properties"/>
>
>    <target name="show">
>        <echo>ant.version = ${ant.version}</echo>
>        <echo>ant.java.version = ${ant.java.version}</echo>
>        <echo>java.vendor = ${java.vendor}</echo>
>        <echo>java.version = ${java.version}</echo>
>
>        <echo message="cmd.demo property = ${cmd.demo}"/>
>        <echo message="global.demo property = ${global.demo}"/>
>        <echo message="props.demo property = ${props.demo}"/>
>        <echo message="xml.demo property = ${xmlTest.demo}"/>
>
>        <echo message="props.cmd property = ${props.cmd}"/>
>        <echo message="props.global property = ${props.global}"/>
>
>        <echo message="xml.cmd property = ${xmlTest.cmd}"/>
>        <echo message="xml.global property = ${xmlTest.global}"/>
>    </target>
>
> </project>
>
> *Here is the regular property file:*
> props.demo = This is properties demo
> props.cmd = This is properties with cmd ${cmd.demo}
> props.global = This is properties with global ${global.demo}
>
> *Here is the xml property file:*
> <xmlTest>
>    <demo>This is xmlTest demo</demo>
>    <cmd>This is xmlTest with cmd ${cmd.demo}</cmd>
>    <global>This is xmlTest with global ${global.demo}</global>
> </xmlTest>
>
> *Here is the output  when I run with -Dcmd.demo="i am command demo" *
> show:
>     [echo] ant.version = Apache Ant version 1.7.1 compiled on June 27 2008
>     [echo] ant.java.version = 1.6
>     [echo] java.vendor = IBM Corporation
>     [echo] java.version = 1.6.0
>     [echo] cmd.demo property = i am command demo
>     [echo] global.demo property = i am global demo
>     [echo] props.demo property = This is properties demo
>     [echo] xml.demo property = This is xmlTest demo
>     [echo] props.cmd property = This is properties with cmd i am command
> demo
>     [echo] props.global property = This is properties with global i am
> global demo
>     [echo] xml.cmd property = This is xmlTest with cmd ${cmd.demo}
>     [echo] xml.global property = This is xmlTest with global ${global.demo}
>