apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'

version '{{{containerVersion}}}'
def aId = '{{{artifactId}}}'
def gId  = '{{{groupId}}}'

artifacts {
    archives androidSourcesJar
}

publishing {
    publications {
        Production(MavenPublication) {
            artifact androidSourcesJar
            artifact("$buildDir/outputs/aar/lib-release.aar")
            groupId gId
            artifactId aId
            version this.version

            pom.withXml {
                def dependenciesNode = asNode().appendNode('dependencies')

                // Iterate over the implementation dependencies (we don't want the test ones), adding a <dependency> node for each
                configurations.implementation.allDependencies.each {
                    // Ensure dependencies such as fileTree are not included.
                    if (it.name != 'unspecified') {
                        def dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', it.group)
                        dependencyNode.appendNode('artifactId', it.name)
                        dependencyNode.appendNode('version', it.version)
                    }
                }
            }
        }
    }
}

bintray {
    user = bintrayUser
    key = bintrayApiKey
    publications = ['Production']
    configurations = ['archives']
    override = false
    pkg {
        repo = bintrayRepo
        name = aId
        description = "Container that holds the MiniApps, APIs and other native dependencies."
        publish = true
        licenses = ['Apache-2.0']
        vcsUrl = bintrayVcsUrl
        dryRun = false
        publicDownloadNumbers = true
        version {
            name = this.version
            desc = "${aId} ${this.version}"
            released  = new Date()
            vcsTag = this.version
        }
    }
}