evaluationDependsOn(':java')

ext {
    dockerImageName = 'timebase-ce-client'
    dockerImages = [
            main   : 'src/main/docker/Dockerfile',
            java17 : 'src/main/docker/java17/Dockerfile',
    ]
}

description = "Timebase Client API Library"

dependencies {
    api project(':java:timebase:aerondirect')
    api project(':java:timebase:api')
    api project(':java:timebase:pub')
    api project(':java:timebase:s3')

    implementation ('com.epam.deltix:timebase-lang')
    implementation ('com.epam.deltix:timebase-util')
    implementation ('com.epam.deltix:timebase-messages')

    implementation ('com.epam.deltix:containers')
    implementation ('com.epam.deltix:dfp')

    implementation 'com.epam.deltix:thread-affinity'

    implementation 'com.epam.deltix:gflog-api',
            'com.epam.deltix:gflog-jul'

    implementation 'com.google.guava:guava'
    implementation 'com.google.code.gson:gson'
    implementation 'org.hdrhistogram:HdrHistogram'
    implementation 'org.apache.commons:commons-text'

    implementation 'org.apache.commons:commons-lang3'
    implementation 'org.apache.commons:commons-compress'

    // TODO: Replace by JSR305
    compileOnly 'com.intellij:annotations'
    testCompile 'com.intellij:annotations'

    // For JMH-based tests
    testImplementation 'org.openjdk.jmh:jmh-core'
    testImplementation 'org.openjdk.jmh:jmh-generator-annprocess'

    testRuntimeOnly 'com.epam.deltix:gflog-slf4j'
    testImplementation 'com.epam.deltix:gflog-jul'
}

task buildTestJar(type: Jar, dependsOn: testClasses) {

    description 'Generates JAR with test classes'
    classifier 'tests'
    from sourceSets.test.output

    manifest {
        attributes.putAt('Class-Path', configurations.testRuntime.collect {it.getName()}.join(' '))
    }
}

task copyTestJar(type: Copy) {
    println("$project.buildDir\\libs");
    from "$project.buildDir\\libs"
    into "$rootDir/lib"
    include '*tests.jar'
}

task prepareFilesForDocker(type: Copy) {
    group 'docker'
    description 'Copy all timebase client dependencies'
    //dependsOn ':java:cleanSubprojects' // This is necessary to force clean build.
    dependsOn 'build'
    dependsOn ':distribution:build'
    dependsOn ':generateSetQsVersionScript'

    into project.file("$buildDir/docker/timebase")

    into ("bin") {
        from "$rootDir/bin" // TODO: Avoid sharing resources thought global folder. Use explicit task outputs instead.
    }
    into ("lib") {
        // Runtime dependencies
        from configurations.runtimeClasspath
        exclude("tools-*")
        from jar
    }
}
