plugins {
    id 'java'
}

group = 'com.annimon'
version = versions.project

dependencies {
    implementation project(":ownlang-core")
    implementation project(":ownlang-parser")
    implementation project(":ownlang-utils")
    implementation project(":modules:main")
    implementation project(":modules:canvasfx")
    implementation project(":modules:server")

    implementation "org.yaml:snakeyaml:${versions.snakeyaml}"
}

tasks.register('generateMarkdownModules') {
    group = "documentation"
    def ownlangExec = tasks.getByPath(':ownlang-desktop:ownlangExec')
    doFirst {
        ownlangExec.configure {
            workingDir '../docs/src'
            args '-f', 'docgen-md.own'
        }
    }
    finalizedBy ownlangExec
}

tasks.register('runDocsDev', Exec) {
    group = "documentation"
    description = "Start docs dev server"
    dependsOn generateMarkdownModules
    workingDir '../docs/docs'
    commandLine 'pnpm', 'docs:dev'
}

tasks.register('buildDocs', Exec) {
    group = "documentation"
    description = "Build docs to static site"
    dependsOn generateMarkdownModules
    workingDir '../docs/docs'
    commandLine 'pnpm', 'docs:build'
}

tasks.register('generateModuleInfo', JavaExec) {
    group = "documentation"
    description = "Run sample program"
    dependsOn classes
    mainClass = 'com.annimon.ownlang.docs.ModulesInfoCreator'
    classpath = sourceSets.main.runtimeClasspath
    args 'server', 'okhttp'
}