plugins {
    id 'org.jetbrains.kotlin.jvm'
    id 'com.jfrog.bintray'
    id 'maven-publish'
}

apply plugin: 'kotlin'
apply plugin: 'com.jfrog.bintray'

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib"
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
    testImplementation "io.kotlintest:kotlintest-runner-junit5:$kotlinTest"
}

test {
    useJUnitPlatform()
}

bintray {
    user = System.getenv('BINTRAY_USER')
    key = System.getenv('BINTRAY_KEY')
    configurations = ['archives']
    publish = true
    publications = ['maven']
    override = true
    pkg {
        repo = 'validata'
        name = 'validata-core'
        userOrg = 'njanma'
        licenses = ['Apache-2.0']
        vcsUrl = 'https://github.com/njanma/validata'
        version {
            name = project.version
            desc = "Validata Version ${project.version}"
            released = new Date()
            vcsTag = project.version
        }
    }
}


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

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

artifacts {
    archives sourcesJar
    archives javadocJar
}

publishing {
    publications {
        maven(MavenPublication) {
            groupId 'io.validata'
            artifactId 'validata-core'
            version project.version
            from components.java
        }
    }
}