Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save gianpaolof/fc62abd365be874b73e0740bb2728dd2 to your computer and use it in GitHub Desktop.

Select an option

Save gianpaolof/fc62abd365be874b73e0740bb2728dd2 to your computer and use it in GitHub Desktop.

Revisions

  1. @olivierperez olivierperez revised this gist Nov 29, 2016. 2 changed files with 9 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Android - Gradle tricks
    Original file line number Diff line number Diff line change
    @@ -10,4 +10,5 @@ Useful tricks for Android gradle files
    - isIdeBuild
    - nice buildConfigField
    - private signing certificate
    - specify the file name of production release
    - specify the file name of production release
    - tests shown in console
    7 changes: 7 additions & 0 deletions tests shown in console
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    testOptions.unitTests.all {
    testLogging {
    events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
    outputs.upToDateWhen { false }
    showStandardStreams = true
    }
    }
  2. @olivierperez olivierperez revised this gist Nov 18, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions private signing certificate
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    signingConfigs {
    release {
    storeFile "${System.env.MYAPP_PRIVATE_KEY}"
    keyAlias "${System.env.MYAPP_ALIAS}"
    storePassword "${System.env.MYAPP_STORE_PASSWORD}"
    keyPassword "${System.env.MYAPP_PASSWORD}"
    storeFile file(System.env.MYAPP_PRIVATE_KEY)
    keyAlias System.env.MYAPP_ALIAS
    storePassword System.env.MYAPP_STORE_PASSWORD
    keyPassword System.env.MYAPP_PASSWORD
    }
    }
  3. @olivierperez olivierperez revised this gist Oct 13, 2016. 4 changed files with 13 additions and 7 deletions.
    2 changes: 1 addition & 1 deletion Android - Gradle tricks
    Original file line number Diff line number Diff line change
    @@ -9,5 +9,5 @@ Useful tricks for Android gradle files
    - git sha
    - isIdeBuild
    - nice buildConfigField
    - nrivate signing certificate
    - private signing certificate
    - specify the file name of production release
    4 changes: 4 additions & 0 deletions force a lang for a specific flavor
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    // .gitignore

    /app/src/prod/res-gen

    // file: app/build.gradle

    apply from: '../forceRU.gradle'
    7 changes: 4 additions & 3 deletions git commit count
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    def VERSION_NAME = "1.0"
    def MAJOR_VERSION = 1
    def MINOR_VERSION = 0

    def gitCount() {
    def cmd = 'git rev-list --count HEAD'
    @@ -8,12 +9,12 @@ def gitCount() {
    android {
    productFlavors {
    dev {
    versionName VERSION_NAME
    versionCode MAJOR_VERSION * 100000 + MINOR_VERSION * 1000
    // and/or
    buildConfigField "String", "GIT_COUNT", "\"\""
    }
    prod {
    versionName "$VERSION_NAME-${gitCount()}"
    versionCode MAJOR_VERSION * 100000 + MINOR_VERSION * 1000 + getCount()
    // and/or
    buildConfigField "String", "GIT_COUNT", "\"${gitCount()}\""
    // Example: Crashlytics.setString("Git Count", BuildConfig.GIT_COUNT);
    7 changes: 4 additions & 3 deletions nice buildConfigField
    Original file line number Diff line number Diff line change
    @@ -3,19 +3,20 @@
    buildTypes {

    def ENABLE_LOGS = "ENABLE_LOGS"
    def BOOLEAN = "boolean"
    def TRUE = "true"
    def FALSE = "false"

    release {
    buildConfigField "boolean", ENABLE_LOGS, FALSE
    buildConfigField BOOLEAN, ENABLE_LOGS, FALSE
    }

    releaseWithLogs {
    buildConfigField "boolean", ENABLE_LOGS, TRUE
    buildConfigField BOOLEAN, ENABLE_LOGS, TRUE
    }

    debug {
    buildConfigField "boolean", ENABLE_LOGS, TRUE
    buildConfigField BOOLEAN, ENABLE_LOGS, TRUE
    }

    }
  4. @olivierperez olivierperez revised this gist Oct 10, 2016. 2 changed files with 20 additions and 0 deletions.
    1 change: 1 addition & 0 deletions Android - Gradle tricks
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@ Useful tricks for Android gradle files
    - ci_job
    - dependencies
    - force a lang for a specific flavor
    - gcm flavorish google-services.json
    - git commit count
    - git sha
    - isIdeBuild
    19 changes: 19 additions & 0 deletions gcm flavorish google-services.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    // Put google-services.json in your flavors directories
    // Then Git-ignore "app/google-services.json"

    gradle.taskGraph.beforeTask { Task task ->
    if (task.name ==~ /process.*GoogleServices/) {
    android.applicationVariants.all { variant ->
    if (task.name ==~ /(?i)process${variant.name}GoogleServices/) {
    def envFlavor = variant.productFlavors.get(0).name

    copy {
    from "./src/${envFlavor}"
    into '.'
    include 'google-services.json'
    }

    }
    }
    }
    }
  5. @olivierperez olivierperez revised this gist Oct 4, 2016. 1 changed file with 12 additions and 10 deletions.
    22 changes: 12 additions & 10 deletions specify the file name of production release
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,15 @@
    applicationVariants.all { variant ->
    variant.outputs.each { output ->
    if (variant.productFlavors[0].name.equals("prod")) {
    output.outputFile = new File(
    output.outputFile.parent,
    output.outputFile.name.replace(
    "app-prod-regular-release-unsigned",
    "monApp-prod-unsigned-" + versionName + "-" + versionCode
    )
    );
    buildTypes {
    applicationVariants.all { variant ->
    variant.outputs.each { output ->
    if (variant.productFlavors[0].name.equals("prod")) {
    output.outputFile = new File(
    output.outputFile.parent,
    output.outputFile.name.replace(
    "app-prod-regular-release-unsigned",
    "monApp-prod-unsigned-" + versionName + "-" + versionCode
    )
    );
    }
    }
    }
    }
  6. @olivierperez olivierperez revised this gist Oct 4, 2016. 2 changed files with 15 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Android - Gradle tricks
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,5 @@ Useful tricks for Android gradle files
    - git sha
    - isIdeBuild
    - nice buildConfigField
    - nrivate signing certificate
    - nrivate signing certificate
    - specify the file name of production release
    13 changes: 13 additions & 0 deletions specify the file name of production release
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    applicationVariants.all { variant ->
    variant.outputs.each { output ->
    if (variant.productFlavors[0].name.equals("prod")) {
    output.outputFile = new File(
    output.outputFile.parent,
    output.outputFile.name.replace(
    "app-prod-regular-release-unsigned",
    "monApp-prod-unsigned-" + versionName + "-" + versionCode
    )
    );
    }
    }
    }
  7. @olivierperez olivierperez revised this gist Oct 4, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Android - Gradle tricks
    Original file line number Diff line number Diff line change
    @@ -4,8 +4,8 @@ Useful tricks for Android gradle files
    - ci_job
    - dependencies
    - force a lang for a specific flavor
    - git sha
    - git commit count
    - git sha
    - isIdeBuild
    - nice buildConfigField
    - nrivate signing certificate
  8. @olivierperez olivierperez revised this gist Sep 23, 2016. 2 changed files with 9 additions and 9 deletions.
    10 changes: 5 additions & 5 deletions git commit count
    Original file line number Diff line number Diff line change
    @@ -6,16 +6,16 @@ def gitCount() {
    }

    android {
    buildTypes {
    release {
    productFlavors {
    dev {
    versionName VERSION_NAME
    // and/or
    buildConfigField "String", "GIT_COUNT", "\"\""
    }
    debug {
    versionName VERSION_NAME + "-" + gitCount()()
    prod {
    versionName "$VERSION_NAME-${gitCount()}"
    // and/or
    buildConfigField "String", "GIT_COUNT", "\"${gitCount()()}\""
    buildConfigField "String", "GIT_COUNT", "\"${gitCount()}\""
    // Example: Crashlytics.setString("Git Count", BuildConfig.GIT_COUNT);
    }
    }
    8 changes: 4 additions & 4 deletions git sha
    Original file line number Diff line number Diff line change
    @@ -7,14 +7,14 @@ def gitSha() {
    }

    android {
    buildTypes {
    release {
    productFlavors {
    dev {
    versionName VERSION_NAME
    // and/or
    buildConfigField "String", "GIT_SHA", "\"\""
    }
    debug {
    versionName VERSION_NAME + "-" + gitSha()
    prod {
    versionName "$VERSION_NAME-${gitSha()}"
    // and/or
    buildConfigField "String", "GIT_SHA", "\"${gitSha()}\""
    // Example: Crashlytics.setString("Git SHA", BuildConfig.GIT_SHA);
  9. @olivierperez olivierperez revised this gist Sep 23, 2016. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions git sha
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,9 @@
    def VERSION_NAME = "1.0"

    def gitVersion() {
    def gitSha() {
    // def cmd = 'git log -1 --format="%h"'
    def cmd = 'git rev-parse --short HEAD'
    cmd.execute().text.trim().toInteger()
    cmd.execute().text.trim()
    }

    android {
    @@ -14,9 +14,9 @@ android {
    buildConfigField "String", "GIT_SHA", "\"\""
    }
    debug {
    versionName VERSION_NAME + "-" + gitVersion()
    versionName VERSION_NAME + "-" + gitSha()
    // and/or
    buildConfigField "String", "GIT_SHA", "\"${gitVersion()}\""
    buildConfigField "String", "GIT_SHA", "\"${gitSha()}\""
    // Example: Crashlytics.setString("Git SHA", BuildConfig.GIT_SHA);
    }
    }
  10. @olivierperez olivierperez revised this gist Sep 23, 2016. 4 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
    File renamed without changes.
  11. @olivierperez olivierperez revised this gist Sep 23, 2016. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions Android - Gradle tricks
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    Useful tricks for Android gradle files

    - Build time
    - git sha
    - git commit count
    - Force a lang for a specific flavor
    - Nice buildConfigField
    - Private signing certificate
    - build time
    - ci_job
    - dependencies
    - isIdeBuild
    - force a lang for a specific flavor
    - git sha
    - git commit count
    - isIdeBuild
    - nice buildConfigField
    - nrivate signing certificate
  12. @olivierperez olivierperez revised this gist Sep 23, 2016. 3 changed files with 24 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Android - Gradle tricks
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    Useful tricks for Android gradle files

    - Build time
    - Find git version
    - git sha
    - git commit count
    - Force a lang for a specific flavor
    - Nice buildConfigField
    - Private signing certificate
    22 changes: 22 additions & 0 deletions git commit count
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    def VERSION_NAME = "1.0"

    def gitCount() {
    def cmd = 'git rev-list --count HEAD'
    cmd.execute().text.trim().toInteger()
    }

    android {
    buildTypes {
    release {
    versionName VERSION_NAME
    // and/or
    buildConfigField "String", "GIT_COUNT", "\"\""
    }
    debug {
    versionName VERSION_NAME + "-" + gitCount()()
    // and/or
    buildConfigField "String", "GIT_COUNT", "\"${gitCount()()}\""
    // Example: Crashlytics.setString("Git Count", BuildConfig.GIT_COUNT);
    }
    }
    }
    File renamed without changes.
  13. @olivierperez olivierperez revised this gist Sep 19, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Android - Gradle tricks
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,8 @@ Useful tricks for Android gradle files
    - Build time
    - Find git version
    - Force a lang for a specific flavor
    - Nice buildConfigField
    - Private signing certificate
    - ci_job
    - dependencies
    - isIdeBuild
    - Nice buildConfigField
    - isIdeBuild
  14. @olivierperez olivierperez revised this gist Sep 19, 2016. 2 changed files with 31 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion Android - Gradle tricks
    Original file line number Diff line number Diff line change
    @@ -1 +1,10 @@
    Useful tricks for Android gradle files
    Useful tricks for Android gradle files

    - Build time
    - Find git version
    - Force a lang for a specific flavor
    - Private signing certificate
    - ci_job
    - dependencies
    - isIdeBuild
    - Nice buildConfigField
    21 changes: 21 additions & 0 deletions Nice buildConfigField
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@


    buildTypes {

    def ENABLE_LOGS = "ENABLE_LOGS"
    def TRUE = "true"
    def FALSE = "false"

    release {
    buildConfigField "boolean", ENABLE_LOGS, FALSE
    }

    releaseWithLogs {
    buildConfigField "boolean", ENABLE_LOGS, TRUE
    }

    debug {
    buildConfigField "boolean", ENABLE_LOGS, TRUE
    }

    }
  15. @olivierperez olivierperez revised this gist Sep 15, 2016. 2 changed files with 46 additions and 38 deletions.
    46 changes: 46 additions & 0 deletions Force a lang for a specific flavor
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    // file: app/build.gradle

    apply from: '../forceRU.gradle'

    android {
    sourceSets {
    prod {
    res.srcDirs += ['src/prod/res-gen']
    }
    }
    }

    // file: forceRU.gradle

    project.afterEvaluate {
    android {
    applicationVariants.all { variant ->
    logger.trace("variant.name: ${variant.name}")
    logger.trace("variant.productFlavors[0].name: ${variant.productFlavors[0].name}")

    // Force RU values only for prod flavor
    if ("prod".equals(variant.productFlavors[0].name)) {

    def forceRU = task("forceRU${variant.name.capitalize()}")
    variant.mergeResources.dependsOn forceRU

    forceRU << {
    logger.info("Forcing strings to RU...")
    File valuesRU = file("src/main/res/values-ru")

    if (valuesRU.isDirectory() && valuesRU.list().length > 0) {
    logger.debug("Directory \"" + valuesRU.path + "\" exists")

    copy {
    from "src/main/res/values-ru/"
    into 'src/prod/res-gen/values/'
    include '*'
    }
    } else {
    throw new RuntimeException("\"" + valuesRU.path + "\" is not a drectory or is empty.")
    }
    }
    }
    }
    }
    }
    38 changes: 0 additions & 38 deletions Force a lang for prod flavor
    Original file line number Diff line number Diff line change
    @@ -1,38 +0,0 @@
    // file: app/build.gradle

    apply from: '../forceRU.gradle'

    // file: forceRU.gradle

    project.afterEvaluate {
    android {
    applicationVariants.all { variant ->
    // println("variant.name: ${variant.name}")
    // println("variant.productFlavors[0].name: ${variant.productFlavors[0].name}")

    // Force RU strings only for prod flavor
    if ("prod".equals(variant.productFlavors[0].name)) {

    def forceRU = task("forceRU${variant.name}")
    variant.mergeResources.dependsOn forceRU

    forceRU << {
    println("Forcing strings to RU...")
    File stringsRU = file("src/main/res/values-ru/strings.xml")

    if (stringsRU.exists()) {
    println("File: " + stringsRU.path + " exists")

    copy {
    from "src/main/res/values-ru/"
    into 'src/prod/res/values/'
    include '*'
    }
    } else {
    throw new RuntimeException("File: " + stringsRU.path + " does not exist")
    }
    }
    }
    }
    }
    }
  16. @olivierperez olivierperez revised this gist Sep 14, 2016. 1 changed file with 38 additions and 0 deletions.
    38 changes: 38 additions & 0 deletions Force a lang for prod flavor
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    // file: app/build.gradle

    apply from: '../forceRU.gradle'

    // file: forceRU.gradle

    project.afterEvaluate {
    android {
    applicationVariants.all { variant ->
    // println("variant.name: ${variant.name}")
    // println("variant.productFlavors[0].name: ${variant.productFlavors[0].name}")

    // Force RU strings only for prod flavor
    if ("prod".equals(variant.productFlavors[0].name)) {

    def forceRU = task("forceRU${variant.name}")
    variant.mergeResources.dependsOn forceRU

    forceRU << {
    println("Forcing strings to RU...")
    File stringsRU = file("src/main/res/values-ru/strings.xml")

    if (stringsRU.exists()) {
    println("File: " + stringsRU.path + " exists")

    copy {
    from "src/main/res/values-ru/"
    into 'src/prod/res/values/'
    include '*'
    }
    } else {
    throw new RuntimeException("File: " + stringsRU.path + " does not exist")
    }
    }
    }
    }
    }
    }
  17. @olivierperez olivierperez revised this gist Sep 14, 2016. 2 changed files with 2 additions and 0 deletions.
    1 change: 1 addition & 0 deletions Build time
    Original file line number Diff line number Diff line change
    @@ -15,6 +15,7 @@ android {
    versionName VERSION_NAME + "-" + buildTime()
    // and/or
    buildConfigField "String", "BUILD_TIME", "\"${buildTime()}\""
    // Example: Crashlytics.setString("Build time", BuildConfig.BUILD_TIME);
    }
    }
    }
    1 change: 1 addition & 0 deletions Find git version
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,7 @@ android {
    versionName VERSION_NAME + "-" + gitVersion()
    // and/or
    buildConfigField "String", "GIT_SHA", "\"${gitVersion()}\""
    // Example: Crashlytics.setString("Git SHA", BuildConfig.GIT_SHA);
    }
    }
    }
  18. @olivierperez olivierperez revised this gist Sep 14, 2016. 2 changed files with 4 additions and 3 deletions.
    2 changes: 1 addition & 1 deletion Build time
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    def VERSION_NAME = "1.0"

    def buildTime() {
    new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'", TimeZone.getTimeZone("UTC")
    new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'", TimeZone.getTimeZone("UTC")
    }

    android {
    5 changes: 3 additions & 2 deletions Find git version
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,9 @@
    def VERSION_NAME = "1.0"

    def gitVersion() {
    def cmd = 'git log -1 --format="%h"'
    cmd.execute().text.trim().toInteger()
    // def cmd = 'git log -1 --format="%h"'
    def cmd = 'git rev-parse --short HEAD'
    cmd.execute().text.trim().toInteger()
    }

    android {
  19. @olivierperez olivierperez revised this gist Sep 14, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Find git version
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    def VERSION_NAME = "1.0"

    def gitVersion() {
    def cmd = 'git rev-list HEAD --first-parent --count'
    def cmd = 'git log -1 --format="%h"'
    cmd.execute().text.trim().toInteger()
    }

  20. @olivierperez olivierperez revised this gist Sep 14, 2016. 1 changed file with 20 additions and 0 deletions.
    20 changes: 20 additions & 0 deletions Build time
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    def VERSION_NAME = "1.0"

    def buildTime() {
    new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'", TimeZone.getTimeZone("UTC")
    }

    android {
    buildTypes {
    release {
    versionName VERSION_NAME
    // and/or
    buildConfigField "String", "BUILD_TIME", "\"\""
    }
    debug {
    versionName VERSION_NAME + "-" + buildTime()
    // and/or
    buildConfigField "String", "BUILD_TIME", "\"${buildTime()}\""
    }
    }
    }
  21. @olivierperez olivierperez revised this gist Sep 14, 2016. No changes.
  22. @olivierperez olivierperez revised this gist Sep 14, 2016. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions Find git version
    Original file line number Diff line number Diff line change
    @@ -9,9 +9,13 @@ android {
    buildTypes {
    release {
    versionName VERSION_NAME
    // and/or
    buildConfigField "String", "GIT_SHA", "\"\""
    }
    debug {
    versionName VERSION_NAME + "-" + gitVersion()
    // and/or
    buildConfigField "String", "GIT_SHA", "\"${gitVersion()}\""
    }
    }
    }
  23. @olivierperez olivierperez revised this gist Sep 14, 2016. 1 changed file with 17 additions and 0 deletions.
    17 changes: 17 additions & 0 deletions Find git version
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    def VERSION_NAME = "1.0"

    def gitVersion() {
    def cmd = 'git rev-list HEAD --first-parent --count'
    cmd.execute().text.trim().toInteger()
    }

    android {
    buildTypes {
    release {
    versionName VERSION_NAME
    }
    debug {
    versionName VERSION_NAME + "-" + gitVersion()
    }
    }
    }
  24. @olivierperez olivierperez revised this gist Sep 14, 2016. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions Private signing certificate
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    signingConfigs {
    release {
    storeFile "${System.env.MYAPP_PRIVATE_KEY}"
    keyAlias "${System.env.MYAPP_ALIAS}"
    storePassword "${System.env.MYAPP_STORE_PASSWORD}"
    keyPassword "${System.env.MYAPP_PASSWORD}"
    }
    }
  25. @olivierperez olivierperez revised this gist Sep 14, 2016. 2 changed files with 2 additions and 5 deletions.
    3 changes: 0 additions & 3 deletions dependencies
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,6 @@ ext.versions = [
    // etc...
    ]


    ext.deps = [
    // Dependency injection
    dagger : "com.google.dagger:dagger:${versions.dagger}",
    @@ -15,10 +14,8 @@ ext.deps = [
    rxAndroid : "io.reactivex:rxandroid:${versions.rxAndroid}",
    rxJava : "io.reactivex:rxjava:${versions.rxJava}",
    rxJavaProguard : "com.artemzin.rxjava:proguard-rules:${versions.rxJava}.0",

    ]


    dependencies {
    // Dependency injection
    compile deps.dagger
    4 changes: 2 additions & 2 deletions isIdeBuild
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    // V1
    // Trick 1
    allprojects {
    ext {
    isCIBuild = System.getenv('BUILD_ID')
    }
    }

    // V2
    // Trick 2
    allprojects {
    ext {
    isIdeBuild = project.properties['android.injected.invoked.from.ide'] == 'true'
  26. @olivierperez olivierperez revised this gist Sep 14, 2016. 1 changed file with 31 additions and 0 deletions.
    31 changes: 31 additions & 0 deletions dependencies
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    ext.versions = [
    dagger : '2.7',
    rxAndroid : '1.2.1',
    rxJava : '1.1.6',
    // etc...
    ]


    ext.deps = [
    // Dependency injection
    dagger : "com.google.dagger:dagger:${versions.dagger}",
    daggerCompiler : "com.google.dagger:dagger-compiler:${versions.dagger}",

    // RxJava
    rxAndroid : "io.reactivex:rxandroid:${versions.rxAndroid}",
    rxJava : "io.reactivex:rxjava:${versions.rxJava}",
    rxJavaProguard : "com.artemzin.rxjava:proguard-rules:${versions.rxJava}.0",

    ]


    dependencies {
    // Dependency injection
    compile deps.dagger
    apt deps.daggerCompiler

    // RxJava
    compile deps.rxAndroid
    compile deps.rxJava
    compile deps.rxJavaProguard
    }
  27. @olivierperez olivierperez revised this gist Sep 14, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Android - Gradle tricks
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    Android - Gradle tricks
    Useful tricks for Android gradle files
  28. @olivierperez olivierperez created this gist Sep 14, 2016.
    1 change: 1 addition & 0 deletions Android - Gradle tricks
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    Android - Gradle tricks
    46 changes: 46 additions & 0 deletions ci_job
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    task ci_job {
    group = 'ci'
    }

    if (project.hasProperty('buildVariant') && !project.property('buildVariant').isEmpty()) {

    def checkVariant = '[RegularRelease]'
    def testVariant = '[MockDebug]'

    project.afterEvaluate {

    /* Assemble */

    def assemble = tasks["assemble${buildVariant}"]
    assemble.mustRunAfter clean

    /* Unit test */

    def unitTests = project.tasks["test${testVariant}UnitTest"]
    unitTests.mustRunAfter assemble
    unitTests.onlyIf {
    !project.hasProperty('skipUnitTest') || project.property('skipUnitTest') != 'true'
    }

    /* Quality */
    task quality
    quality.dependsOn project.tasks["lint${checkVariant}"]
    quality.dependsOn project.tasks["findbugs${checkVariant}"]
    quality.dependsOn project.tasks["checkstyle"]
    quality.onlyIf {
    !project.hasProperty('skipQuality') || project.property('skipQuality') != 'true'
    }

    /* Execute all */

    ci_job.dependsOn clean
    ci_job.dependsOn assemble
    ci_job.dependsOn unitTests
    ci_job.dependsOn quality

    }
    } else {
    ci_job << {
    println "Nothing to do, buildVariant is not wel defined"
    }
    }
    13 changes: 13 additions & 0 deletions isIdeBuild
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    // V1
    allprojects {
    ext {
    isCIBuild = System.getenv('BUILD_ID')
    }
    }

    // V2
    allprojects {
    ext {
    isIdeBuild = project.properties['android.injected.invoked.from.ide'] == 'true'
    }
    }