import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.0"
    }
}

plugins {
    id("org.jetbrains.kotlin.jvm") version "2.1.0"
}

dependencies {
    implementation 'net.portswigger.burp.extender:burp-extender-api:2.3'
    implementation 'net.portswigger.burp.extensions:montoya-api:2023.5'
    implementation 'com.google.code.gson:gson:2.10.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
    implementation 'org.apache.commons:commons-text:1.11.0'
    implementation 'commons-codec:commons-codec:1.16.1'
    implementation 'io.ktor:ktor-server-core:3.1.1'
    implementation 'io.ktor:ktor-server-netty:3.1.1'
    implementation 'com.formdev:flatlaf:3.4'
    implementation 'com.formdev:flatlaf-extras:3.4'
    implementation 'com.graphql-java:graphql-java:21.5'
}

java {
    sourceCompatibility = 17
    targetCompatibility = 17
}

tasks.withType(KotlinCompile).configureEach {
    compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
}

compileKotlin {
    compilerOptions {
        // Configure the Kotlin compiler options
        allWarningsAsErrors = true
    }
}

repositories {
    mavenCentral()
}

sourceSets {
    main {
        java {
            srcDir 'kotlin'
        }
        resources {
            srcDirs = ['resources']
        }
    }
}

build {
    dependsOn(clean, processResources)
}

defaultTasks "build"

// build standalone jar with bundled dependencies
jar {
    manifest {
        attributes('Class-Path': configurations.compileClasspath.collect { it.getName() }.join(' '))
    }
    from { configurations.compileClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
    destinationDirectory = rootDir
    duplicatesStrategy = DuplicatesStrategy.INCLUDE
    archiveFileName = "InQL.jar"
}
