"Fossies" - the Fresh Open Source Software Archive

Member "navit-0.5.6/gradle/scripts/git-scm-version.gradle" (6 Mar 2021, 894 Bytes) of package /linux/privat/navit-0.5.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Java source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "git-scm-version.gradle": 0.5.5_vs_0.5.6.

    1 //THX to https://proandroiddev.com/configuring-android-project-version-name-code-b168952f3323
    2 
    3 buildscript {
    4     repositories {
    5         jcenter()
    6     }
    7     dependencies {
    8         classpath 'org.ajoberstar:grgit:2.3.0'
    9     }
   10 }
   11 
   12 import org.ajoberstar.grgit.Grgit
   13 import java.time.format.DateTimeFormatter
   14 
   15 ext {
   16     git = Grgit.open(currentDir: projectDir)
   17     gitVersionName = git.describe(match: ["v[0-9.rc]*"])
   18     hh = Integer.parseInt(DateTimeFormatter.ofPattern("HH").format(git.head().dateTime))
   19     mm = Integer.parseInt(DateTimeFormatter.ofPattern("mm").format(git.head().dateTime))
   20     hhmm = Math.round((hh*4)+(mm/15)).toString()
   21     yyyyMMdd = DateTimeFormatter.ofPattern("yyyyMMdd").format(git.head().dateTime)
   22     gitVersionCode = Integer.parseInt(yyyyMMdd + hhmm)
   23 }
   24 
   25 task printVersion() {
   26     println("Version Name: $gitVersionName")
   27     println("Version Code: $gitVersionCode")
   28 }