Signing and Required fail

So, this is on the same topic as

For https://github.com/STIXProject/java-stix

My expectation is if the signing flag is false and signing cannot be done then signing will be skipped, but this isn’t happening for me using Gradle 2.4, and 2.3 when I do the following:

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

I need others to be able to build when they don’t have the properties set necessary to deploy a release or a snapshot. So, if hide my ~/.gradle/gradle.properties file, and use gradlew to execute the default task, “build”, this happens:

➜ java_stix git:(v1.1.1) ✗ ./gradlew uploadArchives
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test UP-TO-DATE
:buildSrc:check UP-TO-DATE
:buildSrc:build UP-TO-DATE
:clean
:retrieveSchemas
:createPrefixNamespaceBindings
:generateJAXB
:generatedSourceTransformation
:createPackageInfo
:compileJava
:compileGroovy UP-TO-DATE
:processResources
:classes
:jar
:javadoc
:javadocJar
:sourcesJar
:signArchives FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not evaluate onlyIf predicate for task ‘:signArchives’.

Neither path nor baseDir may be null or empty string. path=’’ basedir=’/Users/walsh/Development/workspace/java_stix’

To get around this I have to skip signArchives like so

./gradlew -x signArchives

So, a) I’m doing something wrong in my build script or b) something else is borked.

Thoughts? Am I doing this right?

-Michael

Crickets. Chirp. Chirp.

You might want to verify that the required closure evaluates to the expected value. A println would probably be sufficient.

signing { 
    required {
        boolean signed = has("release") && gradle.taskGraph.hasTask(tasks.uploadArchives) 
        println signed
        signed
    }
}

It does, and gives

FAILURE: Build failed with an exception.

What went wrong:
Could not evaluate onlyIf predicate for task ‘:signArchives’.
Neither path nor baseDir may be null or empty string. path=’’ basedir=’/Users/walsh/Development/workspace/java_stix’

Please note: it’s setRequired {} in Kotlin DSL instead of required {}.