ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Richard Russell" <richard.russ...@db.com>
Subject Re: AW: AW: how to fail on valid zip file
Date Fri, 08 Oct 2004 15:30:42 GMT
You could subclass the task you're using to do the unzip with, and have it 
catch its' own exception...

ie (without having looked at the code, and not being a java programmer -- 
so caveat emptor):

execute () {
  try {
    super.execute();
  } catch (WhateverException e) {
    // print a log message or whatever
  }
}

Then just use this task instead of your original unzip or whatever. 
Really, if a task fails, the build should fail. What you appear to want is 
a different task, with different success criteria, correct? Alternatively, 
you're really wanting to run this task only if something is not a valid 
zip file, in which case you are using a task as a condition, and probably 
should be using some sort of test first...

Cheers,

Richard Russell 
Deutsche Bank AG London 
Global Markets Customer Solutions
Office: +44 (0)20 7545 8060
Mobile: +44 (0)79 0661 2237




Jeffrey Bacon <jbacon@magmic.com>
10/08/2004 04:18 PM
Please respond to "Ant Users List"

 
        To:     Ant Users List <user@ant.apache.org>
        cc: 
        Subject:        Re: AW: AW: how to fail on valid zip file


here, unzip is throwing the exception and it's seemingly not getting 
caught, do I need to explicitly catch the BuildException? (with a 
<catch> block)

Jeffrey Bacon
jbacon@magmic.com
Creative Developer
http://www.magmic.com

Jan.Materne@rzf.fin-nrw.de wrote:
> oh, yes - sorry.
> In JUnit you work with different Exceptions
> 
> try {
>     test...
>     fail();
> } catch (MyException) {
>     // noop
> }
> 
> The fail() itself throws an Exception ...
> 
> Nothing different here, BUT we´re working only with BuildExceptions ...
> 
> Jan
> 
> 
>>-----Ursprüngliche Nachricht-----
>>Von: Jeffrey Bacon [mailto:jbacon@magmic.com]
>>Gesendet am: Freitag, 8. Oktober 2004 17:02
>>An: Ant Users List
>>Betreff: Re: AW: how to fail on valid zip file
>>
>>It still fails on the invalid ZIP file (which I want it to 
>>succeed on):
>>
>>     [mkdir] Created dir: C:\workspace\BreakFast\temp\ziptest
>>     [unzip] Expanding: C:\workspace\BreakFast\bin\BreakFast_res.cod 
>>into C:\workspace\BreakFast\temp\ziptest
>>    [delete] Deleting directory C:\workspace\BreakFast\temp\ziptest
>>
>>BUILD FAILED
>>C:\workspace\BreakFast\build.xml:251: Following error occured while 
>>executing this line
>>C:\workspace\BreakFast\build.xml:687: Error while expanding 
>>C:\workspace\BreakFast\bin\BreakFast_res.cod
>>
>>
>>here's my code snippit:
>>
>>     <contrib:trycatch>
>>       <contrib:try>
>>         <mkdir dir="${basedir}/${temp.dir}/ziptest" />
>>         <unzip 
>>src="${basedir}/${bin.dir}/${${project-name}.name}.cod" 
>>dest="${basedir}/${temp.dir}/ziptest" />
>>         <contrib:if>
>>           <contrib:not>
>>             <contrib:isset property="ignoreSiblingCODs" />
>>           </contrib:not>
>>           <contrib:then>
>>             <fail message="${${project-name}.name}.cod is a 
>>sibling COD 
>>file which will not install OTA on a BES &lt;4.0" />
>>           </contrib:then>
>>           <contrib:else>
>>             <echo level="warn">WARNING: 
>>${${project-name}.name}.cod is 
>>a sibling COD file which will not install OTA on a BES &lt;4.0</echo>
>>           </contrib:else>
>>         </contrib:if>
>>       </contrib:try>
>>       <contrib:finally>
>>         <delete dir="${basedir}/${temp.dir}/ziptest"
>>                 quiet="true"
>>                 failonerror="false"
>>                 includeEmptyDirs="true" />
>>       </contrib:finally>
>>     </contrib:trycatch>
>>
>>
>>Jeffrey Bacon
>>jbacon@magmic.com
>>Creative Developer
>>http://www.magmic.com
>>
>>Jan.Materne@rzf.fin-nrw.de wrote:
>>
>>>in unit tests you would do
>>>
>>>try {
>>>   test...
>>>   fail();
>>>} catch {
>>>   // fine
>>>}
>>>
>>>so you can use AntContrib for that
>>>
>>><trycatch>
>>>    <try>
>>>        <unzip/>
>>>        <fail/>
>>>    </try>
>>></trycatch>
>>>
>>>
>>>Jan
>>>
>>> > -----Ursprüngliche Nachricht-----
>>> > Von: Jeffrey Bacon [mailto:jbacon@magmic.com]
>>> > Gesendet am: Freitag, 8. Oktober 2004 15:46
>>> > An: Ant Users List
>>> > Betreff: how to fail on valid zip file
>>> >
>>> > During my build process, I want to test a file to see if it
>>> > is a valid
>>> > ZIP file.  However, I want to FAIL if it IS valid and succeed
>>> > if it is
>>> > NOT valid.  Is there some way I can do this with the unzip task?
>>> > --
>>> > Jeffrey Bacon
>>> > jbacon@magmic.com
>>> > Creative Developer
>>> > http://www.magmic.com
>>> >
>>> >
>>>
>>
> 

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


Mime
View raw message