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

sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
    compile 'com.squareup:javapoet:1.8.0'
    compile 'com.google.auto.service:auto-service:1.0-rc2'
}

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives sourcesJar
    archives javadocJar
}

publishing {
    publications {
        library(MavenPublication) {
            from components.java

            artifact sourcesJar
            artifact javadocJar

            artifactId 'easybundler-compiler'
            groupId rootProject.ext.groupId
            version rootProject.ext.version
            pom.withXml {
                def root = asNode()
                root.appendNode('description', rootProject.ext.projectDescription)
                root.appendNode('name', rootProject.ext.projectName)
                root.appendNode('url', rootProject.ext.projectUrl)
                root.children().last() + rootProject.ext.pomConfig
            }
        }
    }
}

bintray {
    user = rootProject.ext.bintrayUser
    key = rootProject.ext.bintrayKey

    publications = ['library']

    pkg {
        name = 'easybundler-compiler'
        repo = rootProject.ext.bintrayRepo
        userOrg = rootProject.ext.bintrayOrg
        licenses = rootProject.ext.licenses
        vcsUrl = "${rootProject.ext.projectUrl}.git"

        version {
            name = rootProject.ext.version
        }
    }
}
