You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Hudson Ansley <hu...@gmail.com> on 2007/12/11 16:33:06 UTC
newbie question: variable scope
I'm trying to use the discouraged "var" to keep track of updated files
for a final upload step. It appears that when I change a variable in
one target, that change is not reflected from another target. I
imagine I am going about this the wrong way, so besides explaining why
this might be happening, a suggestion for a different approach would
also be welcome. Here is exactly what I'm doing
1) conditionally compile from source (if source has changed)
2) conditionally create a file using XSLT (if source changed)
3) upload one or both of those files, or don't even bother to open a
connection if neither has been updated.
#3 is where I'm having problems. I thought I could gather the
respective files in a string in the targets for 1 & 2 and use that in
this target, but that is where I am running into issues with changes
made in a var in #1 and #2 not showing in #3
Thanks in advance for any help - I'm sure I'm missing something
simple, but I did go over the help and search old messages before
posting
Regards,
Hudson
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: newbie question: variable scope
Posted by David Weintraub <qa...@gmail.com>.
When you say "upload", what do you mean? Are you using "ftp" or "scp"
to move the files from your system to another system?
If so, you probably would be better off using the AntContrib
<outofdate> task or the <uptodate> task to determine whether or not to
move these files to another system than trying to save their names
into a property.
On Dec 11, 2007 10:33 AM, Hudson Ansley <hu...@gmail.com> wrote:
> I'm trying to use the discouraged "var" to keep track of updated files
> for a final upload step. It appears that when I change a variable in
> one target, that change is not reflected from another target. I
> imagine I am going about this the wrong way, so besides explaining why
> this might be happening, a suggestion for a different approach would
> also be welcome. Here is exactly what I'm doing
>
> 1) conditionally compile from source (if source has changed)
>
> 2) conditionally create a file using XSLT (if source changed)
>
> 3) upload one or both of those files, or don't even bother to open a
> connection if neither has been updated.
>
> #3 is where I'm having problems. I thought I could gather the
> respective files in a string in the targets for 1 & 2 and use that in
> this target, but that is where I am running into issues with changes
> made in a var in #1 and #2 not showing in #3
>
> Thanks in advance for any help - I'm sure I'm missing something
> simple, but I did go over the help and search old messages before
> posting
> Regards,
> Hudson
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
--
--
David Weintraub
qazwart@gmail.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: newbie question: variable scope
Posted by Krzysztof Kucybala <kk...@echo.fr>.
Don't know what Your ant file looks like, but I'd try to employ the
antcontrib's antcallback task - it calls another target and lets it
return a property (more than one actually) to the target, who made the
call. Does that help?
Best regards,
Chris
Hudson Ansley wrote:
> I'm trying to use the discouraged "var" to keep track of updated files
> for a final upload step. It appears that when I change a variable in
> one target, that change is not reflected from another target. I
> imagine I am going about this the wrong way, so besides explaining why
> this might be happening, a suggestion for a different approach would
> also be welcome. Here is exactly what I'm doing
>
> 1) conditionally compile from source (if source has changed)
>
> 2) conditionally create a file using XSLT (if source changed)
>
> 3) upload one or both of those files, or don't even bother to open a
> connection if neither has been updated.
>
> #3 is where I'm having problems. I thought I could gather the
> respective files in a string in the targets for 1 & 2 and use that in
> this target, but that is where I am running into issues with changes
> made in a var in #1 and #2 not showing in #3
>
> Thanks in advance for any help - I'm sure I'm missing something
> simple, but I did go over the help and search old messages before
> posting
> Regards,
> Hudson
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
--
Krzysztof Kucybala
Software Engineer
GFI Informatique for
Orange - France Telecom Group
790 avenue du docteur Maurice Donat
Batiment Marco Polo - D1
06250 Sophia-Antipolis
email: kkucybala@echo.fr
tel: 04.97.12.62.05
fax: 04.92.28.13.31
skype: krzysztof.kucybala
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: newbie question: variable scope
Posted by Hudson Ansley <hu...@gmail.com>.
Hello, I just wanted to thank this list and Peter, David, Krzysztof
and Chuck in particular for responding to my question. I am very
impressed with the quick response, helpful information and respectful
tone.
Best Regards,
Hudson
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: newbie question: variable scope
Posted by Chuck Holzwarth <ch...@yahoo.com>.
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 <hu...@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.
Re: newbie question: variable scope
Posted by Hudson Ansley <hu...@gmail.com>.
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)
<filelist id="uploadList" dir=".">
</filelist>
in target#1 (if data translation happens)
<filelist refid="uploadList">
<file name="${dataOutFile}"/>
</filelist>
in target#2 (if compilation happens)
<filelist refid="uploadList">
<file name="${outputFile}"/>
</filelist>
in target#3 (upload target)
<filelist refid="uploadList" />
Regards,
Hudson
On Dec 11, 2007 10:59 AM, Hudson Ansley <hu...@gmail.com> wrote:
> yes, I am using <antcall> thanks so much for your explanation and
> suggestion - sounds like a winner!
> Regards,
> Hudson
>
>
> On Dec 11, 2007 10:56 AM, Peter Reilly <pe...@gmail.com> wrote:
> > You are most likely using <ant>or <antcall> 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 <runtarget> 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
Re: newbie question: variable scope
Posted by Hudson Ansley <hu...@gmail.com>.
yes, I am using <antcall> thanks so much for your explanation and
suggestion - sounds like a winner!
Regards,
Hudson
On Dec 11, 2007 10:56 AM, Peter Reilly <pe...@gmail.com> wrote:
> You are most likely using <ant>or <antcall> 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 <runtarget> 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
Re: newbie question: variable scope
Posted by Peter Reilly <pe...@gmail.com>.
You are most likely using <ant>or <antcall> 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 <runtarget> from antcontrib to run the targets in the
same project.
Peter
On Dec 11, 2007 3:33 PM, Hudson Ansley <hu...@gmail.com> wrote:
> I'm trying to use the discouraged "var" to keep track of updated files
> for a final upload step. It appears that when I change a variable in
> one target, that change is not reflected from another target. I
> imagine I am going about this the wrong way, so besides explaining why
> this might be happening, a suggestion for a different approach would
> also be welcome. Here is exactly what I'm doing
>
> 1) conditionally compile from source (if source has changed)
>
> 2) conditionally create a file using XSLT (if source changed)
>
> 3) upload one or both of those files, or don't even bother to open a
> connection if neither has been updated.
>
> #3 is where I'm having problems. I thought I could gather the
> respective files in a string in the targets for 1 & 2 and use that in
> this target, but that is where I am running into issues with changes
> made in a var in #1 and #2 not showing in #3
>
> Thanks in advance for any help - I'm sure I'm missing something
> simple, but I did go over the help and search old messages before
> posting
> Regards,
> Hudson
>
> ---------------------------------------------------------------------
> 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