plugins {
    id "java"
    id "maven-publish"
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
            artifactId = "znpcsplus-api"

            pom {
                name.set("znpcsplus-api")
                description.set("The API for the ZNPCsPlus plugin")
                url.set("https://github.com/Pyrbu/ZNPCsPlus")
            }
        }
    }
    repositories {
        maven {
            Map<String, String> systemProperties = System.getenv()
            credentials {
                if (systemProperties.containsKey("DIST_USERNAME")) username systemProperties.get("DIST_USERNAME")
                if (systemProperties.containsKey("DIST_PASSWORD")) password systemProperties.get("DIST_PASSWORD")
            }
            // If the BUILD_ID enviroment variable is present that means its a Jenkins build & that it should go into the snapshots repo
            url = systemProperties.containsKey("BUILD_ID") ? uri("https://repo.pyr.lol/snapshots/") : uri("https://repo.pyr.lol/releases/")
        }
    }
}