You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by HamletDRC <ha...@gmail.com> on 2009/07/16 22:56:07 UTC
write property as part of task definition
Hi,
Is it possible to do this?
I have a property that contains two XML elements as a String:
<property name="foo"
value="<include>bar.as</include><include>baz.as</include>"
/>
And I want it expanded into the execution of a task as if I wrote this:
<compc>
<include>bar.as</include>
<include>baz.as</include>
</compc>
I expected this to work:
<compc>
${foo}
</compc>
But I get the error:
The <compc> type doesn't support nested text data ("${foo}").
I'm assuming this isn't an error with "compc" but is instead in error in how
I'm expanding ${foo}.
Can I do this in Ant?
-----
--
Hamlet D'Arcy
--
View this message in context: http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24524324.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: write property as part of task definition
Posted by HamletDRC <ha...@gmail.com>.
The number of include elements is dynamic so I don't think this is going to
work.
I've resorted to writing a custom task. I wish there was a better way to do
this.
Michael George wrote:
>
> Another possibility is to create a template file foo.xml.in and use copy
> with substitutions:
>
> --- foo.xml.in ----
>
> <project>
> <include>@file1@</include>
> <include>@file2@</include>
> </project>
>
> --- build.xml ---
>
> <copy from="foo.xml.in" to="foo.xml">
> <filterset>
> <filter token="file1" value="bar.as" />
> <filter token="file2" value="baz.as" />
> </filterset>
> </copy>
>
> <import file="foo.xml" />
>
> I'm not sure if this would accomplish what you want.
>
> --Mike
>
>
> glenn opdycke-hansen wrote:
>> Then use <echo> to write to write to the file.
>> --glenn
>>
>> On Fri, Jul 17, 2009 at 09:38, HamletDRC <ha...@gmail.com> wrote:
>>
>>
>>> Sorry, but this isn't going to work.
>>>
>>> Both echo and echoxml escapes the brackets in the property that contains
>>> XML.
>>>
>>>
>>>
>>>
>>>
>>> HamletDRC wrote:
>>>
>>>> Hi Glenn,
>>>>
>>>> Thanks for the answer!
>>>>
>>>> I do indeed need to include the <compc> tag in echoxml because without
>>>> it
>>>> there is no root tag and so the xml is malformed.
>>>>
>>>>
>>>>
>>>> glenn opdycke-hansen wrote:
>>>>
>>>>> I would try the following approach: (1) write the value to a file and
>>>>> (2)
>>>>> import the file back to the Ant script.
>>>>> Perhaps something like this.
>>>>>
>>>>> <echoxml file="foo.xml">
>>>>> <include>bar.as</include>
>>>>> <include>baz.as</include>
>>>>> </echoxml>
>>>>>
>>>>> ...
>>>>> <compc>
>>>>> <import file="foo.xml"/>
>>>>> </compc>
>>>>>
>>>>> The <compc> </compc> might need to be included in the <echoxml>
>>>>>
>>>>> --glenn
>>>>>
>>>>> On Thu, Jul 16, 2009 at 15:56, HamletDRC <ha...@gmail.com> wrote:
>>>>>
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Is it possible to do this?
>>>>>>
>>>>>> I have a property that contains two XML elements as a String:
>>>>>>
>>>>>> <property name="foo"
>>>>>> value="<include>bar.as</include><include>baz.as
>>>>>> </include>"
>>>>>> />
>>>>>>
>>>>>> And I want it expanded into the execution of a task as if I wrote
>>>>>> this:
>>>>>>
>>>>>> <compc>
>>>>>> <include>bar.as</include>
>>>>>> <include>baz.as</include>
>>>>>> </compc>
>>>>>>
>>>>>> I expected this to work:
>>>>>> <compc>
>>>>>> ${foo}
>>>>>> </compc>
>>>>>>
>>>>>> But I get the error:
>>>>>> The <compc> type doesn't support nested text data ("${foo}").
>>>>>>
>>>>>> I'm assuming this isn't an error with "compc" but is instead in error
>>>>>>
>>> in
>>>
>>>>>> how
>>>>>> I'm expanding ${foo}.
>>>>>>
>>>>>> Can I do this in Ant?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> -----
>>>>>> --
>>>>>> Hamlet D'Arcy
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>>
>>>>>>
>>> http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24524324.html
>>>
>>>>>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>>>>> For additional commands, e-mail: user-help@ant.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>> -----
>>> --
>>> Hamlet D'Arcy
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24535716.html
>>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: user-help@ant.apache.org
>>>
>>>
>>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>
-----
--
Hamlet D'Arcy
--
View this message in context: http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24536597.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: write property as part of task definition
Posted by Michael George <md...@cs.cornell.edu>.
Another possibility is to create a template file foo.xml.in and use copy
with substitutions:
--- foo.xml.in ----
<project>
<include>@file1@</include>
<include>@file2@</include>
</project>
--- build.xml ---
<copy from="foo.xml.in" to="foo.xml">
<filterset>
<filter token="file1" value="bar.as" />
<filter token="file2" value="baz.as" />
</filterset>
</copy>
<import file="foo.xml" />
I'm not sure if this would accomplish what you want.
--Mike
glenn opdycke-hansen wrote:
> Then use <echo> to write to write to the file.
> --glenn
>
> On Fri, Jul 17, 2009 at 09:38, HamletDRC <ha...@gmail.com> wrote:
>
>
>> Sorry, but this isn't going to work.
>>
>> Both echo and echoxml escapes the brackets in the property that contains
>> XML.
>>
>>
>>
>>
>>
>> HamletDRC wrote:
>>
>>> Hi Glenn,
>>>
>>> Thanks for the answer!
>>>
>>> I do indeed need to include the <compc> tag in echoxml because without it
>>> there is no root tag and so the xml is malformed.
>>>
>>>
>>>
>>> glenn opdycke-hansen wrote:
>>>
>>>> I would try the following approach: (1) write the value to a file and
>>>> (2)
>>>> import the file back to the Ant script.
>>>> Perhaps something like this.
>>>>
>>>> <echoxml file="foo.xml">
>>>> <include>bar.as</include>
>>>> <include>baz.as</include>
>>>> </echoxml>
>>>>
>>>> ...
>>>> <compc>
>>>> <import file="foo.xml"/>
>>>> </compc>
>>>>
>>>> The <compc> </compc> might need to be included in the <echoxml>
>>>>
>>>> --glenn
>>>>
>>>> On Thu, Jul 16, 2009 at 15:56, HamletDRC <ha...@gmail.com> wrote:
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> Is it possible to do this?
>>>>>
>>>>> I have a property that contains two XML elements as a String:
>>>>>
>>>>> <property name="foo"
>>>>> value="<include>bar.as</include><include>baz.as
>>>>> </include>"
>>>>> />
>>>>>
>>>>> And I want it expanded into the execution of a task as if I wrote this:
>>>>>
>>>>> <compc>
>>>>> <include>bar.as</include>
>>>>> <include>baz.as</include>
>>>>> </compc>
>>>>>
>>>>> I expected this to work:
>>>>> <compc>
>>>>> ${foo}
>>>>> </compc>
>>>>>
>>>>> But I get the error:
>>>>> The <compc> type doesn't support nested text data ("${foo}").
>>>>>
>>>>> I'm assuming this isn't an error with "compc" but is instead in error
>>>>>
>> in
>>
>>>>> how
>>>>> I'm expanding ${foo}.
>>>>>
>>>>> Can I do this in Ant?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -----
>>>>> --
>>>>> Hamlet D'Arcy
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>>
>>>>>
>> http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24524324.html
>>
>>>>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>>>> For additional commands, e-mail: user-help@ant.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>
>> -----
>> --
>> Hamlet D'Arcy
>>
>> --
>> View this message in context:
>> http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24535716.html
>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: write property as part of task definition
Posted by glenn opdycke-hansen <gl...@gmail.com>.
Then use <echo> to write to write to the file.
--glenn
On Fri, Jul 17, 2009 at 09:38, HamletDRC <ha...@gmail.com> wrote:
>
> Sorry, but this isn't going to work.
>
> Both echo and echoxml escapes the brackets in the property that contains
> XML.
>
>
>
>
>
> HamletDRC wrote:
> >
> > Hi Glenn,
> >
> > Thanks for the answer!
> >
> > I do indeed need to include the <compc> tag in echoxml because without it
> > there is no root tag and so the xml is malformed.
> >
> >
> >
> > glenn opdycke-hansen wrote:
> >>
> >> I would try the following approach: (1) write the value to a file and
> >> (2)
> >> import the file back to the Ant script.
> >> Perhaps something like this.
> >>
> >> <echoxml file="foo.xml">
> >> <include>bar.as</include>
> >> <include>baz.as</include>
> >> </echoxml>
> >>
> >> ...
> >> <compc>
> >> <import file="foo.xml"/>
> >> </compc>
> >>
> >> The <compc> </compc> might need to be included in the <echoxml>
> >>
> >> --glenn
> >>
> >> On Thu, Jul 16, 2009 at 15:56, HamletDRC <ha...@gmail.com> wrote:
> >>
> >>>
> >>> Hi,
> >>>
> >>> Is it possible to do this?
> >>>
> >>> I have a property that contains two XML elements as a String:
> >>>
> >>> <property name="foo"
> >>> value="<include>bar.as</include><include>baz.as
> >>> </include>"
> >>> />
> >>>
> >>> And I want it expanded into the execution of a task as if I wrote this:
> >>>
> >>> <compc>
> >>> <include>bar.as</include>
> >>> <include>baz.as</include>
> >>> </compc>
> >>>
> >>> I expected this to work:
> >>> <compc>
> >>> ${foo}
> >>> </compc>
> >>>
> >>> But I get the error:
> >>> The <compc> type doesn't support nested text data ("${foo}").
> >>>
> >>> I'm assuming this isn't an error with "compc" but is instead in error
> in
> >>> how
> >>> I'm expanding ${foo}.
> >>>
> >>> Can I do this in Ant?
> >>>
> >>>
> >>>
> >>>
> >>> -----
> >>> --
> >>> Hamlet D'Arcy
> >>>
> >>> --
> >>> View this message in context:
> >>>
> http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24524324.html
> >>> Sent from the Ant - Users mailing list archive at Nabble.com.
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> >>> For additional commands, e-mail: user-help@ant.apache.org
> >>>
> >>>
> >>
> >>
> >
> >
>
>
> -----
> --
> Hamlet D'Arcy
>
> --
> View this message in context:
> http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24535716.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
Re: write property as part of task definition
Posted by HamletDRC <ha...@gmail.com>.
Sorry, but this isn't going to work.
Both echo and echoxml escapes the brackets in the property that contains
XML.
HamletDRC wrote:
>
> Hi Glenn,
>
> Thanks for the answer!
>
> I do indeed need to include the <compc> tag in echoxml because without it
> there is no root tag and so the xml is malformed.
>
>
>
> glenn opdycke-hansen wrote:
>>
>> I would try the following approach: (1) write the value to a file and
>> (2)
>> import the file back to the Ant script.
>> Perhaps something like this.
>>
>> <echoxml file="foo.xml">
>> <include>bar.as</include>
>> <include>baz.as</include>
>> </echoxml>
>>
>> ...
>> <compc>
>> <import file="foo.xml"/>
>> </compc>
>>
>> The <compc> </compc> might need to be included in the <echoxml>
>>
>> --glenn
>>
>> On Thu, Jul 16, 2009 at 15:56, HamletDRC <ha...@gmail.com> wrote:
>>
>>>
>>> Hi,
>>>
>>> Is it possible to do this?
>>>
>>> I have a property that contains two XML elements as a String:
>>>
>>> <property name="foo"
>>> value="<include>bar.as</include><include>baz.as
>>> </include>"
>>> />
>>>
>>> And I want it expanded into the execution of a task as if I wrote this:
>>>
>>> <compc>
>>> <include>bar.as</include>
>>> <include>baz.as</include>
>>> </compc>
>>>
>>> I expected this to work:
>>> <compc>
>>> ${foo}
>>> </compc>
>>>
>>> But I get the error:
>>> The <compc> type doesn't support nested text data ("${foo}").
>>>
>>> I'm assuming this isn't an error with "compc" but is instead in error in
>>> how
>>> I'm expanding ${foo}.
>>>
>>> Can I do this in Ant?
>>>
>>>
>>>
>>>
>>> -----
>>> --
>>> Hamlet D'Arcy
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24524324.html
>>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: user-help@ant.apache.org
>>>
>>>
>>
>>
>
>
-----
--
Hamlet D'Arcy
--
View this message in context: http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24535716.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: write property as part of task definition
Posted by Michael George <md...@cs.cornell.edu>.
HamletDRC wrote:
> Hi Glenn,
>
> Thanks for the answer!
>
> I do indeed need to include the <compc> tag in echoxml because without it
> there is no root tag and so the xml is malformed.
>
import strips off a <project> tag, so you could alternatively use that.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: write property as part of task definition
Posted by HamletDRC <ha...@gmail.com>.
Hi Glenn,
Thanks for the answer!
I do indeed need to include the <compc> tag in echoxml because without it
there is no root tag and so the xml is malformed.
glenn opdycke-hansen wrote:
>
> I would try the following approach: (1) write the value to a file and (2)
> import the file back to the Ant script.
> Perhaps something like this.
>
> <echoxml file="foo.xml">
> <include>bar.as</include>
> <include>baz.as</include>
> </echoxml>
>
> ...
> <compc>
> <import file="foo.xml"/>
> </compc>
>
> The <compc> </compc> might need to be included in the <echoxml>
>
> --glenn
>
> On Thu, Jul 16, 2009 at 15:56, HamletDRC <ha...@gmail.com> wrote:
>
>>
>> Hi,
>>
>> Is it possible to do this?
>>
>> I have a property that contains two XML elements as a String:
>>
>> <property name="foo"
>> value="<include>bar.as</include><include>baz.as
>> </include>"
>> />
>>
>> And I want it expanded into the execution of a task as if I wrote this:
>>
>> <compc>
>> <include>bar.as</include>
>> <include>baz.as</include>
>> </compc>
>>
>> I expected this to work:
>> <compc>
>> ${foo}
>> </compc>
>>
>> But I get the error:
>> The <compc> type doesn't support nested text data ("${foo}").
>>
>> I'm assuming this isn't an error with "compc" but is instead in error in
>> how
>> I'm expanding ${foo}.
>>
>> Can I do this in Ant?
>>
>>
>>
>>
>> -----
>> --
>> Hamlet D'Arcy
>>
>> --
>> View this message in context:
>> http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24524324.html
>> Sent from the Ant - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>>
>
>
-----
--
Hamlet D'Arcy
--
View this message in context: http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24535111.html
Sent from the Ant - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: write property as part of task definition
Posted by glenn opdycke-hansen <gl...@gmail.com>.
I would try the following approach: (1) write the value to a file and (2)
import the file back to the Ant script.
Perhaps something like this.
<echoxml file="foo.xml">
<include>bar.as</include>
<include>baz.as</include>
</echoxml>
...
<compc>
<import file="foo.xml"/>
</compc>
The <compc> </compc> might need to be included in the <echoxml>
--glenn
On Thu, Jul 16, 2009 at 15:56, HamletDRC <ha...@gmail.com> wrote:
>
> Hi,
>
> Is it possible to do this?
>
> I have a property that contains two XML elements as a String:
>
> <property name="foo"
> value="<include>bar.as</include><include>baz.as
> </include>"
> />
>
> And I want it expanded into the execution of a task as if I wrote this:
>
> <compc>
> <include>bar.as</include>
> <include>baz.as</include>
> </compc>
>
> I expected this to work:
> <compc>
> ${foo}
> </compc>
>
> But I get the error:
> The <compc> type doesn't support nested text data ("${foo}").
>
> I'm assuming this isn't an error with "compc" but is instead in error in
> how
> I'm expanding ${foo}.
>
> Can I do this in Ant?
>
>
>
>
> -----
> --
> Hamlet D'Arcy
>
> --
> View this message in context:
> http://www.nabble.com/write-property-as-part-of-task-definition-tp24524324p24524324.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>