plugins {
    id 'maven-publish'
    alias catalog.plugins.envelope apply false
    alias catalog.plugins.lombok apply false
}


allprojects {
    apply plugin: 'java-library'
    apply plugin: catalog.plugins.lombok.get().pluginId

    group = "net.woggioni"
    version = getProperty('wson.version')

    java {
        modularity.inferModulePath = true
        toolchain {
            languageVersion = JavaLanguageVersion.of(17)
            vendor = JvmVendorSpec.GRAAL_VM
        }
    }

    lombok {
        version = catalog.versions.lombok.get()
    }

    repositories {
        maven {
            url = "https://woggioni.net/mvn/"
            content {
                includeGroup 'com.beust'
                includeGroup 'com.lys'
                includeGroup 'net.woggioni'
            }
        }
        mavenCentral()
    }

    dependencies {
        implementation catalog.xz

        testImplementation catalog.junit.jupiter.api
        testImplementation catalog.junit.jupiter.params
        testRuntimeOnly catalog.junit.jupiter.engine
    }

    test {
        useJUnitPlatform()
    }

    tasks.named(JavaPlugin.COMPILE_JAVA_TASK_NAME, JavaCompile) {
        options.release = 17
    }

    pluginManager.withPlugin(catalog.plugins.kotlin.jvm.get().pluginId) {
        compileKotlin {
            kotlinOptions.with {
                jvmTarget = '17'
            }
        }
    }
}


dependencies {
    implementation catalog.jwo
    implementation catalog.slf4j.api

    testImplementation project('test-utils')
    testImplementation catalog.jackson.databind
}

java {
    withJavadocJar()
    withSourcesJar()
}

compileJava {
    options.compilerArgs << '-parameters'
}

publishing {
    repositories {
        maven {
            url = "https://mvn.woggioni.net/"
        }
    }
    publications {
        maven(MavenPublication) {
            from(components["java"])
        }
    }
}
