Files
Space-Banane 3d6548d77d
android-release / build (push) Successful in 3m5s
Migrate app to native Kotlin
2026-07-06 13:49:22 +02:00

141 lines
4.5 KiB
Groovy

plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
def getVersionCode = {
def stdout = new ByteArrayOutputStream()
try {
exec {
commandLine 'git', 'rev-list', '--count', 'HEAD'
standardOutput = stdout
errorOutput = new ByteArrayOutputStream()
ignoreExitValue = true
}
def count = stdout.toString().trim()
return count.isInteger() ? count.toInteger() : 1
} catch (ignored) {
return 1
}
}
def signingPropertiesFile = rootProject.file('keystore.properties')
def signingProperties = new Properties()
if (signingPropertiesFile.exists()) {
signingPropertiesFile.withInputStream(signingProperties.&load)
}
def readSigningValue = { String... keys ->
keys.collect { key -> System.getenv(key) ?: signingProperties.getProperty(key) }
.find { value -> value != null && !value.trim().isEmpty() }
}
def releaseKeystorePath = readSigningValue('CODEXMOBILE_STORE_FILE', 'CODEXMOBILE_KEYSTORE_FILE')
def releaseKeystorePassword = readSigningValue('CODEXMOBILE_STORE_PASSWORD', 'CODEXMOBILE_KEYSTORE_PASSWORD')
def releaseKeyAlias = readSigningValue('CODEXMOBILE_KEY_ALIAS')
def releaseKeyPassword = readSigningValue('CODEXMOBILE_KEY_PASSWORD')
def hasReleaseSigning = [releaseKeystorePath, releaseKeystorePassword, releaseKeyAlias, releaseKeyPassword].every { it }
def releaseSigningHelp = '''Release signing is not configured.
Provide these values either as environment variables or in keystore.properties:
- CODEXMOBILE_STORE_FILE or CODEXMOBILE_KEYSTORE_FILE
- CODEXMOBILE_STORE_PASSWORD or CODEXMOBILE_KEYSTORE_PASSWORD
- CODEXMOBILE_KEY_ALIAS
- CODEXMOBILE_KEY_PASSWORD
'''
android {
namespace 'dev.reversed.codexbarmobile'
compileSdk 34
signingConfigs {
if (hasReleaseSigning) {
release {
storeFile rootProject.file(releaseKeystorePath)
storePassword releaseKeystorePassword
keyAlias releaseKeyAlias
keyPassword releaseKeyPassword
}
}
}
defaultConfig {
applicationId 'dev.reversed.codexbarmobile'
minSdk 26
targetSdk 34
versionCode getVersionCode()
versionName '1.0.0'
vectorDrawables.useSupportLibrary = true
}
buildTypes {
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-debug'
}
release {
if (hasReleaseSigning) {
signingConfig signingConfigs.release
}
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.5.14'
}
packaging {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
gradle.taskGraph.whenReady { graph ->
def needsSignedRelease = graph.allTasks.any { task ->
task.project == project &&
task.name.toLowerCase().contains('release') &&
!task.name.toLowerCase().contains('lint') &&
!task.name.toLowerCase().contains('unittest') &&
!task.name.toLowerCase().contains('signingreport')
}
if (needsSignedRelease && !hasReleaseSigning) {
throw new GradleException(releaseSigningHelp)
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.13.1'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.4'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.4'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.8.4'
implementation 'androidx.activity:activity-compose:1.9.2'
implementation platform('androidx.compose:compose-bom:2024.06.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.compose.material:material-icons-extended'
implementation 'androidx.security:security-crypto:1.1.0-alpha06'
implementation 'com.google.errorprone:error_prone_annotations:2.28.0'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1'
debugImplementation 'androidx.compose.ui:ui-tooling'
}