📳
IT351G - Web Development - Programming of Mobile A
  • Course introduction
  • Links
    • Course plan
    • TimeEdit
    • Discord
    • YouTube
  • Guides
    • LenaSYS
    • Assignments (sv. duggor)
    • Buffer time (sv. respittid)
    • Add git hash to APK file name
  • Tools & Services
    • Git
      • Logical view
    • Github
      • Create a Github account
      • Fork a Github project
      • ...
    • Android Studio
      • Intellij
      • Gradle
      • Maven
      • Android SDK
    • Assignment: Tools & Services
  • WebView
    • WebView
      • WebView bindings
    • Assignment: WebView
  • User Interface: Widgets
    • Views
    • Layouts
    • RecyclerView
    • Assignment: Widgets
  • User Interface: Screens
    • Activities
      • Intents
    • Fragments
    • Object-orientation
    • Assignment: Screens
  • Networking
    • JSON data
    • HTTP networking
    • Assignment: Networking
  • Project
    • Project introduction
    • Assignment: Project repository
  • Persistence
    • Shared preferences
    • SQLite
    • Assignment: Persistence
  • External libraries
    • External libraries
    • Assignment: External libraries
Powered by GitBook
On this page

Was this helpful?

  1. Guides

Add git hash to APK file name

To match the APK files uploaded as part of the assignments with a given snapshot (commit) of the git repository we require the APK file name to include the git commit hash of the latest commit. To add the git commit hash to the APK file name add a applicationVariants.all block in the android block in app\build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    ...

    applicationVariants.all { variant ->
        variant.outputs.all {
            outputFileName = "${rootProject.name}-${variant.name}-" + {
                def stdout = new ByteArrayOutputStream()
                exec {
                    commandLine 'git', 'describe', '--match=', '--always', '--dirty'
                    standardOutput = stdout
                }
                stdout.toString().trim()
            }() + ".apk"
        }
    }
}

dependencies {
    ...
}
PreviousBuffer time (sv. respittid)NextGit

Last updated 5 years ago

Was this helpful?