group 'tw.geothings.rekotlin'
version '0.1.0-SNAPSHOT'

buildscript {
    ext.kotlin_version = '1.1.3-2'
    ext.dokka_version = '0.9.15'
    ext.junitPlugin_version = '1.0.0'
    ext.junit_jupiter_version = '5.0.0-M6'
    ext.junit_platform_launcher= "1.0.0-M6"

    repositories {
        mavenCentral()
        jcenter()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:${dokka_version}"
        classpath "org.junit.platform:junit-platform-gradle-plugin:${junitPlugin_version}"
    }


}

apply plugin: 'kotlin'
apply plugin: 'maven-publish'
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'org.junit.platform.gradle.plugin'



repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    testCompile "org.junit.jupiter:junit-jupiter-api:$junit_jupiter_version"
    testRuntime "org.junit.jupiter:junit-jupiter-engine:$junit_jupiter_version"
    testRuntime "org.junit.platform:junit-platform-launcher:$junit_platform_launcher"
}

test {
    testLogging {
        events 'started', 'passed'
    }
}
compileKotlin {
    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7

    kotlinOptions.jvmTarget = "1.6"
}
compileTestKotlin {
    sourceCompatibility = JavaVersion.VERSION_1_7
    targetCompatibility = JavaVersion.VERSION_1_7

    kotlinOptions.jvmTarget = "1.6"
}

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

task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
    outputFormat = 'javadoc'
    outputDirectory = javadoc.destinationDir
    inputs.dir 'src/main/kotlin'
}

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

artifacts {
    archives jar
    archives sourcesJar
    archives javadocJar
}

publishing {
    publications {
        maven(MavenPublication) {
            groupId 'tw.geothings.rekotlin'
            artifactId 'rekotlin'
            from components.java

            artifact(javadocJar){
                classifier = 'javadoc'
            }

            artifact(sourcesJar){
                classifier = 'sources'
            }

            repositories {

                /*
                maven {
                    url 's3://rekotlin/snapshots'
                    credentials(AwsCredentials) {
                        accessKey AWS_ACCESS_KEY   // put this in gradle.properties
                        secretKey AWS_SECRET_KEY   // put this in gradle.properties
                    }
                }*/

                maven {
                    url "file:/${project.projectDir}/artifacts"
                }
            }
        }
    }
}