plugins {
    id 'java'
    id 'application'
    id 'jacoco'
}

version = '1.8.3'

repositories { 
    mavenCentral() 
}

targetCompatibility = "1.8"
sourceCompatibility = "1.8"

afterEvaluate {
    if(project.hasProperty("hprof")) {
        applicationDefaultJvmArgs = ["-Xrunhprof:cpu=times,depth=10", "-Xmx768m"]
    } else {
        applicationDefaultJvmArgs = ["-Xms768m", "-Xmx8g"]
    }
}

dependencies {
    compile 'commons-cli:commons-cli:1.2' 
    compile 'org.apache.commons:commons-math3:3.6.1'
    compile 'com.edropple.jregex:jregex:1.2_01'
    compile('com.github.samtools:htsjdk:2.21.1') {
        transitive = false
    }
    testCompile 'org.mockito:mockito-core:2.23.0'
    testCompile 'org.testng:testng:6.9.13.6'
}

mainClassName = "com.astrazeneca.vardict.Main"

startScripts {
    doLast {
        unixScript.text = unixScript.text.replaceAll(/(DEFAULT_JVM_OPTS=.*)/){ all, group -> 
"""${group}

if [ -n "\$${optsEnvironmentVar}" ] || [ -n "\$JAVA_OPTS" ] ; then
    DEFAULT_JVM_OPTS=''
fi
"""
        }
    }
}

javadoc {
    options.noQualifiers 'java.lang:java.io:java.util'
    options.memberLevel=JavadocMemberLevel.PACKAGE
    exclude '**/ConcurrentHashSet*'
    exclude '**/Utils*'
    exclude '**/Tuple*'
    exclude '**/Main*'
}


test {
    // enable TestNG support (default is JUnit)
    useTestNG()
}

jar {
    manifest {
        attributes 'Main-Class': 'com.astrazeneca.vardict.Main'
    }
    from {
        configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
    }
}

jacoco {
    toolVersion = "0.8.2"
}
applicationDistribution.from('VarDict/teststrandbias.R','VarDict/testsomatic.R','VarDict/var2vcf_valid.pl','VarDict/var2vcf_paired.pl').into('bin')
