apply(plugin: "maven-publish")
apply(plugin: "signing")

java {
    withJavadocJar()
    withSourcesJar()
    toolchain {
        languageVersion = JavaLanguageVersion.of(8)
    }
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java

            groupId = PUBLISH_GROUP_ID
            artifactId = PUBLISH_ARTIFACT_ID
            version = PUBLISH_VERSION

            versionMapping {
                usage('java-api') {
                    fromResolutionOf('runtimeClasspath')
                }
                usage('java-runtime') {
                    fromResolutionResult()
                }
            }

            pom {
                name = PUBLISH_ARTIFACT_ID
                description = POM_DESCRIPTION
                url = POM_URL

                licenses {
                    license {
                        name = POM_LICENSE_NAME
                        url = POM_LICENSE_URL
                    }
                }

                developers {
                    developer {
                        id = POM_DEVELOPER_ID
                        name = POM_DEVELOPER_NAME
                        email = POM_DEVELOPER_EMAIL
                    }
                }

                scm {
                    connection = GITHUB_SCM_CONNECTION
                    url = POM_SCM_URL
                }
            }
        }
    }
}

ext["signing.keyId"] = rootProject.ext["signing.keyId"]
ext["signing.password"] = rootProject.ext["signing.password"]
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]

signing {
    sign publishing.publications
}