build.gradle 4.33 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 26 27 28 29 30 31 32 33 34



// Download gitter-webapp assets from current release
task fetchWebappAssets(type: GradleBuild) {
    description("Download gitter-webapp assets from current release and move")
    tasks = ['configureWebappAssets', 'downloadWebappAssets']
    
}

task configureWebappAssets() {
    doLast{
        file("${buildDir}/tmp/fetchWebappAssets").mkdirs()
35 36
    }
}
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
task downloadWebappAssets() {
    def zipFile = file("${buildDir}/tmp/fetchWebappAssets/webapp-artifacts.zip")
    doLast {
        def artifactURI = "https://gitlab.com/gitlab-org/gitter/webapp/-/jobs/artifacts/master/download?job=mobile-asset-build"
        println("Starte Download")
        new URL(artifactURI).withInputStream { i -> zipFile.withOutputStream { it << i } }
    }
}
task extractWebappAssets(type: Copy) {
    def zipFile = file("${buildDir}/tmp/fetchWebappAssets/webapp-artifacts.zip")
    def assetsDir = file("${projectDir}/src/main/assets")
    println("Extrahiere")
    from zipTree(zipFile)
    into file("${buildDir}/tmp/fetchWebappAssets")
    
    doLast {
        println("versuche zu verschieben")
        ant.move file: file("${buildDir}/tmp/fetchWebappAssets/output/android/www"),
                todir: assetsDir
    }
}

downloadWebappAssets.finalizedBy(extractWebappAssets)
60

Andy Trevorah's avatar
Andy Trevorah committed
61
android {
Eric Eastwood's avatar
Eric Eastwood committed
62
    compileSdkVersion 26
63
    buildToolsVersion '28.0.3'
Andy Trevorah's avatar
Andy Trevorah committed
64 65 66

    defaultConfig {
        applicationId "im.gitter.gitter"
Andy Trevorah's avatar
Andy Trevorah committed
67
        minSdkVersion 19
Eric Eastwood's avatar
Eric Eastwood committed
68
        targetSdkVersion 26
69
        versionCode Integer.valueOf(System.env.VERSION_CODE ?: 0)
70
        // Manually bump the semver version part of the string as necessary
71
        versionName "3.4.0-${System.env.VERSION_SHA}"
72

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

Andy Trevorah's avatar
Andy Trevorah committed
98 99 100 101
repositories {
    mavenCentral()
}

Andy Trevorah's avatar
Andy Trevorah committed
102
dependencies {
103 104 105
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:design:24.2.1'
    implementation 'com.android.volley:volley:1.0.0'
106
    implementation "com.google.android.gms:play-services-gcm:10.2.1"
107 108 109 110
    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
111
}