plugins {
    id "java"
    id "maven"
    id "java-library-distribution"
    id "org.sonarqube" version "2.7.1"
    id "me.champeau.gradle.jmh" version "0.5.0-rc-1"
}
group = 'com.epam.cme'
version = '2.1.4'
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}

jar {
    baseName 'b2bits-jmdp3'
}

configurations {
    cucumberRuntime {
        extendsFrom testImplementation
    }
}

dependencies {
    compile project(':core')
    compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.5'
    compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.5'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
    runtime group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.5'
    compile group: 'net.openhft', name: 'koloboke-api-jdk8', version: '0.6.8'
    runtime group: 'net.openhft', name: 'koloboke-impl-jdk8', version: '0.6.8'
    compile group: 'net.openhft', name: 'chronicle-core', version: '1.7.6'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    testCompile group: 'uk.co.real-logic', name: 'sbe-tool', version: '1.6.0'
    testImplementation 'io.cucumber:cucumber-java:4.3.1'
}

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


task cucumber() {
    dependsOn assemble, compileTestJava
    doLast {
        javaexec {
            main = "cucumber.api.cli.Main"
            classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
            args = ['--plugin', 'pretty', '--glue', 'gradle.cucumber', 'src/cucumber/resources']
        }
    }
}

artifacts {
    archives sourcesJar    
}

task copyToLib(type: Copy) {
    into "$buildDir/libs/lib"
    from configurations.runtime
}
build.dependsOn(copyToLib)

distributions {
    main {
        baseName = 'b2bits-jmdp3'
        contents {
            from { '../dist' }
        }
    }
}
