build.gradle 3.87 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 23 24 25



// Download gitter-webapp assets from current release
26
task fetchWebappAssets() {
27 28
    description("Download gitter-webapp assets from current release and move")
    doLast {
29 30
        def zipFile = file("${getTemporaryDir()}/webapp-artifacts.zip")
        def assetsDir = file("${projectDir}/src/main/assets")
31 32
        def artifactURI = "https://gitlab.com/gitlab-org/gitter/webapp/-/jobs/artifacts/master/download?job=mobile-asset-build"
        new URL(artifactURI).withInputStream { i -> zipFile.withOutputStream { it << i } }
33 34 35 36 37
        copy {
            from zipTree(zipFile)
            into file("${getTemporaryDir()}")
        }
        ant.move file: file("${getTemporaryDir()}/output/android/www"),
38
                todir: assetsDir
39
        delete(zipFile, getTemporaryDir())
40 41 42
    }
}

Andy Trevorah's avatar
Andy Trevorah committed
43
android {
Eric Eastwood's avatar
Eric Eastwood committed
44
    compileSdkVersion 26
45
    buildToolsVersion '28.0.3'
Andy Trevorah's avatar
Andy Trevorah committed
46 47 48

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

55 56 57 58
        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
59
    }
60 61 62 63
    signingConfigs {
        release {
            // You need to specify either an absolute path or include the
            // keystore file in the same directory as the build.gradle file.
64
            storeFile file("../android-signing-keystore.jks")
65 66 67 68 69
            storePassword "${secretProperties['signing_keystore_password']}"
            keyAlias "${secretProperties['signing_key_alias']}"
            keyPassword "${secretProperties['signing_key_password']}"
        }
    }
Andy Trevorah's avatar
Andy Trevorah committed
70 71
    buildTypes {
        release {
72
            minifyEnabled false
73
            testCoverageEnabled false
Andy Trevorah's avatar
Andy Trevorah committed
74
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
75
            signingConfig signingConfigs.release
Andy Trevorah's avatar
Andy Trevorah committed
76 77 78 79
        }
    }
}

Andy Trevorah's avatar
Andy Trevorah committed
80 81 82 83
repositories {
    mavenCentral()
}

Andy Trevorah's avatar
Andy Trevorah committed
84
dependencies {
85 86 87
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:design:24.2.1'
    implementation 'com.android.volley:volley:1.0.0'
88
    implementation "com.google.android.gms:play-services-gcm:10.2.1"
89 90 91 92
    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
93
}