You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Erica A Ramsey <ea...@wideopenwest.com> on 2007/06/16 15:59:07 UTC

buiild.xml & ant

hello, it's me again with another problem. I am using tasks provided by oem.
One of these tasks is the <ndspackage> task. Inside this task I specify
resource files as follows;

<ndspackage>
   <resource name="image1.png" />
</ndspackage>

Problem is that I have a macrodef that generates resources. I don't know the
names of the resource files ahead of time. And they need to specified inside
of the <ndspackage>; however, I can't nest anything ant tasks, for example
<fileset>,  inside of it to include the generated files. I even tried using
a macrodef inside of it and that didn't work either.

Is there a way to have "ant" preprocess the "build.xml" and have it expand a
symbol, whose value that I define, before invoking the <ndspackage> task?
Then I would have the generate resource <macrodef> to create a tmp file and
append it with the string "<resource name=\"some_generated_rsc.rsc\"/>".
Then I would use the <loadfile> to read in the element tags into an symbol.
(I put '<resource name="..." />' and load them into symbol with <loadfile>
because I can't specify "< or >" inside of "value=" of <property> task. )
Then I would add the following line to build file;

<ndspackage>
   @expand ${generated_resources}
   <resource name="image1.png" />
</ndspackage>

"ant" would expand it into

<target name="package" depends="compile">
  <ndspackage>
     <resource name="gen1.rsc" /><resource name="gen2.rsc" />
     <resource name="image1.png" />
  </ndspackage>
</target>

and invoke the <ndspackate> task and it couldn't complain because the data
was expanded before it was invoked.

Also, I was thinking about creating selfmodifying build file that would
first <copy> itself, using <replaceregex>, looking  for the "<-- @replace
me -->" pattern and substitute it with the <resource name=".."/> tags. It
would copy it to an intermediate build file, build.tmp, and then invoke ant
on it with the command argument -Dnocopy. This argument would flag the new
build file not to copy itself again so I don't go into an infinite loop, of
course I could always strip out the self copy tasks as well. I think that
this might work but I prefer to use the first method.

Please, If someone knows a better way please help me. Please note that I am
trying to use "ant 1.6.1" because that is the environment it must run in.

Thanks!
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.17/850 - Release Date: 6/15/2007
11:31 AM


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: buiild.xml & ant

Posted by David Kavanagh <dk...@gmail.com>.
I know this isn't helpful, but it sounds like the OEM didn't write a
proper ant task. They should have taken a <fileset> or something
similar in their task so you could take advantage of all the nice
things Ant provides. Is there any way to get the source for the
ndspackage task?  Ant tasks are pretty trivial to write, so taking the
working guts from their task and putting into a proper ant task
shouldn't be that hard.

David

On 6/16/07, Erica A Ramsey <ea...@wideopenwest.com> wrote:
> hello, it's me again with another problem. I am using tasks provided by oem.
> One of these tasks is the <ndspackage> task. Inside this task I specify
> resource files as follows;
>
> <ndspackage>
>    <resource name="image1.png" />
> </ndspackage>
>
> Problem is that I have a macrodef that generates resources. I don't know the
> names of the resource files ahead of time. And they need to specified inside
> of the <ndspackage>; however, I can't nest anything ant tasks, for example
> <fileset>,  inside of it to include the generated files. I even tried using
> a macrodef inside of it and that didn't work either.
>
> Is there a way to have "ant" preprocess the "build.xml" and have it expand a
> symbol, whose value that I define, before invoking the <ndspackage> task?
> Then I would have the generate resource <macrodef> to create a tmp file and
> append it with the string "<resource name=\"some_generated_rsc.rsc\"/>".
> Then I would use the <loadfile> to read in the element tags into an symbol.
> (I put '<resource name="..." />' and load them into symbol with <loadfile>
> because I can't specify "< or >" inside of "value=" of <property> task. )
> Then I would add the following line to build file;
>
> <ndspackage>
>    @expand ${generated_resources}
>    <resource name="image1.png" />
> </ndspackage>
>
> "ant" would expand it into
>
> <target name="package" depends="compile">
>   <ndspackage>
>      <resource name="gen1.rsc" /><resource name="gen2.rsc" />
>      <resource name="image1.png" />
>   </ndspackage>
> </target>
>
> and invoke the <ndspackate> task and it couldn't complain because the data
> was expanded before it was invoked.
>
> Also, I was thinking about creating selfmodifying build file that would
> first <copy> itself, using <replaceregex>, looking  for the "<-- @replace
> me -->" pattern and substitute it with the <resource name=".."/> tags. It
> would copy it to an intermediate build file, build.tmp, and then invoke ant
> on it with the command argument -Dnocopy. This argument would flag the new
> build file not to copy itself again so I don't go into an infinite loop, of
> course I could always strip out the self copy tasks as well. I think that
> this might work but I prefer to use the first method.
>
> Please, If someone knows a better way please help me. Please note that I am
> trying to use "ant 1.6.1" because that is the environment it must run in.
>
> Thanks!
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.472 / Virus Database: 269.8.17/850 - Release Date: 6/15/2007
> 11:31 AM
>
>
> ---------------------------------------------------------------------
> 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: buiild.xml & ant

Posted by Bill Rich <bi...@wilandra.com>.
Hello Erica,
Have you tried to use the <apply> task? It might help here to <apply> 
your <ndspackage> task to each file in a list.

If that does not work and you are not opposed to adding antcontrib to 
your process, the following example may help using the <for> task from 
antcontrib.
|<ac:for list="${projXLFileList}"
         delimiter=";"
         param="targetfile">
|  <sequential>
|   <getoutputname listitem="@{targetfile}"
                  property="file.ci.@{targetfile}"/>
   ||   <copy tofile="${TARGETFILESDIR}/${PRODUCT}/${file.ci.@{targetfile}}"
         file="${PRODUCT}/${file.ci.@{targetfile}}"/>
   |   </sequential>
|  </ac:for>

In the example,
||projXLFileList is a semi-colon delimited list of file information 
where each element contains several forms of the file name (one being 
the desired output file name),
||||getoutputname  is a macro that knows how to extract the desired 
output file name from an element of the list

HTH Bill

|||
Erica A Ramsey wrote:
> hello, it's me again with another problem. I am using tasks provided by oem.
> One of these tasks is the <ndspackage> task. Inside this task I specify
> resource files as follows;
>
> <ndspackage>
>    <resource name="image1.png" />
> </ndspackage>
>
> Problem is that I have a macrodef that generates resources. I don't know the
> names of the resource files ahead of time. And they need to specified inside
> of the <ndspackage>; however, I can't nest anything ant tasks, for example
> <fileset>,  inside of it to include the generated files. I even tried using
> a macrodef inside of it and that didn't work either.
>
> Is there a way to have "ant" preprocess the "build.xml" and have it expand a
> symbol, whose value that I define, before invoking the <ndspackage> task?
> Then I would have the generate resource <macrodef> to create a tmp file and
> append it with the string "<resource name=\"some_generated_rsc.rsc\"/>".
> Then I would use the <loadfile> to read in the element tags into an symbol.
> (I put '<resource name="..." />' and load them into symbol with <loadfile>
> because I can't specify "< or >" inside of "value=" of <property> task. )
> Then I would add the following line to build file;
>
> <ndspackage>
>    @expand ${generated_resources}
>    <resource name="image1.png" />
> </ndspackage>
>
> "ant" would expand it into
>
> <target name="package" depends="compile">
>   <ndspackage>
>      <resource name="gen1.rsc" /><resource name="gen2.rsc" />
>      <resource name="image1.png" />
>   </ndspackage>
> </target>
>
> and invoke the <ndspackate> task and it couldn't complain because the data
> was expanded before it was invoked.
>
> Also, I was thinking about creating selfmodifying build file that would
> first <copy> itself, using <replaceregex>, looking  for the "<-- @replace
> me -->" pattern and substitute it with the <resource name=".."/> tags. It
> would copy it to an intermediate build file, build.tmp, and then invoke ant
> on it with the command argument -Dnocopy. This argument would flag the new
> build file not to copy itself again so I don't go into an infinite loop, of
> course I could always strip out the self copy tasks as well. I think that
> this might work but I prefer to use the first method.
>
> Please, If someone knows a better way please help me. Please note that I am
> trying to use "ant 1.6.1" because that is the environment it must run in.
>
> Thanks!
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.472 / Virus Database: 269.8.17/850 - Release Date: 6/15/2007
> 11:31 AM
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>
>