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.13k stars 341 forks source link

What's the migration guide for 3.0.0-SNAPSHOT to post processing? #851

Closed b95505017 closed 4 years ago

b95505017 commented 4 years ago

https://github.com/Triple-T/gradle-play-publisher#post-processing-outputs-sanitized-by-auto-resolution

I want to do the same effect in 3.0.0-SNAPSHOT but outputProcessor is gone in 3.0.0-SNAPSHOT, I only saw onVariantProperties but need more cleared guide.

SUPERCILEX commented 4 years ago

Do you have anything specific in mind? Here's a clearer version of that test:

android {
  onVariantProperties {
    for (output in outputs) {
      val processedVersionCode = output.versionCode.map { playVersionCode ->
        // Version names will look like `semantic.release.name.123`
        "semantic.release.name.$playVersionCode"
      }
      output.versionName.set(processedVersionCode)
    }
  }
}
SUPERCILEX commented 4 years ago

Closing in favor of #853

b95505017 commented 4 years ago

@SUPERCILEX I found that it hard to replace some part of current versionName config (based on other config such as versionNameSuffix). Use output.versionName.zip(output.versionCode) seems not working.

Previously I could use versionNameOverride.replace(...). How do I achieve this?

SUPERCILEX commented 4 years ago

Does using output.versionName.get().replace(...) not work?

b95505017 commented 4 years ago

No, I tried get() or map { } both get StackOverflowError

SUPERCILEX commented 4 years ago

Ah, you're doing it inside the versionCode.map... You have to get the value before-hand or it will evaluate to versionName.set which is where you're trying to use it, so then it goes back in there, calls get and yada yada yay recursion. :) Basically just move it outside the map and it should work hopefully:

  for (output in outputs) {
      val initialVersionName = output.versionName.get()
      val processedVersionCode = output.versionCode.map { playVersionCode ->
        initialVersionName...
      }
      output.versionName.set(processedVersionCode)
    }
SUPERCILEX commented 4 years ago

Note that that's also wrong long-term, but I haven't figured out the solution yet: #858