Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different gradle tasks for pushing to different Play Store channels #65

Closed
appplemac opened this issue Apr 28, 2015 · 8 comments
Closed

Comments

@appplemac
Copy link

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!

@bhurling
Copy link
Contributor

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?

@appplemac
Copy link
Author

@bhurling Yep, that works. Thank you so much!

@wesleym
Copy link

wesleym commented Dec 12, 2015

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?

@bhurling
Copy link
Contributor

bhurling commented Jan 5, 2016

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).

@wesleym
Copy link

wesleym commented Jan 5, 2016

That works great. Thanks! It might be worth mentioning that trick in the docs.

@vitorprado
Copy link

Add it to docs PLEASE.

@Byronium
Copy link

Byronium commented May 2, 2018

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.

@golanshy
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants