plugins {
    id "com.jfrog.bintray" version "1.7.3"
    id "java-library"
    id "maven-publish"
}

sourceCompatibility = '1.8'

version = '1.2.2'
def versionDescription = 'FXRibbon'


[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

jar {
    manifest {
        attributes( 'Implementation-Title': project.name,
                    'Implementation-Version': project.version)
    }
}

task javadocJar(type: Jar) {
    classifier = 'javadoc'
    from javadoc
}

javadoc {
    options.addStringOption('javafx', '-quiet')
}

task sourceJar(type: Jar) {
    from sourceSets.main.allJava
    classifier "sources"
}

artifacts {
    archives sourceJar
    archives javadocJar
}

/* Publishing */
bintray {
    user = System.getenv('BINTRAY_USER')
    key = System.getenv('BINTRAY_KEY')
    pkg {
        repo = 'maven'
        name = project.name
        //userOrg = 'dukke'
        licenses = ['BSD New']
        vcsUrl = 'https://github.com/dukke/FXRibbon.git'
        publications = ['mavenJava']
        websiteUrl = 'https://www.pixelduke.com/fxribbon'
        issueTrackerUrl = 'https://github.com/dukke/FXRibbon/issues'
        publicDownloadNumbers = true
        version {
            name = project.version
            desc = versionDescription // Version description
            vcsTag = project.version
            mavenCentralSync {
                sync = true
                user = System.getenv('MAVEN_USERNAME')
                password = System.getenv('MAVEN_PASSWORD')
            }
        }
    }
}

def pomConfig = {
    packaging 'jar'
    name project.name
    url 'https://pixelduke.com/fxribbon/'
    inceptionYear '2014'
    licenses {
        license([:]) {
            name 'BSD New'
            url 'https://opensource.org/licenses/BSD-3-Clause'
            distribution 'repo'
        }
    }
    scm {
        url 'https://github.com/dukke/FXRibbon.git'
    }
    developers {
        [
                dukke: 'Pedro Duque Vieira',
        ].each { devId, devName ->
            developer {
                id devId
                name devName
                roles {
                    role 'Developer'
                }
            }
        }
    }
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
            artifact sourceJar {
                classifier "sources"
            }
            artifact javadocJar {
                classifier "javadoc"
            }

            pom.withXml {
                asNode().children().last() + pomConfig
                asNode().appendNode('description', "Ribbon control for Java, created in JavaFX")
            }
        }
    }
}

