This message was deleted.
# community-support
s
This message was deleted.
v
Not 100% but I doubt it. What would be the use-case to upload to repo A signed but to repo B unsigned?
s
I basically only have one "real" remote repo, and Maven local. For the latter I want to skip signing. Going forward, I might also skip signing for artifacts published to a private snapshot repository.
v
But what is the problem to sign if you actually can sign? Does it break something if you upload signed?
j
I am skipping signing the artifacts when publishing
-SNAPSHOT
versions and/or when running
publishToMavenLocal
tasks
s
No, but I'd like to 1) limit the sharing of signing secrets in a team, and 2) avoid forcing devs to set up "fake" signing just because they want to publish to Maven local.
v
Ah, ok, now we come to it. 🙂
j
Simplified setup of what I have:
Copy code
configure<SigningExtension> {
    val hasPublishToMavenLocalTasks: Boolean =
        allTasks.any { task ->
            task == "publishToMavenLocal" ||
                task == "publishToMavenLocalTest" ||
                task == "publishToMavenLocalBuildTest" ||
                task == "publishAllPublicationsToMavenLocalTestRepository" ||
                task == "publishAllPublicationsToMavenLocalBuildTestRepository"
        }
    isRequired = hasPublishToMavenLocalTasks
}
v
How about setting "signing required" only if some project property is set, so you can set it to true where you need to sign, e. g. CI that publishes. In all other cases it will then skip signing if no signatory is configured and do the signing if it is present anyway.
j
I really miss a lot
isRequired
is not accepting a
Provider
Yep, indeed the whole approach I have, it is doing that at the end, where
shouldSign
is a Gradle project property
Copy code
isRequired = (hasTaskCondition && hasSemverCondition) || shouldSign.get()
s
In my case, I'll try
Copy code
setRequired({
        val mavenPublishingTasks = tasks.withType<PublishToMavenRepository>()
        mavenPublishingTasks.any { gradle.taskGraph.hasTask(it) }
    })
j
But that would avoid signing in all cases, right?
s
I don't think so... publishing to Maven local uses a different task type if I'm not mistaken.
v
This is what I have:
Copy code
signing {
    setRequired {
        // signing is required if this is a release version and the artifacts are to be published
        // do not use hasTask() as this require realization of the tasks that maybe are not necessary
        releaseVersion && gradle.taskGraph.allTasks.any { it is PublishToMavenRepository }
    }
    sign(publishing.publications)
}
s
Yes, that's nicer, thanks!
j
@Vampire
setRequired
is lazy?
s
It's lazy if you pass a lambda to it 🙂
v
Chances are it becomes a proper
Property
in Gradle 9 though: https://github.com/orgs/gradle/projects/31/views/1?pane=issue&amp;itemId=5719703
thank you 1