build.gradle 3.81 KB
Newer Older
1 2
import java.nio.file.Files

Andy Trevorah's avatar
Andy Trevorah committed
3 4
apply plugin: 'com.android.application'

Eric Eastwood's avatar
Eric Eastwood committed
5 6
// Try reading secrets from file
def secretsPropertiesFile = rootProject.file("secrets.properties")
7
def secretProperties = new Properties()
Eric Eastwood's avatar
Eric Eastwood committed
8 9 10 11 12
if (secretsPropertiesFile.exists()) {
    secretProperties.load(new FileInputStream(secretsPropertiesFile))
}
// Otherwise read from environment variables, this happens in CI
else {
13 14 15 16
    secretProperties.setProperty("oauth_client_id", "\"${System.getenv('oauth_client_id')}\"")
    secretProperties.setProperty("oauth_client_secret", "\"${System.getenv('oauth_client_secret')}\"")
    secretProperties.setProperty("oauth_redirect_uri", "\"${System.getenv('oauth_redirect_uri')}\"")
    secretProperties.setProperty("google_project_id", "\"${System.getenv('google_project_id') ?: "null"}\"")
17 18 19
    secretProperties.setProperty("signing_keystore_password", "${System.getenv('signing_keystore_password')}")
    secretProperties.setProperty("signing_key_password", "${System.getenv('signing_key_password')}")
    secretProperties.setProperty("signing_key_alias", "${System.getenv('signing_key_alias')}")
Eric Eastwood's avatar
Eric Eastwood committed
20
}
21

22
// Download gitter-webapp assets from current release if assets folder not present
Marc Schwede's avatar
Marc Schwede committed
23
task fetchWebappAssets(type: Copy) {
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
    String zipFile = "${buildDir}/tmp/webapp-artifacts.zip"
    String assetsPath = "${projectDir}/src/main/assets"
    String artifactURI = "https://gitlab.com/gitlab-org/gitter/webapp/-/jobs/artifacts/master/download?job=mobile-asset-build"
    File f = new File(assetsPath)
    if (!f.isDirectory()) {
        new URL(artifactURI).withInputStream { i -> new File(zipFile).withOutputStream { it << i } }
        from zipTree(zipFile)
        into "."
        doLast {
            ant.move file: "./output/android/www",
                    todir: f.toPath()
            delete("./output", zipFile)
        }
    }
}

Andy Trevorah's avatar
Andy Trevorah committed
40
android {
Eric Eastwood's avatar
Eric Eastwood committed
41
    compileSdkVersion 26
42
    buildToolsVersion '28.0.3'
Andy Trevorah's avatar
Andy Trevorah committed
43 44 45

    defaultConfig {
        applicationId "im.gitter.gitter"
Andy Trevorah's avatar
Andy Trevorah committed
46
        minSdkVersion 19
Eric Eastwood's avatar
Eric Eastwood committed
47
        targetSdkVersion 26
48
        versionCode Integer.valueOf(System.env.VERSION_CODE ?: 0)
49
        // Manually bump the semver version part of the string as necessary
50
        versionName "3.4.0-${System.env.VERSION_SHA}"
51

52 53 54 55
        buildConfigField("String", "oauth_client_id", "${secretProperties['oauth_client_id']}")
        buildConfigField("String", "oauth_client_secret", "${secretProperties['oauth_client_secret']}")
        buildConfigField("String", "oauth_redirect_uri", "${secretProperties['oauth_redirect_uri']}")
        buildConfigField("String", "google_project_id", "${secretProperties['google_project_id']}" ?: "null")
Andy Trevorah's avatar
Andy Trevorah committed
56
    }
57 58 59 60
    signingConfigs {
        release {
            // You need to specify either an absolute path or include the
            // keystore file in the same directory as the build.gradle file.
61
            storeFile file("../android-signing-keystore.jks")
62 63 64 65 66
            storePassword "${secretProperties['signing_keystore_password']}"
            keyAlias "${secretProperties['signing_key_alias']}"
            keyPassword "${secretProperties['signing_key_password']}"
        }
    }
Andy Trevorah's avatar
Andy Trevorah committed
67 68
    buildTypes {
        release {
69
            minifyEnabled false
70
            testCoverageEnabled false
Andy Trevorah's avatar
Andy Trevorah committed
71
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
72
            signingConfig signingConfigs.release
Andy Trevorah's avatar
Andy Trevorah committed
73 74 75 76
        }
    }
}

Andy Trevorah's avatar
Andy Trevorah committed
77 78 79 80
repositories {
    mavenCentral()
}

Andy Trevorah's avatar
Andy Trevorah committed
81
dependencies {
82 83 84
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:design:24.2.1'
    implementation 'com.android.volley:volley:1.0.0'
85
    implementation "com.google.android.gms:play-services-gcm:10.2.1"
86 87 88 89
    implementation 'joda-time:joda-time:2.5'
    implementation 'com.github.rahatarmanahmed:circularprogressview:2.4.0'
    implementation 'com.getbase:floatingactionbutton:1.10.1'
    testImplementation 'junit:junit:4.12'
Andy Trevorah's avatar
Andy Trevorah committed
90
}