build.gradle 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. import java.text.SimpleDateFormat
  2. import java.time.LocalDateTime
  3. plugins {
  4. id 'com.android.application'
  5. id 'kotlin-android'
  6. id 'kotlin-kapt'
  7. }
  8. static int formatTime() {
  9. LocalDateTime now = LocalDateTime.now()
  10. int year = now.year % 100 // 取年份的最后两位
  11. int month = now.monthValue
  12. int day = now.dayOfMonth
  13. int hour = now.hour
  14. int randomNumber = new Random().nextInt(10) // 生成0到9之间的随机数
  15. return Integer.parseInt(String.format("%02d%02d%02d%02d%d", year, month, day, hour, randomNumber))
  16. }
  17. ext{
  18. versionCode=Integer.parseInt(new SimpleDateFormat("yyMMddHH").format(new Date()) + 1)
  19. brandCode="058A"
  20. brandVersionCode=versionCode
  21. model="3015"
  22. }
  23. android {
  24. compileSdk 31
  25. defaultConfig {
  26. applicationId "com.develop.foodcooking"
  27. minSdk 21
  28. targetSdk 26
  29. versionCode project.ext.versionCode
  30. versionName "${project.ext.model}.${project.ext.brandCode}.${project.ext.versionCode}"
  31. archivesBaseName = "cofar-cooking_${versionName}"
  32. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  33. javaCompileOptions {
  34. annotationProcessorOptions {
  35. arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
  36. }
  37. }
  38. kapt {
  39. arguments {
  40. arg("AROUTER_MODULE_NAME", project.getName())
  41. arg("room.schemaLocation", "$projectDir/schemas".toString())
  42. }
  43. }
  44. packagingOptions {
  45. pickFirst 'lib/armeabi-v7a/libc++_shared.so'
  46. }
  47. }
  48. flavorDimensions "platform"
  49. productFlavors {
  50. brandDefault {
  51. dimension "platform"
  52. applicationId "com.develop.foodcooking"
  53. buildConfigField("String", "UpdatePlatform", "\"normal\"")
  54. resValue("string", "app_theme", "@style/SplashTheme")
  55. buildConfigField("String", "model", "\"3015\"")
  56. buildConfigField("String", "brandCode", "\"0000\"")
  57. }
  58. brand034 {
  59. manifestPlaceholders = [channelName: "brand034"]
  60. dimension "platform"
  61. applicationId "com.develop.foodcooking"
  62. buildConfigField("String", "UpdatePlatform", "\"night\"")
  63. resValue("string", "app_theme", "@style/Splash034Theme")
  64. buildConfigField("String", "model", "\"3015\"")
  65. buildConfigField("String", "brandCode", "\"034A\"")
  66. }
  67. brand000ATuya {
  68. manifestPlaceholders = [channelName: "brand000ATuya"]
  69. dimension "platform"
  70. applicationId "com.develop.foodcooking"
  71. buildConfigField("String", "UpdatePlatform", "\"normal\"")
  72. resValue("string", "app_theme", "@style/SplashTheme")
  73. buildConfigField("String", "model", "\"3015\"")
  74. buildConfigField("String", "brandCode", "\"000A\"")
  75. }
  76. brand058A {
  77. manifestPlaceholders = [channelName: "brand058A"]
  78. dimension "platform"
  79. applicationId "com.develop.foodcooking"
  80. buildConfigField("String", "UpdatePlatform", "\"normal\"")
  81. resValue("string", "app_theme", "@style/SplashTheme")
  82. buildConfigField("String", "model", "\"3015\"")
  83. buildConfigField("String", "brandCode", "\"058A\"")
  84. }
  85. brand012ATuya {
  86. dimension "platform"
  87. applicationId "com.develop.foodcooking"
  88. buildConfigField("String", "UpdatePlatform", "\"normal\"")
  89. resValue("string", "app_theme", "@style/SplashTheme")
  90. buildConfigField("String", "model", "\"3015\"")
  91. buildConfigField("String", "brandCode", "\"012A\"")
  92. }
  93. }
  94. signingConfigs {
  95. debug {
  96. storeFile file('..\\signature\\rk.jks')
  97. storePassword '123456'
  98. keyAlias 'rk'
  99. keyPassword '123456'
  100. }
  101. foodCooking {
  102. storeFile file("..\\signature\\rk.jks")
  103. storePassword '123456'
  104. keyAlias 'rk'
  105. keyPassword '123456'
  106. }
  107. release {
  108. storeFile file('..\\signature\\rk.jks')
  109. storePassword '123456'
  110. keyAlias 'rk'
  111. keyPassword '123456'
  112. }
  113. }
  114. //自定义输出包名的设置
  115. applicationVariants.all { variant ->
  116. variant.outputs.all {
  117. // 输出apk名称为sharev1.0_tencent.apk
  118. def fileName = "cofar-cooking_${defaultConfig.versionName}_${variant.productFlavors[0].name}_release.apk"
  119. outputFileName = fileName
  120. }
  121. }
  122. buildTypes {
  123. release {
  124. debuggable true
  125. minifyEnabled false
  126. productFlavors.brand034.signingConfig signingConfigs.release
  127. productFlavors.brand000ATuya.signingConfig signingConfigs.release
  128. productFlavors.brand012ATuya.signingConfig signingConfigs.release
  129. productFlavors.brandDefault.signingConfig signingConfigs.release
  130. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
  131. }
  132. debug{
  133. debuggable true
  134. // buildConfigField("String", "UpdatePlatform", "\"night\"")
  135. // resValue("string", "app_theme", "@style/Splash034Theme")
  136. // buildConfigField("String", "model", "\"3015\"")
  137. // buildConfigField("String", "brandCode", "\"034A\"")
  138. //
  139. // manifestPlaceholders = [channelName: "brand000ATuya"]
  140. // buildConfigField("String", "UpdatePlatform", "\"normal\"")
  141. // resValue("string", "app_theme", "@style/SplashTheme")
  142. // buildConfigField("String", "model", "\"3015\"")
  143. // buildConfigField("String", "brandCode", "\"000A\"")
  144. // manifestPlaceholders = [channelName: "brand034"]
  145. // buildConfigField("String", "UpdatePlatform", "\"night\"")
  146. // resValue("string", "app_theme", "@style/Splash034Theme")
  147. // buildConfigField("String", "model", "\"3015\"")
  148. // buildConfigField("String", "brandCode", "\"034A\"")
  149. manifestPlaceholders = [channelName: "brand058A"]
  150. buildConfigField("String", "UpdatePlatform", "\"normal\"")
  151. resValue("string", "app_theme", "@style/SplashTheme")
  152. buildConfigField("String", "model", "\"3015\"")
  153. buildConfigField("String", "brandCode", "\"058A\"")
  154. }
  155. //输出类型
  156. applicationVariants.all {
  157. //判断是release还是debug版本
  158. def buildType = it.buildType.name
  159. //获取当前时间的"YYYY-MM-dd"格式。
  160. def createTime = new Date().format("YYYY-MM-dd-HHmm", TimeZone.getTimeZone("GMT+08:00"))
  161. //如果是正式包,将其输入到指定文件夹
  162. if (buildType == "release") {
  163. it.getPackageApplication().outputDirectory = new File('D:\\out_apk_food/'+ "${it.productFlavors[0].name}/${createTime}")
  164. }
  165. }
  166. }
  167. compileOptions {
  168. sourceCompatibility JavaVersion.VERSION_1_8
  169. targetCompatibility JavaVersion.VERSION_1_8
  170. }
  171. kotlinOptions {
  172. jvmTarget = '1.8'
  173. }
  174. viewBinding {
  175. enabled = true
  176. }
  177. }
  178. dependencies {
  179. implementation project(path: ':libBase')
  180. implementation project(path: ':BusinessRouter')
  181. implementation project(path: ':BusinessAuth')
  182. implementation project(path: ':BusinessSetting')
  183. implementation project(path: ':BusinessMain')
  184. implementation project(path: ':BusinessStep')
  185. kapt 'com.alibaba:arouter-compiler:1.5.1'
  186. }