打印机封装
This commit is contained in:
+34
-11
@@ -1,25 +1,47 @@
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Properties
|
||||
import java.io.File
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.compose)
|
||||
}
|
||||
|
||||
// 自动版本号管理
|
||||
val versionPropsFile = file("version.properties")
|
||||
fun getVersionCode(): Int {
|
||||
val props = Properties()
|
||||
if (versionPropsFile.exists()) {
|
||||
props.load(versionPropsFile.inputStream())
|
||||
}
|
||||
val code = props.getProperty("VERSION_CODE", "1").toInt()
|
||||
props.setProperty("VERSION_CODE", (code + 1).toString())
|
||||
props.store(versionPropsFile.outputStream(), null)
|
||||
return code
|
||||
}
|
||||
|
||||
fun getVersionName(): String {
|
||||
val props = Properties()
|
||||
if (versionPropsFile.exists()) {
|
||||
props.load(versionPropsFile.inputStream())
|
||||
}
|
||||
return props.getProperty("VERSION_NAME", "1.2")
|
||||
}
|
||||
|
||||
val autoVersionCode = getVersionCode()
|
||||
val autoVersionName = getVersionName()
|
||||
|
||||
android {
|
||||
namespace = "com.example.ops_android"
|
||||
compileSdk {
|
||||
version = release(36) {
|
||||
minorApiLevel = 1
|
||||
}
|
||||
}
|
||||
compileSdk = 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.example.ops_android"
|
||||
minSdk = 24
|
||||
targetSdk = 36
|
||||
versionCode = 2
|
||||
versionName = "1.1"
|
||||
versionCode = autoVersionCode
|
||||
versionName = autoVersionName
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -50,7 +72,6 @@ android {
|
||||
}
|
||||
buildFeatures {
|
||||
compose = true
|
||||
aidl = true
|
||||
buildConfig = true
|
||||
}
|
||||
}
|
||||
@@ -58,11 +79,9 @@ android {
|
||||
androidComponents {
|
||||
onVariants { variant ->
|
||||
variant.outputs.forEach { output ->
|
||||
val versionName = "1.1"
|
||||
val versionCode = "2"
|
||||
val buildType = variant.buildType
|
||||
val date = SimpleDateFormat("yyyyMMdd").format(Date())
|
||||
output.outputFileName.set("PDA_Printer_Test_v${versionName}_${versionCode}_${buildType}_${date}.apk")
|
||||
output.outputFileName.set("PDA_Printer_Test_v${autoVersionName}_${autoVersionCode}_${buildType}_${date}.apk")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,6 +95,10 @@ dependencies {
|
||||
implementation(libs.androidx.compose.ui.tooling.preview)
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.lifecycle.runtime.ktx)
|
||||
|
||||
// 打印SDK
|
||||
implementation(files("libs/lcprintsdk-release.aar"))
|
||||
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(platform(libs.androidx.compose.bom))
|
||||
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
||||
|
||||
Reference in New Issue
Block a user