Skip to content

Instantly share code, notes, and snippets.

@dyrkow
Last active October 13, 2020 07:39
Show Gist options
  • Save dyrkow/9b993d794ab01321e0b0bbded9f81b59 to your computer and use it in GitHub Desktop.
Save dyrkow/9b993d794ab01321e0b0bbded9f81b59 to your computer and use it in GitHub Desktop.
// Add deps in top
import groovy.json.JsonSlurper
// Add this function to your android/app/build.gradle
def getFromPackage(field) {
def inputFile = new File("$rootDir/../package.json")
def packageJson = new JsonSlurper().parseText(inputFile.text)
return packageJson[field]
}
// Use function for getting version
defaultConfig {
...
versionCode getFromPackage("version")
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment