<commit_before>plugins {
    java
    maven
    signing
}

group = "gradle"

// tag::conditional-signing[]
version = "1.0-SNAPSHOT"
extra["isReleaseVersion"] = !version.toString().endsWith("SNAPSHOT")

signing {
    setRequired {
        (project.extra["isReleaseVersion"] as Boolean) && gradle.taskGraph.hasTask("uploadArchives")
    }
    sign(configurations.archives.get())
}
// end::conditional-signing[]

// Alternative to signing.required
// tag::only-if[]
tasks.withType<Sign> {
    onlyIf { project.extra["isReleaseVersion"] as Boolean }
}
// end::only-if[]

tasks.getByName<Upload>("uploadArchives") {
    repositories {
        withConvention(MavenRepositoryHandlerConvention::class) {
            mavenDeployer {
                withGroovyBuilder {
                    "repository"("url" to uri("$buildDir/repo"))
                }
                if (project.extra["isReleaseVersion"] as Boolean) {
                    beforeDeployment { signing.signPom(this) }
                }
            }<commit_msg>Refine samples/signing/conditional for uniformity<commit_after>plugins {
    java
    maven
    signing
}

group = "gradle"

// tag::conditional-signing[]
version = "1.0-SNAPSHOT"
extra["isReleaseVersion"] = !version.toString().endsWith("SNAPSHOT")

signing {
    setRequired({
        (project.extra["isReleaseVersion"] as Boolean) && gradle.taskGraph.hasTask("uploadArchives")
    })
    sign(configurations.archives.get())
}
// end::conditional-signing[]

// Alternative to signing.required
// tag::only-if[]
tasks.withType<Sign> {
    onlyIf { project.extra["isReleaseVersion"] as Boolean }
}
// end::only-if[]

tasks.getByName<Upload>("uploadArchives") {
    repositories {
        withConvention(MavenRepositoryHandlerConvention::class) {
            mavenDeployer {
                withGroovyBuilder {
                    "repository"("url" to uri("$buildDir/repo"))
                }
                if (project.extra["isReleaseVersion"] as Boolean) {
                    beforeDeployment { signing.signPom(this) }
                }
            }
{'fraction_non_alphanumeric': 0.1361661033317238, 'fraction_numerical': 0.001931434089811685, 'mean_word_length': 2.628721541155867, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1892353', 'n_tokens_mistral': 628, 'n_tokens_neox': 604, 'n_words': 89}