diff --git a/bramble-core/build.gradle b/bramble-core/build.gradle
index db6dad04be861dd54a3871147f205c49f4c980ac..49c0f31a32438e5355dfe0054d61a58482c54a78 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 91a9b9b88948803e40c2daa420d44ed73a5d5908..5bb95f17fe8d7b90b7376d2d2c93db591427aff9 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 b044b804d6e0f3f0902a3a85ea84189d28f5179f..7c7d33e9e8d607c7e776571fa3678cbcba7ef780 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 0000000000000000000000000000000000000000..eec34b8a0fe25545d0d6246c125883cc71ab45b2
--- /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