import java.security.MessageDigest buildscript { repositories { maven { url 'https://maven.google.com/' name 'Google' } maven { url "https://repo1.maven.org/maven2" jcenter() } } dependencies { classpath 'com.android.tools.build:gradle:3.0.1' classpath files('libs/gradle-witness.jar') } } apply plugin: 'com.android.application' apply plugin: 'witness' repositories { maven { url "https://repo1.maven.org/maven2/" } maven { url "https://raw.github.com/signalapp/maven/master/preferencefragment/releases/" } maven { url "https://raw.github.com/signalapp/maven/master/smil/releases/" } maven { url "https://raw.github.com/signalapp/maven/master/photoview/releases/" } maven { url "https://raw.github.com/signalapp/maven/master/shortcutbadger/releases/" } maven { url "https://raw.github.com/signalapp/maven/master/circular-progress-button/releases/" } maven { url "https://raw.github.com/signalapp/maven/master/sqlcipher/release/" } maven { url "https://maven.google.com" } maven { // textdrawable url 'https://dl.bintray.com/amulyakhare/maven' } google() jcenter() mavenLocal() } dependencies { def supportVersion = '28.0.0' compile "com.android.support:appcompat-v7:$supportVersion" compile "com.android.support:recyclerview-v7:$supportVersion" compile "com.android.support:design:$supportVersion" compile "com.android.support:support-v13:$supportVersion" compile "com.android.support:cardview-v7:$supportVersion" compile "com.android.support:preference-v7:$supportVersion" compile "com.android.support:preference-v14:$supportVersion" compile "com.android.support:gridlayout-v7:$supportVersion" compile "com.android.support:exifinterface:$supportVersion" compile 'com.android.support:multidex:1.0.3' compile 'android.arch.lifecycle:extensions:1.1.1' compile 'android.arch.lifecycle:common-java8:1.1.1' compile 'android.arch.work:work-runtime:1.0.0-alpha09' compile 'com.google.android.gms:play-services-gcm:9.6.1' compile 'com.google.android.gms:play-services-maps:9.6.1' compile 'com.google.android.gms:play-services-places:9.6.1' compile 'com.google.android.exoplayer:exoplayer-core:2.8.4' compile 'com.google.android.exoplayer:exoplayer-ui:2.8.4' compile 'org.whispersystems:signal-service-android:2.10.0-RC1' compile 'org.whispersystems:webrtc-android:M69' compile "me.leolin:ShortcutBadger:1.1.16" compile 'se.emilsjolander:stickylistheaders:2.7.0' compile 'com.jpardogo.materialtabstrip:library:1.0.9' compile 'org.apache.httpcomponents:httpclient-android:4.3.5' compile 'com.github.chrisbanes:PhotoView:2.1.3' compile 'com.github.bumptech.glide:glide:4.5.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.5.0' compile 'com.makeramen:roundedimageview:2.1.0' compile 'com.pnikosis:materialish-progress:1.5' compile 'org.greenrobot:eventbus:3.0.0' compile 'pl.tajchert:waitingdots:0.1.0' compile 'com.soundcloud.android:android-crop:0.9.10@aar' compile 'com.melnykov:floatingactionbutton:1.3.0' compile 'com.google.zxing:android-integration:3.1.0' compile 'com.squareup.dagger:dagger:1.2.2' annotationProcessor 'com.squareup.dagger:dagger-compiler:1.2.2' compile 'mobi.upod:time-duration-picker:1.1.3' provided 'com.squareup.dagger:dagger-compiler:1.2.2' compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' compile 'com.google.zxing:core:3.2.1' compile ('com.davemorrissey.labs:subsampling-scale-image-view:3.6.0') { exclude group: 'com.android.support', module: 'support-annotations' } compile ('cn.carbswang.android:NumberPickerView:1.0.9') { exclude group: 'com.android.support', module: 'appcompat-v7' } compile ('com.tomergoldst.android:tooltips:1.0.6') { exclude group: 'com.android.support', module: 'appcompat-v7' } compile ('com.klinkerapps:android-smsmms:4.0.1') { exclude group: 'com.squareup.okhttp', module: 'okhttp' exclude group: 'com.squareup.okhttp', module: 'okhttp-urlconnection' } compile 'com.annimon:stream:1.1.8' compile ('com.takisoft.fix:colorpicker:0.9.1') { exclude group: 'com.android.support', module: 'appcompat-v7' exclude group: 'com.android.support', module: 'recyclerview-v7' } compile 'com.codewaves.stickyheadergrid:stickyheadergrid:0.9.4' compile 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3-S2' compile 'org.signal:android-database-sqlcipher:3.5.9-S3' compile ('com.googlecode.ez-vcard:ez-vcard:0.9.11') { exclude group: 'com.fasterxml.jackson.core' exclude group: 'org.freemarker' } testCompile 'junit:junit:4.12' testCompile 'org.assertj:assertj-core:1.7.1' testCompile 'org.mockito:mockito-core:1.9.5' testCompile 'org.powermock:powermock-api-mockito:1.6.1' testCompile 'org.powermock:powermock-module-junit4:1.6.1' testCompile 'org.powermock:powermock-module-junit4-rule:1.6.1' testCompile 'org.powermock:powermock-classloading-xstream:1.6.1' androidTestCompile 'com.android.support:multidex:1.0.3' androidTestCompile 'com.android.support:multidex-instrumentation:1.0.3' androidTestCompile 'com.google.dexmaker:dexmaker:1.2' androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2' androidTestCompile ('org.assertj:assertj-core:1.7.1') { exclude group: 'org.hamcrest', module: 'hamcrest-core' } androidTestCompile ('com.squareup.assertj:assertj-android:1.1.1') { exclude group: 'org.hamcrest', module: 'hamcrest-core' exclude group: 'com.android.support', module: 'support-annotations' } } android { flavorDimensions "none" compileSdkVersion 28 buildToolsVersion '27.0.3' useLibrary 'org.apache.http.legacy' dexOptions { javaMaxHeapSize "4g" } defaultConfig { versionCode 421 versionName "4.29.7" minSdkVersion 14 targetSdkVersion 26 multiDexEnabled true vectorDrawables.useSupportLibrary = true project.ext.set("archivesBaseName", "Signal"); buildConfigField "long", "BUILD_TIMESTAMP", getLastCommitTimestamp() + "L" buildConfigField "String", "SIGNAL_URL", "\"https://textsecure-service-staging.whispersystems.org\"" buildConfigField "String", "SIGNAL_CDN_URL", "\"https://cdn.signal.org\"" buildConfigField "String", "SIGNAL_CONTACT_DISCOVERY_URL", "\"https://api.directory.signal.org\"" buildConfigField "String", "SIGNAL_SERVICE_STATUS_URL", "\"uptime.signal.org\"" buildConfigField "String", "GIPHY_PROXY_HOST", "\"giphy-proxy-production.whispersystems.org\"" buildConfigField "int", "GIPHY_PROXY_PORT", "80" buildConfigField "String", "USER_AGENT", "\"OWA\"" buildConfigField "boolean", "DEV_BUILD", "false" buildConfigField "String", "MRENCLAVE", "\"cd6cfc342937b23b1bdd3bbf9721aa5615ac9ff50a75c5527d441cd3276826c9\"" buildConfigField "String", "UNIDENTIFIED_SENDER_TRUST_ROOT", "\"BbqY1DzohE4NUZoVF+L18oUPrK3kILllLEJh2UnPSsEx\"" ndk { abiFilters "armeabi", "armeabi-v7a", "x86" } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } packagingOptions { exclude 'LICENSE.txt' exclude 'LICENSE' exclude 'NOTICE' exclude 'asm-license.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/NOTICE' exclude 'META-INF/proguard/androidx-annotations.pro' } signingConfigs { release } buildTypes { debug { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-google-play-services.pro', 'proguard-dagger.pro', 'proguard-jackson.pro', 'proguard-sqlite.pro', 'proguard-appcompat-v7.pro', 'proguard-square-okhttp.pro', 'proguard-square-okio.pro', 'proguard-spongycastle.pro', 'proguard-rounded-image-view.pro', 'proguard-glide.pro', 'proguard-shortcutbadger.pro', 'proguard-retrofit.pro', 'proguard-webrtc.pro', 'proguard-klinker.pro', 'proguard-retrolambda.pro', 'proguard-okhttp.pro', 'proguard-ez-vcard.pro', 'proguard-workmanager.pro', 'proguard.cfg' testProguardFiles 'proguard-automation.pro', 'proguard.cfg' } release { minifyEnabled true proguardFiles = buildTypes.debug.proguardFiles signingConfig signingConfigs.release } } productFlavors { play { dimension "none" ext.websiteUpdateUrl = "null" buildConfigField "boolean", "PLAY_STORE_DISABLED", "false" buildConfigField "String", "NOPLAY_UPDATE_URL", "$ext.websiteUpdateUrl" } website { dimension "none" ext.websiteUpdateUrl = "https://updates.signal.org/android" buildConfigField "boolean", "PLAY_STORE_DISABLED", "true" buildConfigField "String", "NOPLAY_UPDATE_URL", "\"$ext.websiteUpdateUrl\"" } } android.applicationVariants.all { variant -> variant.outputs.all { outputFileName = outputFileName.replace(".apk", "-${variant.versionName}.apk") } } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] jniLibs.srcDirs = ['libs'] } androidTest { java.srcDirs = ['test/androidTest/java'] } test { java.srcDirs = ['test/unitTest/java'] } website.manifest.srcFile 'website/AndroidManifest.xml' } lintOptions { abortOnError false } } task assembleWebsiteDescriptor << { android.applicationVariants.all { variant -> if (variant.name.equals("websiteDebug") || variant.name.equals("websiteRelease")) { File file = new File(variant.outputs[0].outputFile.path) if (file.exists()) { MessageDigest md = MessageDigest.getInstance("SHA-256"); file.eachByte 4096, {bytes, size -> md.update(bytes, 0, size); } String digest = md.digest().collect {String.format "%02x", it}.join(); String url = variant.productFlavors.get(0).ext.websiteUpdateUrl String apkName = variant.outputs[0].outputFile.name String descriptor = "{" + "\"versionCode\" : $project.android.defaultConfig.versionCode," + "\"versionName\" : \"$project.android.defaultConfig.versionName\"," + "\"sha256sum\" : \"$digest\"," + "\"url\" : \"$url/$apkName\"" + "}" File descriptorFile = new File(variant.outputs[0].outputFile.parent, apkName.replace(".apk", ".json")) descriptorFile.write(descriptor) } } } } tasks.whenTaskAdded { task -> if (task.name.equals("lint")) { task.enabled = false } if (task.name.equals("assembleWebsiteDebug") || task.name.equals("assembleWebsiteRelease")) { task.finalizedBy assembleWebsiteDescriptor } } def getLastCommitTimestamp() { new ByteArrayOutputStream().withStream { os -> def result = exec { executable = 'git' args = ['log', '-1', '--pretty=format:%ct'] standardOutput = os } return os.toString() + "000" } } def Properties props = new Properties() def propFile = new File('signing.properties') if (propFile.canRead()){ props.load(new FileInputStream(propFile)) if (props !=null && props.containsKey('STORE_FILE') && props.containsKey('STORE_PASSWORD') && props.containsKey('KEY_ALIAS') && props.containsKey('KEY_PASSWORD')) { android.signingConfigs.release.storeFile = file(props['STORE_FILE']) android.signingConfigs.release.storePassword = props['STORE_PASSWORD'] android.signingConfigs.release.keyAlias = props['KEY_ALIAS'] android.signingConfigs.release.keyPassword = props['KEY_PASSWORD'] } else { println 'signing.properties found but some entries are missing' android.buildTypes.release.signingConfig = null } }else { println 'signing.properties not found' android.buildTypes.release.signingConfig = null }