Add cache cleaning if the build script changed
authorDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Mon, 25 Apr 2016 18:08:48 +0000 (20:08 +0200)
committerDmitry Trofimov <dmitry.trofimov@jetbrains.com>
Tue, 26 Apr 2016 06:39:46 +0000 (08:39 +0200)
python/setup-test-environment/build.gradle

index 62e90e5c8ee107c6bf5dbec56a8fa95f199d1061..14342a099b60f0f32ed0cfe2dc8ee0515ed257d8 100644 (file)
@@ -31,7 +31,18 @@ envs {
   textfile "django_latest/tags.txt", "django"
 }
 
-if (new File(envs.envsDirectory, "django_latest").lastModified()<System.currentTimeMillis() - 24*60*60*1000) {
+if (new File(envs.envsDirectory, "django_latest").exists() && 
+    new File(envs.envsDirectory, "django_latest").lastModified()<System.currentTimeMillis() - 24*60*60*1000) {
   // older then a day
+  println "Cleaning django_latest at" + new File(envs.envsDirectory, "django_latest")
   delete new File(envs.envsDirectory, "django_latest")
 }
+
+if (envs.envsDirectory.exists() &&
+    envs.envsDirectory.lastModified()<project.buildscript.sourceFile.lastModified()) {
+  // clean the cache if the build script if modified later
+  println "Cleaning cached environments at " + envs.envsDirectory
+  delete envs.envsDirectory
+  println "Cleaning cached pythons at " + envs.bootstrapDirectory
+  delete envs.bootstrapDirectory
+}