buildscript {
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72"
    }
}

plugins {
    // id "org.jetbrains.kotlin.jvm" version "1.3.72"
    id 'application'
    id 'org.jetbrains.dokka' version "0.9.18"
    id 'com.github.johnrengelman.shadow' version '5.2.0'
    id 'java'
}

apply plugin: "kotlin"
apply plugin: "java"

targetCompatibility = 1.8
sourceCompatibility = 1.8

repositories {
    mavenLocal()
    mavenCentral()
    jcenter()
    maven { url "https://dl.bintray.com/orangy/maven/" }
}

def prog8version = rootProject.file('compiler/res/version.txt').text.trim()

dependencies {
    implementation project(':parser')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    // implementation "org.jetbrains.kotlin:kotlin-reflect"
    implementation 'org.antlr:antlr4-runtime:4.8'
    implementation 'org.jetbrains.kotlinx:kotlinx-cli-jvm:0.1.0-dev-5'
    // implementation 'net.razorvine:ksim65:1.6'
    // implementation "com.github.hypfvieh:dbus-java:3.2.0"
    implementation project(':parser')

    testImplementation "org.jetbrains.kotlin:kotlin-test-junit5"
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2'
    testImplementation 'org.hamcrest:hamcrest-junit:2.0.0.0'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.2'
}

compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
        // verbose = true
        // freeCompilerArgs += "-XXLanguage:+NewInference"
    }
}

compileTestKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

sourceSets {
    main {
        java {
            srcDirs = ["${project.projectDir}/src"]
        }
        resources {
            srcDirs = ["${project.projectDir}/res"]
        }
    }
    test {
        java {
            srcDirs = ["${project.projectDir}/test"]
        }
    }
}

startScripts.enabled = true

application {
    mainClassName = 'prog8.CompilerMainKt'
    applicationName = 'p8compile'
}

artifacts {
    archives shadowJar
}


shadowJar {
    archiveBaseName = 'prog8compiler'
    archiveVersion = prog8version
    // minimize()
}


test {
    // Enable JUnit 5 (Gradle 4.6+).
    useJUnitPlatform()

    // Always run tests, even when nothing changed.
    dependsOn 'cleanTest'

    // Show test results.
    testLogging {
        events "skipped", "failed"
    }
}


dokka {
    outputFormat = 'html'
    outputDirectory = "$buildDir/kdoc"
}
