build.gradle 6.65 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 20
	compileSdkVersion 30
	buildToolsVersion '30.0.2'
21

22
	defaultConfig {
23 24
		minSdkVersion 16
		targetSdkVersion 29
25 26
		versionCode 10215
		versionName "1.2.15"
27
		applicationId "org.briarproject.briar.android"
28 29

		vectorDrawables.useSupportLibrary = true
30 31
		buildConfigField "String", "GitHash",
				"\"${getStdout(['git', 'rev-parse', '--short=7', 'HEAD'], 'No commit hash')}\""
32
		def now = (long) (System.currentTimeMillis() / 1000)
33
		buildConfigField "Long", "BuildTimestamp",
34
				"${getStdout(['git', 'log', '-n', '1', '--format=%ct'], now)}000L"
35
		testInstrumentationRunner 'org.briarproject.briar.android.BriarTestRunner'
36
		testInstrumentationRunnerArguments disableAnalytics: 'true'
37
	}
38

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

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

73
	compileOptions {
74 75
		sourceCompatibility JavaVersion.VERSION_1_8
		targetCompatibility JavaVersion.VERSION_1_8
76
	}
77

78 79 80 81 82 83
	testOptions {
		unitTests {
			includeAndroidResources = true
		}
	}

84
	lintOptions {
ligi's avatar
ligi committed
85 86
		warning 'MissingTranslation'
		warning 'ImpliedQuantity'
87
		warning 'ExtraTranslation'
88 89
		// FIXME
		warning 'InvalidPackage'
90
	}
91
}
Julian Dehm's avatar
Julian Dehm committed
92

93 94 95 96 97
dependencies {
	implementation project(path: ':briar-core', configuration: 'default')
	implementation project(path: ':bramble-core', configuration: 'default')
	implementation project(':bramble-android')

98 99 100 101 102 103
	implementation 'androidx.preference:preference:1.1.1'
	implementation 'androidx.exifinterface:exifinterface:1.3.1'
	implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
	implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
	implementation 'com.google.android.material:material:1.2.1'
	implementation 'androidx.recyclerview:recyclerview-selection:1.1.0-rc03'
104 105

	implementation 'info.guardianproject.panic:panic:1.0'
106
	implementation 'info.guardianproject.trustedintents:trustedintents:0.2'
107
	implementation 'de.hdodenhof:circleimageview:3.0.1'
108
	implementation 'com.google.zxing:core:3.3.3'  // newer version need minSdk 24
109
	implementation 'uk.co.samuelwall:material-tap-target-prompt:3.0.0'
110
	implementation 'com.vanniktech:emoji-google:0.6.0' // newer versions need minSdk 21
111
	implementation 'com.github.kobakei:MaterialFabSpeedDial:1.2.1'
112
	implementation 'com.github.chrisbanes:PhotoView:2.3.0'
113
	def glideVersion = '4.11.0'
114 115 116 117
	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
	}
118

119
	annotationProcessor 'com.google.dagger:dagger-compiler:2.24'
120
	annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
121 122 123

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

124
	def espressoVersion = '3.3.0'
125
	def jmockVersion = '2.8.2'
126 127
	testImplementation project(path: ':bramble-api', configuration: 'testOutput')
	testImplementation project(path: ':bramble-core', configuration: 'testOutput')
128 129 130
	testImplementation 'androidx.test:runner:1.3.0'
	testImplementation 'androidx.test.ext:junit:1.1.2'
	testImplementation 'androidx.fragment:fragment-testing:1.2.5'
131
	testImplementation "androidx.arch.core:core-testing:2.1.0"
132 133
	testImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
	testImplementation 'org.robolectric:robolectric:4.3.1'
134
	testImplementation 'org.mockito:mockito-core:3.1.0'
135
	testImplementation 'junit:junit:4.13.1'
136 137 138
	testImplementation "org.jmock:jmock:$jmockVersion"
	testImplementation "org.jmock:jmock-junit4:$jmockVersion"
	testImplementation "org.jmock:jmock-legacy:$jmockVersion"
139
	testAnnotationProcessor "com.google.dagger:dagger-compiler:2.24"
140

akwizgran's avatar
akwizgran committed
141
	androidTestImplementation project(path: ':bramble-api', configuration: 'testOutput')
142
	androidTestImplementation 'androidx.test.ext:junit:1.1.2'
143 144 145 146
	androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
	androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
	androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
	androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.24"
147
	androidTestCompileOnly 'javax.annotation:jsr250-api:1.0'
148 149 150
	androidTestImplementation 'junit:junit:4.13.1'
	androidTestScreenshotImplementation 'tools.fastlane:screengrab:2.0.0'
	androidTestScreenshotImplementation 'com.jraska:falcon:2.1.1'
151
	androidTestScreenshotImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
152 153
}

Julian Dehm's avatar
Julian Dehm committed
154 155
task verifyTranslations {
	doLast {
156
		def file = project.file("src/main/res/values/arrays.xml")
Julian Dehm's avatar
Julian Dehm committed
157 158 159 160 161 162
		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"]
163
		def exceptions = ["values-night", "values-v21", "values-ldrtl"]
164
		project.file("src/main/res").eachDir { dir ->
165
			if (dir.name.startsWith("values-") && !exceptions.contains(dir.name)) {
Julian Dehm's avatar
Julian Dehm committed
166 167 168 169
				folders.add(dir.name.substring(7).replace("-r", "-"))
			}
		}
		folders.each { n ->
Julian Dehm's avatar
Julian Dehm committed
170
			if (!translations.remove(n) && n != 'iw') {
Julian Dehm's avatar
Julian Dehm committed
171 172 173 174 175 176
				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
177 178

		// Some devices use iw instead of he for hebrew
179 180
		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
181 182 183 184
		// Copy values-he to values-iw
		if (hebrew.exists()) {
			hebrew_legacy.mkdir()
			copy {
185 186
				from hebrew.getAbsolutePath()
				into hebrew_legacy.getAbsolutePath()
Julian Dehm's avatar
Julian Dehm committed
187 188
			}
		}
Julian Dehm's avatar
Julian Dehm committed
189 190 191 192 193 194
	}
}

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