plugins {
    id 'base'
}

ext {
    guavaVersion = '33.5.0-jre'
    gsonVersion = '2.13.2'
    grpcVersion = '1.76.0'
    junitVersion = '5.14.1'
    picocliVersion = '4.7.7'
    protobufVersion = '4.33.1'
}

subprojects {
    group = 'com.zb.mom.ww.mxgateway'
    version = '0.1.1'

    pluginManager.withPlugin('java') {
        java {
            toolchain {
                languageVersion = JavaLanguageVersion.of(21)
            }
        }

        tasks.withType(JavaCompile).configureEach {
            options.encoding = 'UTF-8'
            options.release = 21
        }

        tasks.withType(Test).configureEach {
            useJUnitPlatform()
        }

        dependencies {
            testImplementation platform("org.junit:junit-bom:${junitVersion}")
            testImplementation 'org.junit.jupiter:junit-jupiter'
            testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
        }
    }

    pluginManager.withPlugin('maven-publish') {
        publishing {
            publications {
                maven(MavenPublication) {
                    from components.java
                    pom {
                        url = 'https://gitea.dohertylan.com/dohertj2/mxaccessgw'
                        description = 'MxAccessGateway Java client'
                        scm {
                            url = 'https://gitea.dohertylan.com/dohertj2/mxaccessgw'
                            connection = 'scm:git:https://gitea.dohertylan.com/dohertj2/mxaccessgw.git'
                        }
                        developers {
                            developer {
                                id = 'dohertj2'
                                name = 'Joseph Doherty'
                            }
                        }
                        licenses {
                            license {
                                name = 'Proprietary'
                                distribution = 'repo'
                            }
                        }
                    }
                }
            }
            repositories {
                maven {
                    name = 'GiteaPackages'
                    url = 'https://gitea.dohertylan.com/api/packages/dohertj2/maven'
                    credentials {
                        username = System.getenv('GITEA_USERNAME') ?: ''
                        password = System.getenv('GITEA_TOKEN') ?: ''
                    }
                }
            }
        }
    }
}
