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

android {
    compileSdkVersion versions.compileSdk
    defaultConfig {
        minSdkVersion versions.minSdk
        targetSdkVersion versions.targetSdk
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    namespace 'com.bakerj.rxretrohttp'
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    api 'com.squareup.retrofit2:retrofit:2.8.1'
    api 'com.squareup.okhttp3:okhttp:4.2.2'
    api 'com.squareup.okhttp3:okhttp-urlconnection:3.11.0'
    api 'io.reactivex.rxjava2:rxjava:2.2.9'
    api 'io.reactivex.rxjava2:rxandroid:2.1.1'
    api 'com.alibaba:fastjson:1.2.54'
    api 'com.squareup.retrofit2:adapter-rxjava2:2.8.1'
    api 'com.trello.rxlifecycle3:rxlifecycle:3.0.0'
    api 'com.trello.rxlifecycle3:rxlifecycle-android:3.0.0'
    api 'com.trello.rxlifecycle3:rxlifecycle-components:3.0.0'
    implementation 'com.facebook.stetho:stetho:1.5.0'
    implementation 'com.facebook.stetho:stetho-okhttp3:1.5.0'
}

afterEvaluate {
    publishing {
        publications {
            // Creates a Maven publication called "release".
            release(MavenPublication) {
//                println("Com-------:"+components*.name)
                // Applies the component for the release build variant.
//                from components.release

                // You can then customize attributes of the publication as shown below.
                groupId = 'com.github.BakerJQ'
                artifactId = 'RxRetroHttp'
                version = '1.2.10'
                artifact(bundleReleaseAar)
                //generate pom nodes for dependencies
                pom.withXml {
                    def dependenciesNode = asNode().appendNode('dependencies')
                    configurations.implementation.allDependencies.each { dependency ->
                        if (dependency.name != 'unspecified') {
                            def dependencyNode = dependenciesNode.appendNode('dependency')
                            dependencyNode.appendNode('groupId', dependency.group)
                            dependencyNode.appendNode('artifactId', dependency.name)
                            dependencyNode.appendNode('version', dependency.version)
                        }
                    }
                }
                // Creates a Maven publication called “debug”.
//            debug(MavenPublication) {
//                // Applies the component for the debug build variant.
//                from components.debug
//
//                groupId = 'com.example.MyLibrary'
//                artifactId = 'final-debug'
//                version = '1.0'
//            }
            }
        }
    }
}