From 9262308032823c217a0653e3efd6b76e85ff71a6 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 2 Nov 2011 17:25:58 +0100 Subject: [PATCH] put forceDelete() function to common build scripts, use it in IDEA build script --- build/scripts/dist.gant | 2 +- build/scripts/utils.gant | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/build/scripts/dist.gant b/build/scripts/dist.gant index 5354776e4176..49bebb6899da 100644 --- a/build/scripts/dist.gant +++ b/build/scripts/dist.gant @@ -35,7 +35,7 @@ target(compile: "Compile project") { loadProject() project.stage("Cleaning up sandbox folder") - ant.delete(dir: paths.sandbox) + forceDelete(paths.sandbox) [paths.sandbox, paths.distWin, paths.distAll, paths.distUnix, paths.distMac, paths.artifacts, paths.artifacts_core].each { ant.mkdir(dir: it) diff --git a/build/scripts/utils.gant b/build/scripts/utils.gant index 0cd266c57477..7c0ad815631b 100644 --- a/build/scripts/utils.gant +++ b/build/scripts/utils.gant @@ -195,6 +195,29 @@ binding.setVariable("layoutMacApp", { String path, String ch, Map args -> }) +binding.setVariable("forceDelete", { String dirPath -> + // if wasn't deleted - retry several times + attempt = 1 + while (attempt < 21 && (new File(dirPath).exists())) { + if (attempt > 1) { + ant.echo "Deleting $dirPath ... (attempt=$attempt)" + + // let's wait a bit and try again - may be help + // in some cases on our windows 7 agents + sleep(2000) + } + + ant.delete(failonerror: false, dir: dirPath) + + attempt++ + } + + if (new File(dirPath).exists()) { + ant.project.log ("Cannot delete directory: $dirPath" ) + System.exit (1) + } +}) + binding.setVariable("patchPropertiesFile", { String where -> ant.echo(file: "$where/bin/idea.properties", append: "true", message: isEap() ?