import com.android.build.gradle.tasks.MergeResources plugins { id 'com.android.application' id 'kotlin-android' id 'kotlin-kapt' id 'dagger.hilt.android.plugin' id "org.jlleitschuh.gradle.ktlint" version "$ktlint_plugin_version" id 'checkstyle' // only needed for Java code } android { compileSdkVersion 31 buildToolsVersion "31.0.0" defaultConfig { applicationId "org.briarproject.mailbox" minSdkVersion 16 targetSdkVersion 31 versionCode 1 versionName "1.0" multiDexEnabled true // only needed when minSdkVersion < 21 testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } buildFeatures { viewBinding true } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 coreLibraryDesugaringEnabled true } kotlinOptions { jvmTarget = '1.8' } packagingOptions { exclude 'META-INF/*' // Due to https://github.com/Kotlin/kotlinx.coroutines/issues/2023 exclude 'META-INF/licenses/*' exclude '**/attach_hotspot_windows.dll' } } configurations { tor } dependencies { implementation project(path: ':mailbox-core', configuration: 'default') implementation project(path: ':dont-kill-me-lib') implementation 'com.github.tony19:logback-android:2.0.0' implementation 'androidx.appcompat:appcompat:1.4.1' implementation "androidx.activity:activity-ktx:1.4.0" implementation "androidx.fragment:fragment-ktx:$androidx_fragment_version" def lifecycle_version = "2.4.0" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycle_version" def nav_version = "2.4.0" implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" implementation "androidx.navigation:navigation-ui-ktx:$nav_version" implementation "androidx.constraintlayout:constraintlayout:$androidx_constraintlayout_version" implementation "com.google.android.material:material:$google_material_version" implementation "com.google.dagger:hilt-android:$hilt_version" kapt "com.google.dagger:hilt-compiler:$hilt_version" // Java 8 coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' // Multidex needed if we target API < 21 def multidex_version = "2.0.1" implementation "androidx.multidex:multidex:$multidex_version" tor "org.briarproject:tor-android:$tor_version" tor "org.briarproject:obfs4proxy-android:$obfs4_version@zip" testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } def torBinariesDir = 'src/main/res/raw' def torLibsDir = 'src/main/jniLibs' task cleanTorBinaries { doLast { delete fileTree(torBinariesDir) { include '*.zip' } delete fileTree(torLibsDir) { include '**/*.so' } } } clean.dependsOn cleanTorBinaries task unpackTorBinaries { doLast { copy { from configurations.tor.collect { zipTree(it) } into torBinariesDir include 'geoip.zip' } configurations.tor.each { outer -> zipTree(outer).each { inner -> if (inner.name.endsWith('_arm_pie.zip')) { copy { from zipTree(inner) into torLibsDir rename '(.*)', 'armeabi-v7a/lib$1.so' } } else if (inner.name.endsWith('_arm64_pie.zip')) { copy { from zipTree(inner) into torLibsDir rename '(.*)', 'arm64-v8a/lib$1.so' } } else if (inner.name.endsWith('_x86_pie.zip')) { copy { from zipTree(inner) into torLibsDir rename '(.*)', 'x86/lib$1.so' } } else if (inner.name.endsWith('_x86_64_pie.zip')) { copy { from zipTree(inner) into torLibsDir rename '(.*)', 'x86_64/lib$1.so' } } } } } dependsOn cleanTorBinaries } tasks.withType(MergeResources) { inputs.dir torBinariesDir inputs.dir torLibsDir dependsOn unpackTorBinaries } apply from: "${rootProject.rootDir}/gradle/ktlint.gradle"