maoni-sample/build.gradle

Summary

Maintainability
Test Coverage
/*
 * Copyright (c) 2016-2022 Armel Soro
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

apply plugin: 'com.android.application'
apply plugin: 'com.mikepenz.aboutlibraries.plugin'
apply plugin: 'kotlin-android'
//apply plugin: 'jacoco-android'

Properties localProperties = new Properties()
try {
    localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
} catch (FileNotFoundException fnfe) {
    //No worries
    logger.info(fnfe.getClass().getSimpleName() + " : " + fnfe.getMessage() +
        " => maoni-github callback will not be available!\n")
}
//maoni-github creds
def ghUsername = localProperties.getProperty('github.username', "")
def ghPasswordToken = localProperties.getProperty('github.passwordToken', "")

//maoni-jira creds
def jiraRestBaseUrl = localProperties.getProperty('jira.rest.baseUrl', "")
def jiraUsername = localProperties.getProperty('jira.username', "")
def jiraPassword = localProperties.getProperty('jira.password', "")

//maoni-slack creds
def slackWebhookUrl = localProperties.getProperty('slack.webhook.url', "")
def slackChannel = localProperties.getProperty('slack.channel', "")
def slackUsername = localProperties.getProperty('slack.username', "")
def slackIconUrl = localProperties.getProperty('slack.icon.url', "")
def slackEmojiIcon = localProperties.getProperty('slack.emoji.icon', "")

android {
    compileSdkVersion 32

    signingConfigs {
        debug {
            (keyAlias, storeFile, storePassword, keyPassword) = rootProject.getDebugSigningConfig()
        }
        release {

            def (store_file, store_password, key_alias, key_password) = rootProject.getReleaseSigningInfo(android)

            if (key_alias != null) {
                keyAlias key_alias
            }
            if (key_password != null) {
                keyPassword key_password
            }
            if (store_file != null) {
                storeFile store_file
            }
            if (store_password != null) {
                storePassword store_password
            }
        }
    }

    sourceSets {
        main {
            manifest.srcFile 'src/main/AndroidManifest.xml'
            //noinspection GroovyAssignabilityCheck
            java.srcDirs = ['src/main/java']
            //noinspection GroovyAssignabilityCheck
            resources.srcDirs = ['src/main/res']
            aidl.srcDirs = ['src/main/res']
            renderscript.srcDirs = ['src/main/java']
            res.srcDirs = ['src/main/res']
            assets.srcDirs = ['src/main/assets']
        }

        main.java.srcDirs += 'src/main/kotlin'

//        // Move the tests to tests/java, tests/res, etc...
//        instrumentTest.setRoot('src/androidTests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')
    }

    defaultConfig {
        applicationId "org.rm3l.maoni.sample"
        minSdkVersion 19
        targetSdkVersion 32
        versionCode maoni_version.replace('.', '').toInteger()
        versionName "${maoni_version}"

        vectorDrawables.useSupportLibrary = true

//        playAccountConfig = playAccountConfigs.defaultAccountConfig
    }

    buildTypes {
        release {
            minifyEnabled true

            buildConfigField "String", "GITHUB_USERNAME", "\"${ghUsername}\""
            buildConfigField "String", "GITHUB_PASSWORD_TOKEN", "\"${ghPasswordToken}\""

            buildConfigField "String", "JIRA_REST_BASE_URL", "\"${jiraRestBaseUrl}\""
            buildConfigField "String", "JIRA_USERNAME", "\"${jiraUsername}\""
            buildConfigField "String", "JIRA_PASSWORD", "\"${jiraPassword}\""

            buildConfigField "String", "SLACK_WEBHOOK_URL", "\"${slackWebhookUrl}\""
            buildConfigField "String", "SLACK_CHANNEL", "\"${slackChannel}\""
            buildConfigField "String", "SLACK_USERNAME", "\"${slackUsername}\""
            buildConfigField "String", "SLACK_ICON_URL", "\"${slackIconUrl}\""
            buildConfigField "String", "SLACK_EMOJI_ICON", "\"${slackEmojiIcon}\""

            signingConfig signingConfigs.release
            zipAlignEnabled true
            proguardFiles 'proguard-rules-r8.pro'
        }
        debug {
            testCoverageEnabled true
            minifyEnabled true

            buildConfigField "String", "GITHUB_USERNAME", "\"${ghUsername}\""
            buildConfigField "String", "GITHUB_PASSWORD_TOKEN", "\"${ghPasswordToken}\""

            buildConfigField "String", "JIRA_REST_BASE_URL", "\"${jiraRestBaseUrl}\""
            buildConfigField "String", "JIRA_USERNAME", "\"${jiraUsername}\""
            buildConfigField "String", "JIRA_PASSWORD", "\"${jiraPassword}\""

            buildConfigField "String", "SLACK_WEBHOOK_URL", "\"${slackWebhookUrl}\""
            buildConfigField "String", "SLACK_CHANNEL", "\"${slackChannel}\""
            buildConfigField "String", "SLACK_USERNAME", "\"${slackUsername}\""
            buildConfigField "String", "SLACK_ICON_URL", "\"${slackIconUrl}\""
            buildConfigField "String", "SLACK_EMOJI_ICON", "\"${slackEmojiIcon}\""

            zipAlignEnabled true
            signingConfig signingConfigs.debug
            proguardFiles 'proguard-rules-r8.pro'
        }
    }
    lintOptions {
//        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    // For Kotlin projects
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "org.jetbrains.anko:anko-sdk27:$anko_version"
    implementation "org.jetbrains.anko:anko-sdk27:$anko_version"
    implementation "org.jetbrains.anko:anko-sdk27-listeners:$anko_version"

    implementation project(":maoni")
    implementation project(":callbacks:maoni-github")
    implementation project(":callbacks:maoni-jira")
    implementation project(":callbacks:maoni-slack")

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.13.2'
    implementation 'com.google.android.material:material:1.6.1'
    implementation 'androidx.appcompat:appcompat:1.4.2'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.facebook.stetho:stetho:1.6.0'
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.14'
    implementation("com.mikepenz:aboutlibraries:${aboutlibraries_version}@aar") {
        transitive = true
    }
}