XYOracleNetwork/sdk-xyo-client-android

View on GitHub
sdk/build.gradle

Summary

Maintainability
Test Coverage
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven-publish'
apply plugin: "de.mannodermaus.android-junit5"
apply plugin: "com.google.protobuf"

group = 'network.xyo'

def majorVersion = 2
def minorVersion = 1
def patchVersion = 5

def verCode = majorVersion  * 10000000 + minorVersion * 10000 + patchVersion
def verString = "" + majorVersion + "." + minorVersion + "(Build-" + patchVersion + ")"

android {
    compileSdk 33
    buildToolsVersion '30.0.3'

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 33
        versionCode verCode
        versionName verString

        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
        testInstrumentationRunnerArgument("runnerBuilder", "de.mannodermaus.junit5.AndroidJUnit5Builder")
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled false
            shrinkResources false
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8
    }

    namespace 'sdk.xyo.client.android'

    sourceSets {
        main {
            proto {
                srcDir 'src/main/java/network/xyo/client/proto'
            }
        }
    }
}

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.8.20"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
    implementation 'com.squareup.moshi:moshi-kotlin:1.14.0'
    implementation 'androidx.core:core-ktx:1.10.0'
    implementation 'com.squareup.okhttp3:okhttp:4.9.2'
    implementation 'com.madgag.spongycastle:prov:1.58.0.0'
    implementation 'com.madgag.spongycastle:pkix:1.54.0.0'
    implementation 'com.ionspin.kotlin:bignum:0.3.8'
    androidTestImplementation "androidx.test:runner:1.5.2"
    androidTestImplementation "androidx.test:rules:1.5.0"
    androidTestImplementation "androidx.test.ext:junit:1.1.5"
    androidTestImplementation "de.mannodermaus.junit5:android-test-core:1.3.0"
    androidTestRuntimeOnly "de.mannodermaus.junit5:android-test-runner:1.3.0"
    androidTestImplementation "org.junit.jupiter:junit-jupiter:5.9.2"
    implementation "androidx.datastore:datastore:1.0.0"
    implementation 'com.google.protobuf:protobuf-javalite:3.20.1'
}

publishing {
    publications {
        Production(MavenPublication) {
            artifact("$buildDir/outputs/aar/sdk-release.aar") {
                builtBy assemble
            }
            groupId 'network.xyo'
            artifactId 'sdk-xyo-client-android'
            version verString

            //The publication doesn't know about our dependencies, so we have to manually add them to the pom
            pom.withXml {
                def dependenciesNode = asNode()['dependencies'][0] ?: asNode().appendNode('dependencies')
                //Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
                configurations.implementation.allDependencies.each {
                    if (it.name != 'unspecified') {
                        def dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', it.group)
                        dependencyNode.appendNode('artifactId', it.name)
                        dependencyNode.appendNode('version', it.version)
                    }
                }
            }
        }
    }
}

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.20.1'
    }
    generateProtoTasks {
        all().configureEach { task ->
            task.builtins {
                java {
                    option "lite"
                }
            }
        }
    }
}