apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'maven-publish'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.0"

    defaultConfig {
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        consumerProguardFiles 'consumer-rules.pro'
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        rubikRelease {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    kotlinOptions.freeCompilerArgs += ['-module-name', "kmd.mars.rubik.router"]
    lintOptions {
        abortOnError false
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'com.google.code.gson:gson:2.8.5'

    implementation deps.ktnail.x

    //    api project(':rubik_annotations')
    api deps.rubik.annotations
}

publishing {
    publications {
        rubikRouter(MavenPublication) {
            groupId 'com.rubik'
            artifactId 'router'
            version pubs.rubik.router
            description 'rubik'
            artifact("build/intermediates/aar_main_jar/rubikRelease/classes.jar")
            pom.withXml {
                def dependenciesNode = asNode().appendNode('dependencies')
                configurations.api.allDependencies.each {
                    if (it.group != null && (it.name != null || "unspecified" == it.name) && it.version != null) {
                        def dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', it.group)
                        dependencyNode.appendNode('artifactId', it.name)
                        dependencyNode.appendNode('version', it.version)
                    }
                }
                configurations.implementation.allDependencies.each {
                    if (it.group != null && (it.name != null || "unspecified" == it.name) && it.version != null) {
                        def dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', it.group)
                        dependencyNode.appendNode('artifactId', it.name)
                        dependencyNode.appendNode('version', it.version)
                    }
                }
            }
        }
    }

    apply from: '../rubik_maven_repositories.gradle'
    addRubikMavenRepos(repositories)
}