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 34
    buildToolsVersion '35.0.0'

    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:2.0.21'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0'
    implementation 'com.squareup.moshi:moshi-kotlin:1.15.1'
    implementation 'androidx.core:core-ktx:1.13.1'
    implementation 'com.squareup.okhttp3:okhttp:4.12.0'
    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.10'
    androidTestImplementation 'androidx.test:runner:1.6.2'
    androidTestImplementation 'androidx.test:rules:1.6.1'
    androidTestImplementation 'androidx.test.ext:junit:1.2.1'
    androidTestImplementation 'de.mannodermaus.junit5:android-test-core:1.6.0'
    androidTestRuntimeOnly 'de.mannodermaus.junit5:android-test-runner:1.6.0'
    androidTestImplementation 'org.junit.jupiter:junit-jupiter:5.11.3'
    implementation 'androidx.datastore:datastore:1.1.1'
    implementation 'com.google.protobuf:protobuf-javalite:4.28.3'
}

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"
                }
            }
        }
    }
}