build.gradle 3.62 KB
Newer Older
Lee Jaebin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'org.ajoberstar:gradle-git:0.12+'
        classpath 'com.google.gms:google-services:3.1.0'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

dependencies {
    implementation project(':ABVJE_UI_Android')
    implementation 'com.android.support:multidex:1.0.2'
}

android {
    compileSdkVersion 21
21
    buildToolsVersion '27.0.3'
Lee Jaebin committed
22 23

    defaultConfig {
24
        minSdkVersion 23
Lee Jaebin committed
25 26 27 28 29 30 31 32
        multiDexEnabled true

        // from gradle.properties
        applicationId app_custompackagename
        versionCode app_versioncode as int;
        versionName version_name

        buildConfigField("boolean", "isStoreProduct", "${isStoreProduct}")
Lee Jaebin committed
33
        manifestPlaceholders = [HOME_APP: "android.intent.category.DEFAULT"]
Lee Jaebin committed
34 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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
    }

    dexOptions {
        preDexLibraries = true
        jumboMode = true
        javaMaxHeapSize "2g"
    }
    signingConfigs {
        release {
            storeFile file(keystore)
            storePassword keystorepassword
            keyAlias keyalias
            keyPassword keyaliaspassword
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['res']
            aidl.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }
    }
    lintOptions {
        quiet true
        checkReleaseBuilds false
        abortOnError false
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    packagingOptions {
        exclude 'values/attrs.xml'
        exclude 'values/dimens.xml'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
    }

    flavorDimensions "default" // OK
    productFlavors {

        if (isStoreProduct.toBoolean()) {
            armv7 {
                versionCode defaultConfig.versionCode
                ndk {
                    abiFilters "armeabi-v7a", ""
                }
            }
            x86 {
                versionCode defaultConfig.versionCode + 1
                ndk {
                    abiFilters "x86", ""
                }
            }
            // 容量が大きいため、コメントアウト
//            x86_armv7 {
//                ndk {
//                    abiFilters "x86", "armeabi-v7a", ""
//                }
//            }
        } else {
            armv7 {
                versionCode defaultConfig.versionCode
                ndk {
                    abiFilters "armeabi-v7a", ""
                }
            }
        }
    }
}

import org.ajoberstar.grgit.*
task gitInfo << {
    description 'update githash.txt with current hash'
    def grgit = Grgit.open(project.file('..'))
    def gitfile=file('assets/githash.txt')
    gitfile.write grgit.head().id
}
preBuild.dependsOn gitInfo

task convertToPackage << {
    description 'convert to package for google-services.json'
    def appModuleRootFolder = '.'
    def googleServicesJson = 'google-services.json'
    copy {
        from "fcm"
        include "$googleServicesJson"
        into "$appModuleRootFolder"
        expand PACKAGE_NAME : app_custompackagename
    }
}
preBuild.dependsOn convertToPackage

gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.encoding = "UTF-8"
        options.compilerArgs << "-Xlint:unchecked" <<  "-Xlint:deprecation"
    }
}