On 1/23/11 10:12 PM, Michael Ludwig wrote:
> Laurence Mills-Gahl schrieb am 23.01.2011 um 21:27 (-0500):
>> I have an ant exec task that is behaving inconsistently.
>>
>> I have a list of centerid's and a "foreach" loop
> Red flag goes up …

What is the red flag?


>> that calls the following target:
>>
>>     <target name="compile_alert_report" description="compile  detail
>> report for alerts">
>>         <echo>patient detail for patients NOT on alert for center
>> ${centerid}</echo>
> Alert: Properties aren't variable. They're immutable. Their value does
> not change once set.


The foreach task (from Ant-Contrib) passes a parameter to the target
task. The ${centerid} is echoed on the target of the loop and it is
indeed changing as I would expect it to...
For example

<target name="generate_reports">
<foreach target="generate_reports_for_center" param="centerid"
list="${centerlist}" />
</target>

<target name="generate_reports_for_center" description="generate reports
for a particular centerid">
        <echo>generating reports for center ${centerid} through
${report.enddategraphs}</echo>
        <antcall target="compile_patient_detail_report">
            <param name="centerid" value="${centerid}" />
        </antcall>
    [...]
</target>

    <target name="compile_patient_detail_report" 
depends="render_graphs_for_center">

        <antcall target="compile_patients_on_alert">
            <param name="centerid" value="${centerid}" />
        </antcall>
      [...]
    </target>

    <target name="compile_patients_on_alert" description="compile
patient detail report for patients on alert">
        <echo>patient detail for alerting patients for center
${centerid}</echo>
        <echo message=" reportPatientDetail.pl -e ${report.enddate} -c
${centerid} -o ${report.xml}/${BUILDTIME} " />

        <exec dir="${center.bin}" executable="${perl}" failonerror="true">
            <arg line=" reportPatientDetail.pl -e ${report.enddate} -c
${centerid} -o ${report.xml}/${BUILDTIME} " />
        </exec>
    </target>

Where ${centerlist} is  "297,298,299,300,301" I get the echo message
with the correct ${centerid} as I expect. This is exactly how the
foreach task is supposed to behave and exactly the way it does behave in
a number of other areas of this project.

When it get's down to the "compile_patients_on_alert" target, the
arguments echoed to the console are correct (they are the same one's
that are used to call this script from the shell). This includes the
${centerid} (The rest of the properties in the command are the same for
the entire project run)

With the echo tasks showing that the command is forming as I expect, I
don't think this is an issue with properties.

>>         <exec dir="${center.bin}" executable="${perl}" failonerror="true">
>>             <arg line=" reportAlertDetail.pl -e ${report.enddate} -c
>> ${centerid}  -A x -a x  -o ${report.xml}/${BUILDTIME}" />
>>         </exec>
> More properties here. It's the same Perl script invocation each time
> around. That's probably not what you intend to do.

Actually, it's not the same perl script invocation. The ${centerid}
changes with each iteration of the foreach task.

Here is the echo output of an invocation to "generate_reports"

generate_reports:

va_common_targets.generate_reports:
     [echo] generating reports for center list
    [mkdir] Created dir: /home/VascAlert/reports/xml/20110124003823
    [mkdir] Created dir: /home/VascAlert/reports/pdf/20110124003823
     [copy] Copying 1 file to /home/VascAlert/reports/xml/20110124003823
     [copy] Copying 1 file to /home/VascAlert/reports/xml/20110124003823
     [copy] Copying 1 file to /home/VascAlert/reports/xml/20110124003823
     [copy] Copying 1 file to /home/VascAlert/reports/xml/20110124003823
     [copy] Copying 1 file to /home/VascAlert/reports/xml/20110124003823

generate_reports_for_center:
     [echo] generating reports for center 297 through 2011-01-24

compile_patient_detail_report:

compile_patients_on_alert:
     [echo] patient detail for alerting patients for center 297
     [echo]  reportPatientDetail.pl -e 2011-01-23 -c 297 -o
/home/VascAlert/reports/xml/20110124003824

compile_patients_not_on_alert:
     [echo] patient detail for patients NOT on alert for center 297

compile_access_report:
     [echo] access report for center 297

compile_alert_list_reports:
     [echo] VAPR alert list report for center 297
     [echo] AAPR alert list report for center 297

generate_reports_for_center:
     [echo] generating reports for center 298 through 2011-01-24

compile_patient_detail_report:

compile_patients_on_alert:
     [echo] patient detail for alerting patients for center 298
     [echo]  reportPatientDetail.pl -e 2011-01-23 -c 298 -o
/home/VascAlert/reports/xml/20110124003824

compile_patients_not_on_alert:
     [echo] patient detail for patients NOT on alert for center 298

compile_access_report:
     [echo] access report for center 298

compile_alert_list_reports:
     [echo] VAPR alert list report for center 298
     [echo] AAPR alert list report for center 298

generate_reports_for_center:
     [echo] generating reports for center 299 through 2011-01-24

compile_patient_detail_report:

compile_patients_on_alert:
     [echo] patient detail for alerting patients for center 299
     [echo]  reportPatientDetail.pl -e 2011-01-23 -c 299 -o
/home/VascAlert/reports/xml/20110124003824



The script and commandline args are all correct and produce the correct
result when called from the shell.
The problem is that calling this from ant produces *inconsistent*
results. Some of the first report files are written but after two or
three iterations, the output that should be going to the file is turning
up in standard output.



> There are a couple simple things you can do to find out what's going on.
>
> ant -h              # help
> ant -v              # verbose, some info
> ant -d              # debug, including properties getting set
> ant -diagnostics    # also useful to know what info is available here
>
> Take a look at the <listproperties> task, also occasionally useful to
> produce diagnostic output.
>

The -d switch does provide lots of detail about what is going on at each
step and I don't see anything unexpected that would make the output of
an (apparently) separate process (the perl process) which is outside the
ant execution space, change from a perl file handle to standard out.

Thanks for your help, but I'm still on the hunt for why this is happening.




Reply via email to