apply plugin: "com.android.library"


android {
    compileSdkVersion  29 // sdk level 21 lets ndk generate resources for archs such as arm64.
    defaultConfig {
        // applicationId "io.antmedia.rtmpclient"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cppFlags "-frtti -fexceptions"
                arguments '-DANDROID_PLATFORM=android-15'
                abiFilters 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' //, 'armeabi', 'mips', 'mips64'
            }
        }
    }
    lintOptions {
        abortOnError false
    }

    buildTypes {
        release {
            minifyEnabled  false
            proguardFiles.add(file("proguard-rules.pro"))
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

    externalNativeBuild {
        cmake {
            path "CMakeLists.txt"

        }
    }
}


ext {
    bintrayRepo = 'maven'
    bintrayName = 'rtmp-client'

    publishedGroupId = 'io.antmedia'
    libraryName = 'rtmp-client'
    artifact = 'rtmp-client'

    libraryDescription = 'RTMP Client for Android. It supports all architectures with 300KB total size'

    siteUrl = 'https://github.com/ant-media/Librtmp-Client-for-Android'
    gitUrl = 'https://github.com/ant-media/LibRtmp-Client-for-Android.git'

    libraryVersion = '3.2.0'

    developerId = 'mekya'
    developerName = 'Ahmet Oguz Mermerkaya'
    developerEmail = 'ahmetmermerkaya@gmail.com'

    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ["Apache-2.0"]
}


task androidSourcesJar(type: Jar) {
    archiveClassifier.set('sources')
    from android.sourceSets.main.java.srcDirs
}

/////////////////////////////////////////////////////
version = libraryVersion
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

afterEvaluate {
    publishing {
        publications {
            // Creates a Maven publication called "release".
            release(MavenPublication) {

                groupId = publishedGroupId
                artifactId = artifact
                version = libraryVersion

                artifact bundleReleaseAar
                artifact androidSourcesJar
                pom {
                    name = libraryName
                    description = libraryDescription
                    url = siteUrl

                    licenses {
                        license {
                            name = licenseName
                            url = licenseUrl
                        }
                    }
                    developers {
                        developer {
                            id = developerId
                            name = developerName
                            email = developerEmail
                        }
                    }

                    scm {
                        connection = gitUrl
                        developerConnection = gitUrl
                        url = siteUrl
                    }
                }
            }

        }
//        repositories {
//            maven {
//                credentials {
//                    username properties.getProperty("maven.user")
//                    password properties.getProperty("maven.password")
//                }
//
//                def releasesRepoUrl = 'https://oss.sonatype.org/service/local/repositories/releases/content'
//                def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
//                url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
//            }
//        }
    }

//    signing {
//        sign publishing.publications.release
//    }
}

//How to upload
//./gradlew clean build publish




