Skip to content
Snippets Groups Projects
build.gradle 5.32 KiB
Newer Older
import org.ajoberstar.grgit.Grgit

        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.22.2'
        classpath 'io.realm:realm-gradle-plugin:3.4.0'
        classpath 'org.ajoberstar:grgit:1.5.0'
    id 'net.researchgate.release' version '2.6.0'
apply plugin: 'com.android.application'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url "https://jitpack.io" }
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
def gitVersion() {
    // current dir is <your proj>/app, so it's likely that all your git repo files are in the dir
    // above.
    ext.repo = Grgit.open()

    // should result in the same value as running
    // git tag -l | wc -l or git tag -l | grep -c ".*" -
    def numOfTags = ext.repo.tag.list().size()
    return numOfTags
}

def gitCommitId() {
    ext.repo = Grgit.open()

    return ext.repo.log().first().id.substring(0, 7) //+ " " + ext.repo.branch.current.name
}

def gitBranch() {
    ext.repo = Grgit.open()
    return ext.repo.branch.current.name
static def getBugfenderApiKey() {
    Properties properties = new Properties()
    properties.load(new FileInputStream("app/bugfender.properties"))
    return "\"" + properties.getProperty("apiKey", "") + "\""
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
    // FIXME - replace with URLConnection. This is used in ManageCNLActivity.
    applicationVariants.all { variant ->
        variant.resValue "string", "versionName", variant.versionName
    }

Volker Richert's avatar
Volker Richert committed
        minSdkVersion 14
        versionName project.properties['version'] + "/" + gitCommitId() // + " (" + gitBranch()+")"
        versionCode gitVersion()
        buildConfigField "String", "BUGFENDER_API_KEY", getBugfenderApiKey()
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
        // Dag nabbit :(
        // Because of http://stackoverflow.com/questions/35492259/lint-error-on-okio
        warning 'InvalidPackage'
task signRelease {
    doLast {
        def command = [
                'jarsigner',
                '-verbose',
                '-sigalg',
                'SHA1withRSA',
                '-digestalg',
                'SHA1',
                '-keystore',
                '/Users/lennart/keystores/nightscout_android.jks',
                'app/build/outputs/apk/app-release-unsigned.apk',
                'nightscoutandroidkey'
        ]

        def proc = new ProcessBuilder(command)
                .redirectOutput(ProcessBuilder.Redirect.INHERIT)
                .redirectInput(ProcessBuilder.Redirect.INHERIT)
                .redirectError(ProcessBuilder.Redirect.INHERIT)
                .start()

        proc.waitFor()

        if (0 != proc.exitValue()) {
            throw new RuntimeException("Could not sign APK.")
        }
task zipalignRelease {
    doLast {
        def command = [
                '/Users/lennart/Library/Android/sdk/build-tools/25.0.2/zipalign',
                '-v',
                '4',
                'app/build/outputs/apk/app-release-unsigned.apk',
                'app/build/outputs/apk/600-series-uploader.apk'
        ]

        def proc = new ProcessBuilder(command)
                .redirectOutput(ProcessBuilder.Redirect.INHERIT)
                .redirectInput(ProcessBuilder.Redirect.INHERIT)
                .redirectError(ProcessBuilder.Redirect.INHERIT)
                .start()

        proc.waitFor()

        if (0 != proc.exitValue()) {
            throw new RuntimeException("Could not align APK.")
        }
    buildTasks = ['build']
    beforeReleaseBuild.dependsOn 'clean'
    afterReleaseBuild.dependsOn 'signRelease', 'zipalignRelease'
dependencies {
    compile files('libs/slf4j-api-1.7.2.jar')

    compile 'com.android.support:support-v13:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.android.support:cardview-v7:25.3.1'
    compile 'org.apache.commons:commons-lang3:3.4'
    compile 'com.mikepenz:google-material-typeface:2.2.0.1.original@aar'
    compile 'uk.co.chrisjenx:calligraphy:2.2.0'
    compile 'com.bugfender.sdk:android:0.7.2'
    compile 'com.jjoe64:graphview:4.0.1'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
        transitive = true;
    }

    // The version of okhttp3 *must* be the same as the version in AppUpdater
    compile 'com.squareup.okhttp3:okhttp:3.6.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.6.0'

    compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }
    compile('com.mikepenz:materialdrawer:5.2.9@aar') {
        transitive = true
    }
    compile 'com.github.javiersantos:AppUpdater:2.6.1'
Lennart Goedhart's avatar
Lennart Goedhart committed
}