ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chuck Holzwarth <>
Subject Re: Variables and zip file comments
Date Wed, 28 Nov 2007 13:53:16 GMT
Thank you. I am using the contrib var task. That is the one where I am seeing scoping constraints.
What I am now programming is a variable that is set and checked.

module list is defined in a property file.

<target name="top_level">
<var name="been_here" value="false"/>
<for list="${modules} param="this_module" trim="true"/>
    <antcall target="__compile_module">
        <param name="module" value="@this_module">
    <var name="been_here" unset="true"/>
    <var name="been_here" value="true"/>

<target name="__compile_module">
generate file name and store it in the variable this_file. Call any required targets then:
<antcall target="__build_file_list"/>

<target name="__build_file_list">
    <equals arg1="${been_here} arg2="true"/>
    <echo file="the_file.prop">,${this_file}</echo>
    <echo file="the_files.prop">file_list=${this_file}</echo>

At the end of the build, I use loadproperties to load the_files.prop. Then I iterate through
the file_list and add the zip file comment to each of the files.

I was hoping for an easier way to do this, but I have something workable.
Thank you,
Chuck Holzwarth
(804) 403-3478 (home)
(540) 335-3171 (cell)

----- Original Message ----
From: David Weintraub <>
To: Ant Users List <>
Sent: Tuesday, November 27, 2007 8:00:02 PM
Subject: Re: Variables and zip file comments

You cannot reset the value of a property. They are not variables
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
set properties inside the calls. See the example below.

* Use the AntContrib's variable task. This (unlike <properties> is a

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=""/>

    <antcall task="ziptask">
        <param name="zipComment" value="Comment #2"/>
        <param name="zipDir" value="mydir2"/>
        <param name="zipName" value=""/>

<target name="ziptask">
    <zip destfile="${zipName}"

On Nov 27, 2007 1:15 PM, Chuck Holzwarth <>

> 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
> contains, among other things, the names of all of the zip files that
> part of the release.
> I have been trying to set a variable with the list of module file
> The problem I have is that when the target where I set the variable
> 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
> comment. I have not been able to insert the comment in the zip file
> the zip comment function.
> Can anyone provide an example of reading a file, carriage returns and
> 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
> 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.

David Weintraub

Be a better sports nut!  Let your teams follow you 
with Yahoo Mobile. Try it now.;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message