plugins {
    id "org.jetbrains.kotlin.jvm" version "1.9.10"
    id "org.jetbrains.kotlin.plugin.serialization" version "1.9.10"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0"
    implementation "org.kohsuke:github-api:1.135"
    implementation "org.dom4j:dom4j:2.1.3"
}

task run(type: JavaExec, dependsOn: jar) {
    mainClass = "dev.architectury.templates.GenerateTemplatesKt"
    environment "CONFIG_PATH", file("generator.config.json").absolutePath
    environment "OUTPUT_PATH", file("build/templates").absolutePath
    environment "BODY_PATH", file("body.md").absolutePath
    environment "PUBLISH", "true"
    environment "GITHUB_TOKEN", System.getenv("GITHUB_TOKEN")
    environment "GITHUB_REPOSITORY", System.getenv("GITHUB_REPOSITORY")
    classpath configurations.runtimeClasspath.files + jar.archiveFile
}

task runLocal(type: JavaExec, dependsOn: jar) {
    mainClass = "dev.architectury.templates.GenerateTemplatesKt"
    environment "CONFIG_PATH", file("generator.config.json").absolutePath
    environment "OUTPUT_PATH", file("build/templates").absolutePath
    environment "PUBLISH", "false"
    classpath configurations.runtimeClasspath.files + jar.archiveFile
}
