From d29812a42bb48ccf94f79f40aabc1f18c21866ab Mon Sep 17 00:00:00 2001
From: akwizgran <michael@briarproject.org>
Date: Tue, 30 Oct 2018 13:06:06 +0000
Subject: [PATCH] Delete Tor binaries when cleaning.

---
 bramble-android/build.gradle | 25 +++++++++++++++++++++----
 bramble-java/build.gradle    | 25 +++++++++++++++++++++----
 2 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/bramble-android/build.gradle b/bramble-android/build.gradle
index e69df25dff..55f2389f02 100644
--- a/bramble-android/build.gradle
+++ b/bramble-android/build.gradle
@@ -43,9 +43,26 @@ dependencies {
 	testImplementation "org.hamcrest:hamcrest-core:1.3"
 }
 
-project.afterEvaluate {
-	copy {
-		from configurations.tor.collect { zipTree(it) }
-		into 'src/main/res/raw'
+def torBinariesDir = 'src/main/res/raw'
+
+task unpackTorBinaries {
+	outputs.dir torBinariesDir
+	doLast {
+		copy {
+			from configurations.tor.collect { zipTree(it) }
+			into torBinariesDir
+		}
 	}
 }
+
+tasks.withType(JavaCompile) {
+	dependsOn unpackTorBinaries
+}
+
+task cleanTorBinaries {
+	doLast {
+		delete fileTree(torBinariesDir) { include '*.zip' }
+	}
+}
+
+clean.dependsOn cleanTorBinaries
diff --git a/bramble-java/build.gradle b/bramble-java/build.gradle
index 41e81ea24b..66ec4d6c1d 100644
--- a/bramble-java/build.gradle
+++ b/bramble-java/build.gradle
@@ -32,13 +32,30 @@ dependencies {
 	testApt 'com.google.dagger:dagger-compiler:2.0.2'
 }
 
-project.afterEvaluate {
-	copy {
-		from configurations.tor.collect { zipTree(it) }
-		into 'src/main/resources'
+def torBinariesDir = 'src/main/resources'
+
+task unpackTorBinaries {
+	outputs.dir torBinariesDir
+	doLast {
+		copy {
+			from configurations.tor.collect { zipTree(it) }
+			into torBinariesDir
+		}
 	}
 }
 
+tasks.withType(JavaCompile) {
+	dependsOn unpackTorBinaries
+}
+
+task cleanTorBinaries {
+	doLast {
+		delete fileTree(torBinariesDir) { include '*.zip' }
+	}
+}
+
+clean.dependsOn cleanTorBinaries
+
 tasks.withType(Test) {
 	systemProperty 'java.library.path', 'libs'
 }
-- 
GitLab