Hi there, is it possible to make the plugin create more than one gradle task so that a different task is used to push to a different Play Store channel?
E.g. I want to push an APK to different channels from different GitHub branches on my CI server, and the only way to do that I am aware of is to have a different config for gradle-play-publisher in every branch of my project. Is that the only way?
Thanks!
Another solution would be to use a property for the track
play {
// ...
track = "${track}"
}
and then define your CI server to run the publish task with an additional argument:
./gradlew publishApkRelease -Dorg.gradle.project.track=alpha
Jenkins for example does that automatically if you are using parameterized builds along with the gradle build step.
Does that help you?
@bhurling Yep, that works. Thank you so much!
I find when I set track to ${track} that non-publish tasks like assemble now fail if I don't specify org.gradle.project.track.
./gradlew assembleDevDebug
...
* What went wrong:
A problem occurred evaluating root project 'nextdoor'.
> Track has to be one of 'alpha', 'beta', 'rollout' or 'production'.
Is this the expected behaviour? Does this mean that I need to add -Dorg.gradle.project.track=alpha to every invocation of Gradle for this project? Is there a way to specify a default?
If you use properties in your build script you have to provide them externally. But you can set defaults in your gradle.properties:
track=alpha
-Dorg.gradle.project.track overrides the values in the gradle.properties (see here).
That works great. Thanks! It might be worth mentioning that trick in the docs.
Add it to docs PLEASE.
For some reason, using
play {
track = "${track}"
}
always pushed to alpha even if I set the default to internal in gradle.properties and passed in the -Dorg.gradle.project.track=internal parameter...
Changing the syntax to the following
play {
track = project.properties['track']
}
worked for me.
I'm a bit confused about this since "${track}" seems like valid syntax, and if I test it in other places in the build.gradle file, it works as intended. Also, if the syntax isn't working and is thus creating a null or empty string, I thought that Gradle Play Publisher would complain that the specified track isn't in the accepted list and fail instead of defaulting to Alpha, which seems to be what's happening.
Worked for me, as long as you default the track i.e. track = internal in your gradle.properties you can refer to it in your build.gradle as
play {
track = project.properties['track']
}
and then in your CI you can override e.g
./gradlew publishApkRelease -Dorg.gradle.project.track=alpha
Most helpful comment
I find when I set track to
${track}that non-publish tasks like assemble now fail if I don't specify org.gradle.project.track../gradlew assembleDevDebugIs this the expected behaviour? Does this mean that I need to add
-Dorg.gradle.project.track=alphato every invocation of Gradle for this project? Is there a way to specify a default?