Triple-T / gradle-play-publisher

GPP is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.
MIT License
4.1k stars 339 forks source link

Impossible to set ResolutionStrategy from external Gradle script #1053

Closed malloth closed 2 years ago

malloth commented 2 years ago

Describe the bug

We don't want to pollute our app's build.gradle with third party configs. Therefore we use external Gradle scripts which do all the third party plugin configuration. Because you are using classes instead of using simple strings, we are unable to set properties like resolutionStrategy. Please use strings instead of classes to support external Gradle files.

How To Reproduce

  1. Create a $rootDir/gradle/playstore.gradle script with the code below:
buildscript {
    repositories {
        google()
        gradlePluginPortal()
    }

    dependencies {
        classpath "com.android.tools.build:gradle:7.2.1"
        classpath "com.github.triplet.gradle:play-publisher:3.7.0"
    }
}

apply plugin: 'com.github.triplet.play'

play {
    serviceAccountCredentials = file("${rootProject.rootDir}/keystores/play-store-key.json")
    resolutionStrategy = com.github.triplet.gradle.androidpublisher.ResolutionStrategy.AUTO
    defaultToAppBundles = true
}
  1. Use this script in the app's build.gradle like below:
apply from: "$rootDir/gradle/playstore.gradle"
  1. Compiler is throwing such exception:

Caused by: java.lang.IllegalArgumentException: Cannot set the value of extension 'play' property 'resolutionStrategy' of type com.github.triplet.gradle.androidpublisher.ResolutionStrategy using an instance of type com.github.triplet.gradle.androidpublisher.ResolutionStrategy.

Versions

Tasks executed

N/A

Expected behavior

Users of this plugin should be able to set all properties - even if those are set in the external Gradle scripts.

Additional context (if a crash, provide stack trace)

N/A

SUPERCILEX commented 2 years ago

Does writing "auto" not work?

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

malloth commented 2 years ago

The problem is that imports don't work in external Gradle scripts. That's why I recommend to switch to use strings instead of classes.

SUPERCILEX commented 2 years ago

These used to be untyped, so I'm not going to go back. I would raise this issue with the Gradle folks since this is fundamentally an issue with bad external script support.

himamis commented 1 year ago

@malloth Did you find any workaround for this?