build.gradle 6.51 KB
Newer Older
1
apply plugin: 'com.android.application'
2
apply plugin: 'witness'
3
apply from: 'witness.gradle'
4

5
def getStdout = { command, defaultValue ->
6
7
8
	def stdout = new ByteArrayOutputStream()
	try {
		exec {
9
			commandLine = command
10
11
12
13
			standardOutput = stdout
		}
		return stdout.toString().trim()
	} catch (Exception ignored) {
14
		return defaultValue
15
16
17
	}
}

18
android {
19
	compileSdkVersion 28
akwizgran's avatar
akwizgran committed
20
	buildToolsVersion '28.0.3'
21

22
	defaultConfig {
akwizgran's avatar
akwizgran committed
23
		minSdkVersion 15
24
		targetSdkVersion 26
25
26
		versionCode 10203
		versionName "1.2.3"
27
		applicationId "org.briarproject.briar.android"
28
29
		buildConfigField "String", "GitHash",
				"\"${getStdout(['git', 'rev-parse', '--short=7', 'HEAD'], 'No commit hash')}\""
30
		def now = (long) (System.currentTimeMillis() / 1000)
31
		buildConfigField "Long", "BuildTimestamp",
32
				"${getStdout(['git', 'log', '-n', '1', '--format=%ct'], now)}000L"
33
		testInstrumentationRunner 'org.briarproject.briar.android.BriarTestRunner'
34
	}
35

36
37
	buildTypes {
		debug {
38
			applicationIdSuffix ".debug"
39
			shrinkResources false
40
			minifyEnabled true
Torsten Grote's avatar
Torsten Grote committed
41
			crunchPngs false
42
			proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
43
44
			testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-test.txt'
		}
45
		release {
46
			shrinkResources false
47
			minifyEnabled true
Torsten Grote's avatar
Torsten Grote committed
48
			crunchPngs false
49
50
51
			proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
		}
	}
52

53
54
55
56
57
58
59
	flavorDimensions "version"
	productFlavors {
		screenshot {
			dimension "version"
			minSdkVersion 18
			applicationIdSuffix ".screenshot" // = org.briarproject.briar.android.screenshot.debug
		}
60
		official {
61
62
63
64
65
66
67
68
69
			dimension "version"
		}
	}
	variantFilter { variant ->
		if (variant.flavors*.name.contains("screenshot") && variant.buildType.name == "release") {
			setIgnore(true)
		}
	}

70
	compileOptions {
71
72
		sourceCompatibility JavaVersion.VERSION_1_8
		targetCompatibility JavaVersion.VERSION_1_8
73
	}
74

75
76
77
78
79
80
	testOptions {
		unitTests {
			includeAndroidResources = true
		}
	}

81
	lintOptions {
ligi's avatar
ligi committed
82
83
		warning 'MissingTranslation'
		warning 'ImpliedQuantity'
84
		warning 'ExtraTranslation'
85
	}
86
}
Julian Dehm's avatar
Julian Dehm committed
87

