@@ -38,16 +38,14 @@ val apiHosts = mapOf(
3838)
3939
4040// app
41- const val globalVersionName = " 1.0"
42- const val globalVersionCode = 20210107
4341const val appPackageName = " io.goooler.demoapp"
4442const val appName = " Demo"
4543const val extraScriptPath = " buildSrc/extra.gradle.kts"
4644
47- val localLibs = mapOf (
48- " dir " to " libs " ,
49- " include " to arrayOf( " *.jar " , " *.aar " )
50- )
45+ val gitCommitCount : String get() = " git describe --tags " .exec()
46+ val gitCommitDescribe : Int get() = " git rev-list HEAD --count " .exec().toInt()
47+
48+ fun String. exec (): String = String ( Runtime .getRuntime().exec( this ).inputStream.readBytes()).trim( )
5149
5250fun ScriptHandlerScope.classpaths (vararg names : Any ) {
5351 dependencies {
@@ -133,8 +131,8 @@ fun Project.setupBase(module: Module? = null, block: BaseExtension.() -> Unit =
133131 defaultConfig {
134132 minSdkVersion(globalMinSdk)
135133 targetSdkVersion(globalTargetSdk)
136- versionCode = globalVersionCode
137- versionName = globalVersionName
134+ versionCode = gitCommitDescribe
135+ versionName = gitCommitCount
138136 vectorDrawables.useSupportLibrary = true
139137 ndk { abiFilters.addAll(ndkLibs) }
140138 module?.let {
@@ -259,7 +257,7 @@ private fun Project.setupCommon(module: Module? = null): BaseExtension {
259257 }
260258 implementations(
261259 // local
262- fileTree(localLibs ),
260+ fileTree(mapOf ( " dir " to " libs " , " include " to arrayOf( " *.jar " , " *.aar " )) ),
263261 project(Module .Base .moduleName),
264262
265263 // router
0 commit comments