Conditional Task on exec failure in Ant

前端 未结 2 593
温柔的废话
温柔的废话 2020-12-06 15:16

I have some unit tests running through Ant, and I\'d like to be able to run some cleanup code if the unit tests fail. I was looking for some sort of \"finally\" block, but I

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 15:39

    Two possiblities

    -1-
    use some try/catch/finally construct for specific parts of your script
    you need some Ant Plugin that provides those features, f.e. =

    Flaka
    Antcontrib / Antelope

        
         
          
         
         
          do your cleanup here
          and afterwards don't forget to fail
          
         
          optionally you may use a finally section also
         
          ..
         
       
    

    -2-
    use a buildlistener for the whole script ( BUILD SUCCESSFUL, BUILD FAILED )

    Kev Jackson has a nice example of an exec-listener in his presentation, = http://people.apache.org/~kevj/ossummit/extending-ant.html (the sources of the exec-listener are included in the slides)

    You're able to kick off specific tasks depending on the build result after your build has finished

        
    
    ..
    
     your stuff goes here 
    ..
    
    

提交回复
热议问题