You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Chuck Holzwarth <ch...@yahoo.com> on 2007/11/27 19:15:44 UTC
Variables and zip file comments
The builds I do are differential builds. I use svn diff to gather the diffs. The system is composed of several modules. Each module goes into its own zip file. When code is released, the zip files require a comment that contains, among other things, the names of all of the zip files that are part of the release.
I have been trying to set a variable with the list of module file names. The problem I have is that when the target where I set the variable exits, the variable reverts to the previous value. Is there a way to make a variable persistent?
In the mean time, I have been creating a file that contains the zip file comment. I have not been able to insert the comment in the zip file using the zip comment function.
Can anyone provide an example of reading a file, carriage returns and all, into a variable or property and adding to the zip file as a comment?
Can anyone provide an example of using the zip target to add the contents of a file to the zip file as a comment?
Thank you,
Chuck Holzwarth
____________________________________________________________________________________
Be a better sports nut! Let your teams follow you
with Yahoo Mobile. Try it now. http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
Re: Variables and zip file comments
Posted by David Weintraub <qa...@gmail.com>.
You cannot reset the value of a property. They are not variables because
they don't vary. Once you set the value of a property, you cannot change it.
There are a couple of ways to handle what you want:
* Use <antcall> or <macrodef>. These allow you to pass parameters that will
set properties inside the calls. See the example below.
* Use the AntContrib's variable task. This (unlike <properties> is a true
variable.
See http://ant-contrib.sourceforge.net/tasks/tasks/variable_task.html
Here's how to use <antcall> to be able to change the comment. <macrodef> is
very similar:
<target name="main">
<antcall target="ziptask">
<param name="zipComment" value="Comment #1"/>
<param name="zipDir" value="mydir1"/>
<param name="zipName" value="zip1.zip"/>
</antcall>
<antcall task="ziptask">
<param name="zipComment" value="Comment #2"/>
<param name="zipDir" value="mydir2"/>
<param name="zipName" value="zip2.zip"/>
</antcall>
</target>
<target name="ziptask">
<zip destfile="${zipName}"
basedir="${zipDir}"
comment="${zipComment}"/>
</target>
On Nov 27, 2007 1:15 PM, Chuck Holzwarth <ch...@yahoo.com> wrote:
> The builds I do are differential builds. I use svn diff to gather the
> diffs. The system is composed of several modules. Each module goes into its
> own zip file. When code is released, the zip files require a comment that
> contains, among other things, the names of all of the zip files that are
> part of the release.
>
> I have been trying to set a variable with the list of module file names.
> The problem I have is that when the target where I set the variable exits,
> the variable reverts to the previous value. Is there a way to make a
> variable persistent?
>
> In the mean time, I have been creating a file that contains the zip file
> comment. I have not been able to insert the comment in the zip file using
> the zip comment function.
> Can anyone provide an example of reading a file, carriage returns and all,
> into a variable or property and adding to the zip file as a comment?
> Can anyone provide an example of using the zip target to add the contents
> of a file to the zip file as a comment?
>
> Thank you,
> Chuck Holzwarth
>
>
>
>
>
> ____________________________________________________________________________________
> Be a better sports nut! Let your teams follow you
> with Yahoo Mobile. Try it now.
> http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
>
--
--
David Weintraub
qazwart@gmail.com