/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java Library project to get you started.
 * For more details take a look at the Java Libraries chapter in the Gradle
 * user guide available at https://docs.gradle.org/4.10.2/userguide/java_library_plugin.html
 */

plugins {
    // Apply the java-library plugin to add support for Java Library
    id 'java-library'
    id 'maven-publish'
    id 'jacoco'
    id "com.palantir.git-version" version "0.12.0-rc2"
    id 'signing'
}

group = 'io.alkal'
version = '0.0.4'

dependencies {
    // This dependency is exported to consumers, that is to say found on their compile classpath.
    api 'org.apache.commons:commons-math3:3.6.1'

    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation 'com.google.guava:guava:28.1-jre'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'
    testImplementation 'org.mockito:mockito-core:2.23.4'
}

task sourcesJar(type: Jar) {
    from sourceSets.main.allJava
    classifier = 'sources'
}

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

publishing {
    publications {
        maven(MavenPublication) {
            from components.java
            artifact sourcesJar
            artifact javadocJar
            pom {
                name = 'Kalium'
                description = 'A reactive framework for micro-services. current commit_id=' + gitVersion()
                version = '0.0.4'
                url = 'https://kalium.alkal.io'

                licenses {
                    license {
                        name = 'The Apache License, Version 2.0'
                        url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id = 'zivzs'
                        name = 'Ziv Salzman'
                        email = 'whoisziv@gmail.com'
                    }
                }
                scm {
                    connection = 'scm:git:git://github.com/alkal-io/kalium.git'
                    developerConnection = 'scm:git:ssh://github.com/alkal-io/kalium.git'
                    url = 'http://github.com/alkal-io/kalium.git'
                }
            }
        }
    }

    repositories {
        maven {
            def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
            def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots"
            url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
            // url = snapshotsRepoUrl
            credentials {
                username = project.properties['sonatype.user']
                password = project.properties['sonatype.password']
            }
        }
    }
}

signing {
    sign publishing.publications.maven
}


javadoc {
    if (JavaVersion.current().isJava9Compatible()) {
        options.addBooleanOption('html5', true)
    }
}

// In this section you declare where to find the dependencies of your project
repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
    mavenLocal()
}

jacocoTestReport {
    reports {
        xml.enabled true
        xml.destination file("${buildDir}/reports/jacoco/report.xml")
        html.enabled false
    }
}

jacocoTestReport.dependsOn(test)
