import com.urbancode.air.*
import com.urbancode.air.plugin.scm.*

final def workDir = new File('.').canonicalFile

//------------------------------------------------------------------------------
// GET ALL INPUT PARAMETERS
//------------------------------------------------------------------------------

final def apTool = new AirPluginTool(args[0], args[1]);
final stepProps = apTool.getStepProperties()

final def srcName      = stepProps['source'];
final def dir          = new File(workDir, stepProps['source/dirOffset'] ?: '.').canonicalFile // get checkout directory

final def cmdHelper = new CommandHelper(dir);

//------------------------------------------------------------------------------
// PREPARE COMMAND LINE
//------------------------------------------------------------------------------

 println "Deleting directory contents for $dir"
 dir.listFiles().each{ file ->
     boolean success = false;
     if (file.isFile()) {
         success = file.delete()
     }
     else if (file.isDirectory()){
         success = file.deleteDir()
     }
     if (!success) {
         println("Failed to delete $file")
     }
 }
 println "Done deleting directory contents for $dir"
