apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'

group = 'gradle'

version = '1.0-SNAPSHOT'
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")

signing {
    required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
    sign configurations.archives
}

// Alternative to signing.required
tasks.withType(Sign) {
    onlyIf { isReleaseVersion }
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: uri("${buildDir}/repo"))
            if (isReleaseVersion) {
                beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
            }
        }
    }
}