88
89
90
91
92
dependencies {
	implementation project(path: ':briar-core', configuration: 'default')
	implementation project(path: ':bramble-core', configuration: 'default')
	implementation project(':bramble-android')

akwizgran's avatar
akwizgran committed
93
	def supportVersion = '28.0.0'
94
95
96
97
98
99
100
101
102
103
104
105
106
	implementation "com.android.support:support-v4:$supportVersion"
	implementation("com.android.support:appcompat-v7:$supportVersion") {
		exclude module: 'support-v4'
	}
	implementation("com.android.support:preference-v14:$supportVersion") {
		exclude module: 'support-v4'
	}
	implementation("com.android.support:design:$supportVersion") {
		exclude module: 'support-v4'
		exclude module: 'recyclerview-v7'
	}
	implementation "com.android.support:cardview-v7:$supportVersion"
	implementation "com.android.support:support-annotations:$supportVersion"
107
	implementation "com.android.support:exifinterface:$supportVersion"
108
	implementation 'com.android.support.constraint:constraint-layout:1.1.3'
109
	implementation "android.arch.lifecycle:extensions:1.1.1"
110

akwizgran's avatar
akwizgran committed
111
	implementation('ch.acra:acra:4.11') {
112
113
114
115
116
117
		exclude module: 'support-v4'
		exclude module: 'support-annotations'
	}
	implementation 'info.guardianproject.panic:panic:0.5'
	implementation 'info.guardianproject.trustedintents:trustedintents:0.2'
	implementation 'de.hdodenhof:circleimageview:2.2.0'
118
	implementation 'com.google.zxing:core:3.3.3'
119
	implementation 'uk.co.samuelwall:material-tap-target-prompt:2.14.0'
120
	implementation 'com.vanniktech:emoji-google:0.5.1'
121
	implementation 'com.github.kobakei:MaterialFabSpeedDial:1.2.1' // later versions already use androidx
122
	def glideVersion = '4.9.0'
123
124
125
126
	implementation("com.github.bumptech.glide:glide:$glideVersion") {
		exclude group: 'com.android.support'
		exclude module: 'disklrucache' // when there's no disk cache, we can't accidentally use it
	}
127
	implementation 'com.github.chrisbanes:PhotoView:2.1.4' // later versions already use androidx
128

129
	annotationProcessor 'com.google.dagger:dagger-compiler:2.22.1'
130
	annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
131
132
133
134
135

	compileOnly 'javax.annotation:jsr250-api:1.0'

	testImplementation project(path: ':bramble-api', configuration: 'testOutput')
	testImplementation project(path: ':bramble-core', configuration: 'testOutput')
Julian Dehm's avatar
Julian Dehm committed
136
	testImplementation 'org.robolectric:robolectric:4.0.1'
137
	testImplementation 'org.robolectric:shadows-support-v4:3.3.2'
138
	testImplementation 'org.mockito:mockito-core:2.25.0'
139
140
141
142
143
144
145
146
147
	testImplementation 'junit:junit:4.12'
	testImplementation "org.jmock:jmock:2.8.2"
	testImplementation "org.jmock:jmock-junit4:2.8.2"
	testImplementation "org.jmock:jmock-legacy:2.8.2"

	def espressoVersion = '3.0.2'
	androidTestImplementation "com.android.support.test.espresso:espresso-core:$espressoVersion"
	androidTestImplementation "com.android.support.test.espresso:espresso-contrib:$espressoVersion"
	androidTestImplementation "com.android.support.test.espresso:espresso-intents:$espressoVersion"
148
	androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.22.1"
149
150
	androidTestCompileOnly 'javax.annotation:jsr250-api:1.0'
	androidTestImplementation 'junit:junit:4.12'
151
	androidTestScreenshotImplementation "tools.fastlane:screengrab:1.2.0"
152
153
154
	androidTestScreenshotImplementation "com.android.support.test.uiautomator:uiautomator-v18:2.1.3"
}

Julian Dehm's avatar
Julian Dehm committed
155
156
task verifyTranslations {
	doLast {
157
		def file = project.file("src/main/res/values/arrays.xml")
Julian Dehm's avatar
Julian Dehm committed
158
159
160
161
162
163
		def arrays = new XmlParser().parse(file)
		def lc = arrays.children().find { it.@name == "pref_language_values" }
		def translations = []
		lc.children().each { value -> translations.add(value.text()) }

		def folders = ["default", "en-US"]
164
		def exceptions = ["values-night", "values-v21", "values-ldrtl"]
165
		project.file("src/main/res").eachDir { dir ->
166
			if (dir.name.startsWith("values-") && !exceptions.contains(dir.name)) {
Julian Dehm's avatar
Julian Dehm committed
167
168
169
170
				folders.add(dir.name.substring(7).replace("-r", "-"))
			}
		}
		folders.each { n ->
Julian Dehm's avatar
Julian Dehm committed
171
			if (!translations.remove(n) && n != 'iw') {
Julian Dehm's avatar
Julian Dehm committed
172
173
174
175
176
177
				throw new GradleException("Translation " + n + " is missing in $file")
			}
		}
		if (translations.size() != 0)
			throw new GradleException("Translations\n" + translations.join("\n")
					+ "\nhave no matching value folder")
Julian Dehm's avatar
Julian Dehm committed
178
179

		// Some devices use iw instead of he for hebrew
180
181
		def hebrew_legacy = project.file("src/main/res/values-iw")
		def hebrew = project.file("src/main/res/values-he")
Julian Dehm's avatar
Julian Dehm committed
182
183
184
185
		// Copy values-he to values-iw
		if (hebrew.exists()) {
			hebrew_legacy.mkdir()
			copy {
186
187
				from hebrew.getAbsolutePath()
				into hebrew_legacy.getAbsolutePath()
Julian Dehm's avatar
Julian Dehm committed
188
189
			}
		}
Julian Dehm's avatar
Julian Dehm committed
190
191
192
193
194
195
	}
}

project.afterEvaluate {
	preBuild.dependsOn.add(verifyTranslations)
}