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: newbie question: variable scope
Date Tue, 11 Dec 2007 17:18:40 GMT
I have had the same problem. The following target shows how I got around the problem. Since
I have to do differential builds I can't predict the number of zip files that are produced,
so I check for the existence of the file before calling this target. When I need the list
of files, to create the release notes, I load the property file that was created with the
list of files. The following code shows an example of this.


<if>
            <available file="${diff_file}"/>
        <then>
<antcall target="__create_zip_file_list">
                <param name="__PropertyName" value="diff@{index}_file_list"/>
                <param name="__zFlistFname" value="${release_dir}/diff@{index}/${diff_comment_file_list_name}"/>
                <param name="__zFileToAdd" value="${diff_file_name}"/>
            </antcall>
</then>
</if>

<target name="__create_zip_file_list">
    <!--
    #######################################################################################################################################
    TARGET: __create_zip_file_list
    Purpose:  This target takes the zip file list file path with name and the name of the
zip file to add as parameters. If the zip file is
            the first file in the list, the name of the property is inserted followed by the
fiel name. If the file is not the first one,
            a "," followed by the file name is appended.
    Inputs: __zFlistFname - the path and name of the zip file list
            __zFileToAdd - the zip file name to add
            __PropertyName - the name of the property to use
    See: release, release_diff
    #######################################################################################################################################
    -->
        <if>
                <available file="${__zFlistFname}"/>
            <then>
                <echo file="${__zFlistFname}" append="true">,${__zFileToAdd}</echo>
            </then>
            <else>
                <echo file="${__zFlistFname}">${__PropertyName}=${__zFileToAdd}</echo>
            </else>
            </if>
    </target>


<loadproperties srcfile="${release_dir}/diff@{index}/comment_FileList_${build_time}.properties"/>
                <antcall target="__comment_zip_file">
                    <param name="__zFpath" value="${release_dir}/diff@{index}"/>
                    <param name="__zFlist" value="${diff@{index}_file_list}"/>
                </antcall>

Hudson Ansley <hudsonansley@gmail.com> wrote: that did the trick, thanks again! Now,
what I thought might be a
better solution than using "var" was to create a "filelist" and add
files to this construct and then use it by ref in the upload target. I
thought creating an empty "filelist" then using it's refid to add
files might work, but it seems that it does not. I assume this is just
not how "filelist" works, any insights or alternative suggestions
welcome.

This is the code I was attempting:

in target#0 (main build target)
  
  
in target#1 (if data translation happens)
  
   
  
in target#2 (if compilation happens)
  
   
  
in target#3 (upload target)
  

Regards,
Hudson

On Dec 11, 2007 10:59 AM, Hudson Ansley  wrote:
> yes, I am using  thanks so much for your explanation and
> suggestion - sounds like a winner!
> Regards,
> Hudson
>
>
> On Dec 11, 2007 10:56 AM, Peter Reilly 
 wrote:
> > You are most likely using or  to call the other targers
> > this causes a new ant project to be created. porjects created in or modified in
> > the child projects have no effect on the properties in the main project.
> >
> > You can use  from antcontrib to run the targets in the
> > same project.
> >
> > Peter
> >
>

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





Thank you,
Chuck Holzwarth
(804) 403-3478 (home)
(540) 335-3171 (cell)
       
---------------------------------
Be a better friend, newshound, and know-it-all with Yahoo! Mobile.  Try it now.
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message