From 98e2adf7944380b82ff40e8d5368aac3fc7e9a3b Mon Sep 17 00:00:00 2001
From: akwizgran <michael@briarproject.org>
Date: Wed, 15 Nov 2017 14:13:57 +0000
Subject: [PATCH] Fix Dagger setup, remove android-apt plugin.

---
 bramble-android/build.gradle                        |  3 +++
 bramble-api/build.gradle                            |  4 ----
 bramble-core/build.gradle                           | 13 +++++++------
 bramble-j2se/build.gradle                           |  4 ++++
 briar-android/build.gradle                          |  2 ++
 .../briar/android/login/SetupActivityTest.java      |  9 +++------
 briar-api/build.gradle                              |  2 --
 briar-core/build.gradle                             | 13 +++++++------
 build.gradle                                        |  5 ++++-
 9 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/bramble-android/build.gradle b/bramble-android/build.gradle
index b372cf7f3d..c94dc003f3 100644
--- a/bramble-android/build.gradle
+++ b/bramble-android/build.gradle
@@ -26,6 +26,9 @@ android {
 dependencies {
 	compile project(path: ':bramble-core', configuration: 'default')
 	compile fileTree(dir: 'libs', include: '*.jar')
+
+	annotationProcessor 'com.google.dagger:dagger-compiler:2.0.2'
+
 	provided 'javax.annotation:jsr250-api:1.0'
 }
 
diff --git a/bramble-api/build.gradle b/bramble-api/build.gradle
index f1d0018e60..bded3ab754 100644
--- a/bramble-api/build.gradle
+++ b/bramble-api/build.gradle
@@ -6,7 +6,6 @@ apply plugin: 'witness'
 
 dependencies {
 	compile "com.google.dagger:dagger:2.0.2"
-	compile 'com.google.dagger:dagger-compiler:2.0.2'
 	compile 'com.google.code.findbugs:jsr305:3.0.2'
 
 	testCompile 'junit:junit:4.12'
@@ -20,11 +19,8 @@ dependencies {
 dependencyVerification {
 	verify = [
 			'com.google.dagger:dagger:84c0282ed8be73a29e0475d639da030b55dee72369e58dd35ae7d4fe6243dcf9',
-			'com.google.dagger:dagger-compiler:b74bc9de063dd4c6400b232231f2ef5056145b8fbecbf5382012007dd1c071b3',
 			'com.google.code.findbugs:jsr305:766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7',
 			'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
-			'com.google.dagger:dagger-producers:99ec15e8a0507ba569e7655bc1165ee5e5ca5aa914b3c8f7e2c2458f724edd6b',
-			'com.google.guava:guava:d664fbfc03d2e5ce9cab2a44fb01f1d0bf9dfebeccc1a473b1f9ea31f79f6f99',
 	]
 }
 
diff --git a/bramble-core/build.gradle b/bramble-core/build.gradle
index dfe194a316..93a6c2c946 100644
--- a/bramble-core/build.gradle
+++ b/bramble-core/build.gradle
@@ -1,12 +1,9 @@
-plugins {
-	id 'java'
-	id 'net.ltgt.apt' version '0.9'
-	id 'idea'
-}
-
+apply plugin: 'java'
 sourceCompatibility = 1.6
 targetCompatibility = 1.6
 
+apply plugin: 'net.ltgt.apt'
+apply plugin: 'idea'
 apply plugin: 'witness'
 
 dependencies {
@@ -15,7 +12,11 @@ dependencies {
 	compile 'com.h2database:h2:1.4.192' // This is the last version that supports Java 1.6
 	compile 'org.bitlet:weupnp:0.1.4'
 
+	apt 'com.google.dagger:dagger-compiler:2.0.2'
+
 	testCompile project(path: ':bramble-api', configuration: 'testOutput')
+
+	testApt 'com.google.dagger:dagger-compiler:2.0.2'
 }
 
 dependencyVerification {
diff --git a/bramble-j2se/build.gradle b/bramble-j2se/build.gradle
index 5b3cf67866..a140432b6e 100644
--- a/bramble-j2se/build.gradle
+++ b/bramble-j2se/build.gradle
@@ -2,6 +2,8 @@ apply plugin: 'java'
 sourceCompatibility = 1.7
 targetCompatibility = 1.7
 
+apply plugin: 'net.ltgt.apt'
+apply plugin: 'idea'
 apply plugin: 'witness'
 
 dependencies {
@@ -10,6 +12,8 @@ dependencies {
 	compile 'net.java.dev.jna:jna:4.4.0'
 	compile 'net.java.dev.jna:jna-platform:4.4.0'
 
+	apt 'com.google.dagger:dagger-compiler:2.0.2'
+
 	testCompile project(path: ':bramble-core', configuration: 'testOutput')
 }
 
diff --git a/briar-android/build.gradle b/briar-android/build.gradle
index d31f16b1f8..da9bb4dd3c 100644
--- a/briar-android/build.gradle
+++ b/briar-android/build.gradle
@@ -30,6 +30,8 @@ dependencies {
 	compile 'com.github.bumptech.glide:glide:3.8.0'
 	compile 'uk.co.samuelwall:material-tap-target-prompt:1.9.2'
 
+	annotationProcessor 'com.google.dagger:dagger-compiler:2.0.2'
+
 	provided 'javax.annotation:jsr250-api:1.0'
 
 	testCompile project(path: ':bramble-core', configuration: 'testOutput')
diff --git a/briar-android/src/test/java/org/briarproject/briar/android/login/SetupActivityTest.java b/briar-android/src/test/java/org/briarproject/briar/android/login/SetupActivityTest.java
index 7841d792bf..72bffbf63c 100644
--- a/briar-android/src/test/java/org/briarproject/briar/android/login/SetupActivityTest.java
+++ b/briar-android/src/test/java/org/briarproject/briar/android/login/SetupActivityTest.java
@@ -7,9 +7,6 @@ import android.support.design.widget.TextInputLayout;
 import android.widget.Button;
 import android.widget.EditText;
 
-import com.google.common.base.Strings;
-
-import org.briarproject.bramble.api.identity.AuthorConstants;
 import org.briarproject.briar.BuildConfig;
 import org.briarproject.briar.R;
 import org.briarproject.briar.android.TestBriarApplication;
@@ -35,6 +32,8 @@ import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUIT
 import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.QUITE_WEAK;
 import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.STRONG;
 import static org.briarproject.bramble.api.crypto.PasswordStrengthEstimator.WEAK;
+import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
+import static org.briarproject.bramble.util.StringUtils.getRandomString;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.eq;
@@ -145,9 +144,7 @@ public class SetupActivityTest {
 	@Test
 	public void testNicknameUI() {
 		Assert.assertNotNull(setupActivity);
-		String longNick =
-				Strings.padEnd("*", AuthorConstants.MAX_AUTHOR_NAME_LENGTH + 1,
-						'*');
+		String longNick = getRandomString(MAX_AUTHOR_NAME_LENGTH + 1);
 		nicknameEntry.setText(longNick);
 		// Nickname should be too long
 		assertEquals(nicknameEntryWrapper.getError(),
diff --git a/briar-api/build.gradle b/briar-api/build.gradle
index 2c957a6452..33bc10b8cb 100644
--- a/briar-api/build.gradle
+++ b/briar-api/build.gradle
@@ -2,8 +2,6 @@ apply plugin: 'java'
 sourceCompatibility = 1.6
 targetCompatibility = 1.6
 
-apply plugin: 'witness'
-
 dependencies {
 	compile project(path: ':bramble-api', configuration: 'default')
 }
diff --git a/briar-core/build.gradle b/briar-core/build.gradle
index 8976d7e3a5..6fc8e564bb 100644
--- a/briar-core/build.gradle
+++ b/briar-core/build.gradle
@@ -1,12 +1,9 @@
-plugins {
-	id 'java'
-	id 'net.ltgt.apt' version '0.9'
-	id 'idea'
-}
-
+apply plugin: 'java'
 sourceCompatibility = 1.6
 targetCompatibility = 1.6
 
+apply plugin: 'net.ltgt.apt'
+apply plugin: 'idea'
 apply plugin: 'witness'
 
 dependencies {
@@ -16,10 +13,14 @@ dependencies {
 	compile 'com.squareup.okhttp3:okhttp:3.8.0'
 	compile 'org.jsoup:jsoup:1.10.3'
 
+	apt 'com.google.dagger:dagger-compiler:2.0.2'
+
 	testCompile project(path: ':bramble-core', configuration: 'default')
 	testCompile project(path: ':bramble-core', configuration: 'testOutput')
 	testCompile project(path: ':bramble-api', configuration: 'testOutput')
 	testCompile 'net.jodah:concurrentunit:0.4.2'
+
+	testApt 'com.google.dagger:dagger-compiler:2.0.2'
 }
 
 dependencyVerification {
diff --git a/build.gradle b/build.gradle
index af816d45f5..f022dce92f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -11,11 +11,14 @@ buildscript {
 	repositories {
 		jcenter()
 		mavenLocal()
+		maven {
+			url "https://plugins.gradle.org/m2/"
+		}
 	}
 
 	dependencies {
 		classpath 'com.android.tools.build:gradle:2.3.3'
-		classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
+		classpath 'net.ltgt.gradle:gradle-apt-plugin:0.9'
 		classpath 'de.undercouch:gradle-download-task:3.2.0'
 		classpath files('libs/gradle-witness.jar')
 	}
-- 
GitLab