[GRADLE-3281] Plugin publishing plugin ignores publishing keys set in ~/.gradle/gradle.properties when there's a project-local gradle.properties Created: 14/Apr/15  Updated: 14/Jan/16  Resolved: 14/Jan/16

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Tom Dunstan Assignee: Adrian Kelly (Inactive)
Resolution: Fixed Votes: 6


From the forums:

The documentation on the plugin portal states that gradle.publish.key and gradle.publish.secret should be configured in ~/.gradle/gradle.properties. However, it doesn't appear to work:

Execution failed for task ':publishPlugins'.
> Missing publishing keys. Please set gradle.publish.key and gradle.publish.secret system properties or login using the login task.

I've verified that the properties are configured correctly by outputting them from the build script:

println project.getProperty('gradle.publish.key')
println project.getProperty('gradle.publish.secret')

Strangely, if I remove my project's gradle.properties file, it works as expected and uses the properties configured in ~/.gradle/gradle.properties.

Comment by Tom Dunstan [ 14/Apr/15 ]

Forum post: https://discuss.gradle.org/t/plugin-publish-plugin-ignores-gradle-gradle-properties-if-the-project-has-a-gradle-properties-file/9059

Comment by Holger Stolzenberg [ 21/Apr/15 ]

Can confirm this. This is especially annoying within a multi module project.

Comment by Ned Twigg [ 25/Aug/15 ]

This is killing me. I can't upload from CI without putting my API keys in my project's local gradle.properties (clearly not a good idea for an open source plugin).

Comment by Holger Stolzenberg [ 26/Aug/15 ]

@Ned Twigg You can work around this by setting these properties to the command line definition that runs on your CI, so you do not have check it in with `gradle.properties`.

$> ./gradlew publishPlugins -Dgradle.publish.key=foo -Dgradle.publish.secret=bar

or under certain circumstances you may need to use -P instead of -D

Comment by Ned Twigg [ 26/Aug/15 ]

@Holger Stolzenberg Thanks very much! This fixed it.

Comment by Julien HENRY [ 04/Nov/15 ]

Same problem here when trying to use both release plugin and publishing plugin:

Comment by Vyacheslav Rusakov [ 04/Dec/15 ]

Another workaround is to set system properties inside build.gradle:

System.setProperty('gradle.publish.key', project.properties['gradle.publish.key'] ?: '')
System.setProperty('gradle.publish.secret', project.properties['gradle.publish.secret'] ?: '')

With this, publishPlugins could be called without parameters

Comment by Adrian Kelly (Inactive) [ 14/Jan/16 ]

This has been fixed in version 0.9.3 of the plugin

Generated at Wed Jun 30 12:44:43 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.