Gradle-play-publisher: Credentials are validated at configuration time.

Created on 21 Feb 2020  路  3Comments  路  Source: Triple-T/gradle-play-publisher

Describe the bug

At the moment credentials are validated at the configuration phase of the project. Problem is that one may not want to have serviceAccountCredentials file accessible to everyone and will therefore not be set every time. For example, you don't want to have the file shared among the development team and just have it accessible on CI. Why is this validation not done when credentials actually need to be used?

How To Reproduce

Don't set play.serviceAccountCredentials property and run ./gradlew tasks. Tasks task has nothing to do with this plugin but it will still fail.

Versions

  • Gradle Play Publisher: 2.6.2
  • Gradle Wrapper: 6.2
  • Android Gradle Plugin: 2.5.3

Expected behavior

The plugin should validate credentials when they are needed and not at configuration time.

Caused by: java.lang.IllegalStateException: No credentials specified. Please read our docs for more details:
https://github.com/Triple-T/gradle-play-publisher#authenticating-gradle-play-publisher
        at com.github.triplet.gradle.play.internal.ValidationKt.validateCreds(Validation.kt:11)
        at com.github.triplet.gradle.play.PlayPublisherPlugin$applyInternal$1.execute(PlayPublisherPlugin.kt:141)
        at com.github.triplet.gradle.play.PlayPublisherPlugin$applyInternal$1.execute(PlayPublisherPlugin.kt:49)
        at org.gradle.internal.ImmutableActionSet$SetWithManyActions.execute(ImmutableActionSet.java:329)
        at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:264)
        at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:253)
        at com.android.build.gradle.AppExtension.addVariant(AppExtension.java:84)
        at com.android.build.gradle.internal.ApiObjectFactory.create(ApiObjectFactory.java:127)
        ... 146 more
bug

Most helpful comment

Resolved it by reading documentation all the way through. 馃槃

All 3 comments

Resolved it by reading documentation all the way through. 馃槃

Resolved it by reading documentation all the way through. 馃槃

On our build server I use an environment variable ANDROID_PUBLISHER_CREDENTIALS, and therefore do not specify serviceAccountCredentials in the gradle file. But in this case all gradle tasks fails when run locally.

Can you be a bit more specific about how you fixed it?

----- EDIT -----
OK, I fixed this by enabling the publisher task using an environment variable only present on the build server.

play { enabled.set(System.getenv("CI") == "true") }

What i did was set

play {
    isEnabled = false
}

and then added also

android {
    playConfigs {
        register("<flavourName>") {
            isEnabled = project.hasProperty("<gradle_properties_key_for_play_credewntials>")
        }
    }
}

and since <gradle_properties_key_for_play_credewntials> is only set on CI, it works as expected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kristiyanP picture kristiyanP  路  4Comments

ivoberger picture ivoberger  路  4Comments

emartynov picture emartynov  路  4Comments

bunjix picture bunjix  路  5Comments

theunreal picture theunreal  路  3Comments