Closed Burtan closed 7 years ago
At the moment I have two flavours of one service. One flavour is the sandbox, the other one is the production environment. I have one class with constants which I comment out depending on which flavour I want to publish. The constants contain API information like URL and client IDs.
A good point to start with would be defined properties similar to BuildConfig with Android. I think some of the sample projects using Maven use properties, but I didn't find a way to do so with gradle.
This seems like something that can be solved by gradle and isn't appengine specific. Android has defined a convention for doing that for Android projects and within the IDE, but it doesn't make sense for us to provide such a strong suggestion to app engine developers.
A way to mimic that behavior would be to do it on your own. Perhaps by controlling the sourceset includes?
Something like (I don't know if this will actually work, but you could play around with it, there are probably other ways to do this too) :
sourceSets {
main {
java {
if ( /*some condition for debug*/ ) {
srcDirs "src/variants/debug/java"
}
else if ( /*some condition for prod*/) {
srcDirs "src/variants/prod/java"
}
}
}
}
And here some condition
can be checking a system or gradle property or something like that.
./gradlew assemble -Pvariant=debug
It's really up to you.
Thanks, I'll look into it.
Can you be more specific, what exactly are you trying to customize?