// Configures common publishing settings.

apply plugin: "maven-publish"
apply plugin: "signing"
group = rootProject.group
version = rootProject.version
task sourceJar(type: Jar) {
    if (project.hasProperty("kotlin")) {
        from android.sourceSets.main.java.getSrcDirs()
    } else if (project.hasProperty("android")) {
        from android.sourceSets.main.java.sourceFiles
    } else {
        from sourceSets.main.allSource
    }
    archiveClassifier = 'sources'
}
afterEvaluate {
    publishing {
        publications {
            mavenJava(MavenPublication) {
                artifact sourceJar
                artifactId = PROJ_NAME
                from(components.release)
                pom {
                    packaging = "aar"
                    name = PROJ_BASENAME
                    description = PROJ_DESCRIPTION
                    url = PROJ_WEBSITEURL
                    licenses {
                        license {
                            name =  'The Apache License, Version 2.0'
                            url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                        }
                    }
                    developers {
                        developer {
                            id = DEVELOPER_ID
                            name = DEVELOPER_NAME
                            email = DEVELOPER_EMAIL
                        }
                    }

                    scm {
                        connection = PROJ_VCSURL
                        developerConnection = PROJ_VCSURL
                        url = PROJ_WEBSITEURL
                    }
                }
            }
        }
    }
    signing {
        sign publishing.publications.mavenJava
    }
}
