plugins {
    id 'java'
    id 'org.openjfx.javafxplugin' version '0.0.7'
    id 'application'
	id 'org.jetbrains.kotlin.jvm' version '1.4.32'
	id 'org.jetbrains.kotlin.plugin.serialization' version '1.4.32'
}

group 'edu.duke.cs'
version '3.1-BETA'

sourceCompatibility = 16

repositories {
    mavenCentral()
}

def autoValueVersion = 1.7

dependencies {
    implementation 'org.apache.commons:commons-collections4:4.3'
    implementation 'org.apache.commons:commons-math3:3.6.1'
    implementation 'org.apache.commons:commons-lang3:3.9'
    implementation 'colt:colt:1.2.0'
    implementation 'com.joptimizer:joptimizer:3.5.1'
    implementation 'commons-io:commons-io:2.5'
    implementation 'org.mapdb:mapdb:3.0.5'
    implementation 'de.lmu.ifi.dbs.elki:elki:0.7.1'
    implementation 'ch.obermuhlner:big-math:2.3.0'
    implementation 'org.jogamp.jocl:jocl:2.3.2'
    implementation 'org.jogamp.gluegen:gluegen-rt:2.3.2'
    implementation 'com.github.haifengl:smile-core:1.5.1'
    implementation 'com.github.haifengl:smile-netlib:1.5.1'
    implementation 'org.apache.xmlgraphics:batik-svggen:1.9.1'
    implementation 'org.apache.xmlgraphics:batik-svg-dom:1.9.1'
    implementation 'org.ojalgo:ojalgo:41.0.0'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.9'
    implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.9'
    implementation 'com.beust:jcommander:1.72'
    implementation 'org.tomlj:tomlj:1.0.0'
    implementation 'org.joml:joml:1.9.19'
    implementation 'org.tukaani:xz:1.8'
    implementation "ch.qos.logback:logback-classic:1.2.3"
    implementation "org.slf4j:jul-to-slf4j:1.7.30"
    implementation 'org.postgresql:postgresql:42.2.16'
    implementation 'org.sql2o:sql2o:1.6.0'
    implementation "com.hazelcast:hazelcast:4.0"
    implementation "net.java.dev.jna:jna:5.5.0"
    implementation 'com.google.guava:guava:29.0-jre'
    implementation "com.google.auto.value:auto-value-annotations:${autoValueVersion}"
    implementation 'one.util:streamex:0.7.3'
    annotationProcessor "com.google.auto.value:auto-value:${autoValueVersion}"
    implementation platform('software.amazon.awssdk:bom:2.15.48')
    implementation 'software.amazon.awssdk:s3'

	implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
	implementation 'org.jetbrains.kotlin:kotlin-reflect'

    javafx {
        version = "11.0.1"
        modules = ['javafx.controls']
    }

    // JCUDA stuff, see https://github.com/jcuda/jcuda-main/blob/master/USAGE.md#using-jcuda-with-gradle
    implementation('org.jcuda:jcuda:10.2.0') {
            transitive = false
    }

    runtimeOnly 'org.jogamp.gluegen:gluegen-rt:2.3.2:natives-linux-amd64'
    runtimeOnly 'org.jogamp.jocl:jocl:2.3.2:natives-linux-amd64'
    runtimeOnly 'org.jcuda:jcuda-natives:10.2.0:linux-x86_64'

    compileOnly 'org.jetbrains:annotations:17.0.0'

    implementation fileTree(dir: 'lib', include: ['*.jar'])

    testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: '5.4.2'
    testImplementation 'org.assertj:assertj-core:3.18.1'
	testImplementation "org.hamcrest:hamcrest-all:1.3" 
	testImplementation "junit:junit:4.12" 
	testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.0" 

	// gui
	def ktorVersion = "1.5.4"
	implementation "com.cuchazinteractive:kludge:0.1"
	implementation "io.ktor:ktor-client-cio:${ktorVersion}"
	implementation "io.ktor:ktor-client-serialization-jvm:${ktorVersion}"

	// used by the service
	implementation "io.ktor:ktor-server-netty:${ktorVersion}" 
	implementation "io.ktor:ktor-serialization:${ktorVersion}" 
}

test {
    useJUnitPlatform()
}

application {
    mainClassName = 'edu.duke.cs.osprey.design.Main'
    applicationDefaultJvmArgs = ['--add-modules=jdk.incubator.foreign']
}

tasks.withType(JavaCompile) {
    options.compilerArgs += '--add-modules=jdk.incubator.foreign'
}

compileKotlin {
	kotlinOptions {
		jvmTarget = '1.8'
		freeCompilerArgs += '-Xuse-experimental=kotlin.Experimental'
		freeCompilerArgs += '-XXLanguage:+InlineClasses'

		// use the newer (and less buggier?) compiler backend
		useIR = true
	}
}

task compileGpu(type:Exec) {
    workingDir 'src/main/resources/gpuKernels/cuda'
    commandLine './compile.sh'
}

jar {
   manifest {
       attributes("Main-Class": "edu.duke.cs.osprey.design.Main")
   }
}
