From db8796049e900e83cf7096d3b2d93d9d1bc21b69 Mon Sep 17 00:00:00 2001
From: Torsten Grote <t@grobox.de>
Date: Thu, 1 Nov 2018 10:45:59 -0300
Subject: [PATCH] gradle: Factor out dagger apt code into its own file

---
 bramble-core/build.gradle | 16 +---------------
 bramble-java/build.gradle | 16 +---------------
 briar-core/build.gradle   | 16 +---------------
 gradle/dagger.gradle      | 14 ++++++++++++++
 4 files changed, 17 insertions(+), 45 deletions(-)
 create mode 100644 gradle/dagger.gradle

diff --git a/bramble-core/build.gradle b/bramble-core/build.gradle
index db6dad04be..49c0f31a32 100644
--- a/bramble-core/build.gradle
+++ b/bramble-core/build.gradle
@@ -6,6 +6,7 @@ apply plugin: 'ru.vyarus.animalsniffer'
 apply plugin: 'idea'
 apply plugin: 'witness'
 apply from: 'witness.gradle'
+apply from: '../gradle/dagger.gradle'
 
 dependencies {
 	implementation project(path: ':bramble-api', configuration: 'default')
@@ -32,21 +33,6 @@ dependencies {
 	signature 'org.codehaus.mojo.signature:java16:1.1@signature'
 }
 
-sourceSets.configureEach { sourceSet ->
-	tasks.named(sourceSet.compileJavaTaskName).configure {
-		options.annotationProcessorGeneratedSourcesDirectory = file("$buildDir/generated/source/apt/${sourceSet.name}")
-	}
-}
-
-idea {
-	module {
-		sourceDirs += compileJava.options.annotationProcessorGeneratedSourcesDirectory
-		generatedSourceDirs += compileJava.options.annotationProcessorGeneratedSourcesDirectory
-		testSourceDirs += compileTestJava.options.annotationProcessorGeneratedSourcesDirectory
-		generatedSourceDirs += compileTestJava.options.annotationProcessorGeneratedSourcesDirectory
-	}
-}
-
 // needed to make test output available to bramble-java
 configurations {
 	testOutput.extendsFrom(testCompile)
diff --git a/bramble-java/build.gradle b/bramble-java/build.gradle
index 91a9b9b889..5bb95f17fe 100644
--- a/bramble-java/build.gradle
+++ b/bramble-java/build.gradle
@@ -5,6 +5,7 @@ targetCompatibility = 1.8
 apply plugin: 'idea'
 apply plugin: 'witness'
 apply from: 'witness.gradle'
+apply from: '../gradle/dagger.gradle'
 
 configurations {
 	tor
@@ -32,21 +33,6 @@ dependencies {
 	testAnnotationProcessor 'com.google.dagger:dagger-compiler:2.19'
 }
 
-sourceSets.configureEach { sourceSet ->
-	tasks.named(sourceSet.compileJavaTaskName).configure {
-		options.annotationProcessorGeneratedSourcesDirectory = file("$buildDir/generated/source/apt/${sourceSet.name}")
-	}
-}
-
-idea {
-	module {
-		sourceDirs += compileJava.options.annotationProcessorGeneratedSourcesDirectory
-		generatedSourceDirs += compileJava.options.annotationProcessorGeneratedSourcesDirectory
-		testSourceDirs += compileTestJava.options.annotationProcessorGeneratedSourcesDirectory
-		generatedSourceDirs += compileTestJava.options.annotationProcessorGeneratedSourcesDirectory
-	}
-}
-
 def torBinariesDir = 'src/main/resources'
 
 task unpackTorBinaries {
diff --git a/briar-core/build.gradle b/briar-core/build.gradle
index b044b804d6..7c7d33e9e8 100644
--- a/briar-core/build.gradle
+++ b/briar-core/build.gradle
@@ -6,6 +6,7 @@ apply plugin: 'ru.vyarus.animalsniffer'
 apply plugin: 'idea'
 apply plugin: 'witness'
 apply from: 'witness.gradle'
+apply from: '../gradle/dagger.gradle'
 
 dependencies {
 	implementation project(path: ':briar-api', configuration: 'default')
@@ -31,18 +32,3 @@ dependencies {
 
 	signature 'org.codehaus.mojo.signature:java16:1.1@signature'
 }
-
-sourceSets.configureEach { sourceSet ->
-	tasks.named(sourceSet.compileJavaTaskName).configure {
-		options.annotationProcessorGeneratedSourcesDirectory = file("$buildDir/generated/source/apt/${sourceSet.name}")
-	}
-}
-
-idea {
-	module {
-		sourceDirs += compileJava.options.annotationProcessorGeneratedSourcesDirectory
-		generatedSourceDirs += compileJava.options.annotationProcessorGeneratedSourcesDirectory
-		testSourceDirs += compileTestJava.options.annotationProcessorGeneratedSourcesDirectory
-		generatedSourceDirs += compileTestJava.options.annotationProcessorGeneratedSourcesDirectory
-	}
-}
diff --git a/gradle/dagger.gradle b/gradle/dagger.gradle
new file mode 100644
index 0000000000..eec34b8a0f
--- /dev/null
+++ b/gradle/dagger.gradle
@@ -0,0 +1,14 @@
+sourceSets.configureEach { sourceSet ->
+	tasks.named(sourceSet.compileJavaTaskName).configure {
+		options.annotationProcessorGeneratedSourcesDirectory = file("$buildDir/generated/source/apt/${sourceSet.name}")
+	}
+}
+
+idea {
+	module {
+		sourceDirs += compileJava.options.annotationProcessorGeneratedSourcesDirectory
+		generatedSourceDirs += compileJava.options.annotationProcessorGeneratedSourcesDirectory
+		testSourceDirs += compileTestJava.options.annotationProcessorGeneratedSourcesDirectory
+		generatedSourceDirs += compileTestJava.options.annotationProcessorGeneratedSourcesDirectory
+	}
+}
\ No newline at end of file
-- 
GitLab