build.gradle 4.02 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
    description("Download gitter-webapp assets from current release and move")
28
    def zipFile = file("${getTemporaryDir()}/webapp-artifacts.zip")
29 30 31 32 33
    doLast {
        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 } }
    }
}
34

35 36 37
task extractWebappAssets(type: Copy) {
    def zipFile = file("${buildDir}/tmp/fetchWebappAssets/webapp-artifacts.zip")
    def assetsDir = file("${projectDir}/src/main/assets")
38

39 40 41 42 43 44
    from zipTree(zipFile)
    into file("${buildDir}/tmp/fetchWebappAssets")
    
    doLast {
        ant.move file: file("${buildDir}/tmp/fetchWebappAssets/output/android/www"),
                todir: assetsDir
45
        delete(zipFile,)
46 47 48
    }
}

49
fetchWebappAssets.finalizedBy(extractWebappAssets)
50

Andy Trevorah's avatar
Andy Trevorah committed
51
android {
Eric Eastwood's avatar
Eric Eastwood committed
52
    compileSdkVersion 26
53
    buildToolsVersion '28.0.3'
Andy Trevorah's avatar
Andy Trevorah committed
54 55 56

    defaultConfig {
        applicationId "im.gitter.gitter"
Andy Trevorah's avatar
Andy Trevorah committed
57
        minSdkVersion 19
Eric Eastwood's avatar
Eric Eastwood committed
58
        targetSdkVersion 26
59
        versionCode Integer.valueOf(System.env.VERSION_CODE ?: 0)
60
        // Manually bump the semver version part of the string as necessary
61
        versionName "3.4.0-${System.env.VERSION_SHA}"
62

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

Andy Trevorah's avatar
Andy Trevorah committed
88 89 90 91
repositories {
    mavenCentral()
}

Andy Trevorah's avatar
Andy Trevorah committed
92
dependencies {
93 94 95
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:design:24.2.1'
    implementation 'com.android.volley:volley:1.0.0'
96
    implementation "com.google.android.gms:play-services-gcm:10.2.1"
97 98 99 100
    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
101
}