ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chuck Holzwarth <chuck_holzwa...@yahoo.com>
Subject Re: Variables and zip file comments
Date Wed, 28 Nov 2007 13:53:16 GMT
David,
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"/>
<sequential>
    <antcall target="__compile_module">
        <param name="module" value="@this_module">
      </antcall>
    <var name="been_here" unset="true"/>
    <var name="been_here" value="true"/>
</sequential>
</for>
</target>

<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>


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

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 <qazwart@gmail.com>
To: Ant Users List <user@ant.apache.org>
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
 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 <chuck_holzwarth@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






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