I followed instructions similar to these:
Android Library Gradle release JAR
However, I get the following error:
Could not find method isReleaseBuild() for arguments [] on project ':myProject'.
None of the examples I saw on Maven integration define this function, so I assumed it was built-in. However, I get this error with Gradle 1.12 and 2.1, and Android plugin 0.12.+ and 0.13.+
If it's not a built-in function, what is the best practice for defining it?
No. It is user defined, but seems to permeate examples because a lot of Gradle examples are copied.
This is the way I ended up defining it, so that I could pass in -PMAVEN_RELEASE_BUILD
on the command line to turn on release builds.
def isReleaseBuild() {
return hasProperty("MAVEN_RELEASE_BUILD") && MAVEN_RELEASE_BUILD == "true";
}
Some people also like to define as version names ending in -SNAPSHOT
. I do not prefer to do this, because I want to be able to choose whether to build a release or debug build without checking in a change to gradle.properties.
def isReleaseBuild() {
return !VERSION_NAME.contains("SNAPSHOT");
}