/*
 * This build file was auto generated by running the Gradle 'init' task
 * by 'jabed' at '11/14/15 7:37 PM' with Gradle 2.8
 *
 */

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'

mainClassName = 'hello.HelloWorld'

repositories {
    mavenCentral()
}

jar {
    baseName = 'jb-hello-world'
    version =  '0.1.0'
}

/* 1.8 means Java 8 or above */
sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile "joda-time:joda-time:2.2"
    testCompile('org.junit.jupiter:junit-jupiter-api:5.3.1')
    testCompile('org.junit.jupiter:junit-jupiter-params:5.3.1')
    testRuntime('org.junit.jupiter:junit-jupiter-engine:5.3.1')   
// The following is a work around to fix the warning:
// warning: unknown enum constant Status.STABLE
    testCompile "org.apiguardian:apiguardian-api:1.0.0"
}

// ****** Comment this out on the remote repository so that Travis CI will build ****** 

test {
    useJUnitPlatform()
    testLogging {
        events "passed", "skipped", "failed"
    }
}

task dist {
    description "Generate the dist(s) into the dist folder need to fix this."
}

task distSetup {
    description "Generate the dist folder."
    delete "${projectDir}/dist"
    copy {
        from "${buildDir}/build/distributions"
        into "${projectDir}/dist/executables"
    }
    copy {
        from "${projectDir}/build/reports"
        into "${projectDir}/dist/test_reports"
    }
}

task zipDist(type: Zip, dependsOn: distSetup) {
    from "${projectDir}/dist/executables"
    from "${projectDir}/Readme.md"
    destinationDir = file("${projectDir}/dist")
    version = "${version}"
    appendix = "Main"
    doLast {
        println "Created ${zipDist.archiveName}"
    }
}

task zipTest(type: Zip, dependsOn: distSetup) {
    from "${projectDir}/dist/test_reports"
    from "${projectDir}/Readme.md"
    destinationDir = file("${projectDir}/dist")
    version = "${version}"
    appendix = "Test Output"
    doLast{
        println "Created ${zipTest.archiveName}"
    }
}

distSetup.dependsOn(build)

dist.dependsOn(zipDist)
dist.dependsOn(zipTest)