plugins {
    id 'groovy'
    id 'application'
    id 'com.github.johnrengelman.shadow' version '8.1.1'
    id 'maven-publish'
    id "com.dorongold.task-tree" version "4.0.0"
}

group = 'space.left4dev'
version = '1.0'

repositories {
    mavenLocal()
    mavenCentral()
    gradlePluginPortal()
}

dependencies {
    implementation 'org.apache.groovy:groovy-all:4.0.25'
    implementation 'com.hivemq:hivemq-mqtt-client:1.3.5'
    implementation 'org.slf4j:slf4j-api:2.0.16'
    implementation 'ch.qos.logback:logback-classic:1.5.16'
}

application {
    mainClass = 'space.left4dev.GhostApp'
}

sourceCompatibility = 21
targetCompatibility = 21

shadowJar {
    archiveFileName = "mqtt-ghost-${version}.jar"
    manifest {
        attributes 'Main-Class': 'space.left4dev.GhostApp'
    }
}

publishing {
    repositories {
        maven {
            name 'GitHubPackages'
            url "https://maven.pkg.github.com/epistax1s/mqtt-ghost"
            credentials {
                username = System.getenv("GITHUB_ACTOR")
                password = System.getenv("GITHUB_TOKEN")
            }
        }
    }
    publications {
        create("shadow", MavenPublication) {
            artifact(shadowJar) {
                classifier = ""
            }
            groupId = project.group
            artifactId = "mqtt-ghost"
            version = project.version
            pom {
                name.set("mqtt-ghost")
                description.set("MQTT client ghost tool")
                url.set("https://github.com/epistax1s/mqtt-ghost")
                licenses {
                    license {
                        name.set("MIT License")
                        url.set("https://opensource.org/licenses/MIT")
                    }
                }
                developers {
                    developer {
                        id.set("epistax1s")
                        name.set("epistax1s")
                        email.set("your.email@example.com")
                    }
                }
                scm {
                    connection.set("scm:git:git://github.com/epistax1s/mqtt-ghost.git")
                    developerConnection.set("scm:git:ssh://github.com/epistax1s/mqtt-ghost.git")
                    url.set("https://github.com/epistax1s/mqtt-ghost")
                }
            }
        }
    }
}

tasks.matching { task ->
    task.name in ['distZip', 'distTar', 'startScripts', 'startShadowScripts', 'shadowDistTar', 'shadowDistZip']
}.configureEach {
    enabled = false
}
