strato/app/build.gradle
lynxnb d5d6e677ca Rework CI to only upload artifacts for PR builds
CI now performs build checks on pushes to the master branch only.
For pull requests, the dev variant of the app is built and artifacts are uploaded for ease of testing and side-by-side installation. PR builds use autogenerated debug signing keys, resulting in different keys being used for each build on purpose to ensure they cannot be installed over each other, avoiding any possible conflict between two PRs.
2024-02-27 23:11:15 +01:00

259 lines
7.4 KiB
Groovy

plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
id 'idea'
id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"
}
idea.module {
// These are not viable to index on most systems so exclude them to prevent IDE crashes
excludeDirs.add(file("libraries/boost"))
}
android {
namespace 'org.stratoemu.strato'
compileSdk 34
defaultConfig {
applicationId "org.stratoemu.strato"
minSdk 29
targetSdk 33
versionCode getGitVersionCode()
versionName getGitVersionName()
ndk {
//noinspection ChromeOsAbiSupport
abiFilters "arm64-v8a"
}
// Disable the use of a separate process for emulation by default
manifestPlaceholders["emulationProcess"] = ""
def locales = ["en", "de", "el", "es", "es-419", "fr", "hu", "id", "it", "ja", "ko", "pl", "ru", "ta", "zh-Hans", "zh-Hant"]
// Add available locales to the build config so that they can be accessed from the app
buildConfigField "String[]", "AVAILABLE_APP_LANGUAGES", "new String[]{\"" + locales.join("\",\"") + "\"}"
// Uncomment the following line whenever AAPT2 will properly support BCP47 language tags
//resourceConfigurations += locales
}
/* JVM Bytecode Options */
def javaVersion = JavaVersion.VERSION_17
kotlinOptions {
jvmTarget = javaVersion.toString()
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}
compileOptions {
sourceCompatibility javaVersion
targetCompatibility javaVersion
}
packagingOptions {
jniLibs.useLegacyPackaging = true
}
buildTypes {
release {
debuggable true
externalNativeBuild {
cmake {
arguments "-DCMAKE_BUILD_TYPE=RELEASE"
}
}
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
manifestPlaceholders["emulationProcess"] = ":emulationProcess"
}
reldebug {
debuggable true
externalNativeBuild {
cmake {
arguments "-DCMAKE_BUILD_TYPE=RELWITHDEBINFO"
}
}
minifyEnabled false
shrinkResources false
signingConfig signingConfigs.debug
}
debug {
debuggable true
minifyEnabled false
shrinkResources false
signingConfig signingConfigs.debug
}
}
flavorDimensions += "version"
productFlavors {
mainline {
dimension = "version"
}
dev {
dimension = "version"
applicationIdSuffix = ".dev"
}
}
buildFeatures {
viewBinding true
buildConfig true
}
/* NDK and CMake */
ndkVersion '26.1.10909125'
externalNativeBuild {
cmake {
version '3.22.1+'
path "CMakeLists.txt"
}
}
/* Android Assets */
androidResources {
ignoreAssetsPattern '*.md'
}
/* Vulkan Validation Layers */
sourceSets {
reldebug {
jniLibs {
srcDir "libraries/vklayers"
}
}
debug {
jniLibs {
srcDir "libraries/vklayers"
}
}
}
}
dependencies {
/* Google */
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'androidx.activity:activity-ktx:1.8.2'
implementation 'com.google.android.material:material:1.10.0'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
implementation 'androidx.window:window:1.2.0'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.2"
implementation 'androidx.fragment:fragment-ktx:1.6.2'
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"
implementation 'com.google.android.flexbox:flexbox:3.0.0'
/* Kotlin */
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2'
/* JetBrains */
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
/* Other Java */
implementation 'info.debatty:java-string-similarity:2.0.0'
implementation 'com.github.KikiManjaro:colorpicker:v1.1.12'
implementation 'com.github.android:renderscript-intrinsics-replacement-toolkit:344be3f'
}
kapt {
correctErrorTypes true
}
/**
* Returns the version name based on the current git state
* If HEAD is a tag, the tag name is used as the version name
* e.g. `1.0.0`
* If HEAD is not a tag, the closest tag name, the branch name and the short commit hash are used
* e.g. `1.0.0-master-ab00cd11`
* If PR_NUMBER is set, prPR_NUMBER is used instead of the branch name
* e.g. `1.0.0-pr123-ab00cd11`
*/
def getGitVersionName() {
def versionName = '0.0.0'
try {
// Check if HEAD is a tag
def process = 'git describe --exact-match'.execute([], project.rootDir)
def isTag = process.waitFor() == 0
// Use the tag name as the version name
def tag = 'git describe --abbrev=0'.execute([], project.rootDir).text.trim()
if (!tag.isEmpty())
versionName = tag
// If HEAD is not a tag, append the branch name and the short commit hash
if (!isTag)
versionName += '-' + getGitBranch() + '-' + getGitShortHash()
} catch (Exception e) {
logger.quiet(e.toString() + ': defaulting to dummy version number ' + versionName)
}
logger.quiet('Version name: ' + versionName)
return versionName
}
/**
* Returns the number of commits until the last tag
*/
def getGitVersionCode() {
def versionCode = 1
try {
versionCode = Integer.max('git rev-list --first-parent --count --tags'.execute([], project.rootDir).text
.toInteger(), versionCode)
} catch (Exception e) {
logger.error(e.toString() + ': defaulting to dummy version code ' + versionCode)
}
logger.quiet('Version code: ' + versionCode)
return versionCode
}
/**
* Returns the short commit hash
*/
def getGitShortHash() {
def gitHash = '0'
try {
gitHash = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
} catch (Exception e) {
logger.error(e.toString() + ': defaulting to dummy build hash ' + gitHash)
}
return gitHash
}
/**
* Returns the current branch name, or prPR_NUMBER if PR_NUMBER is set
*/
def getGitBranch() {
def branch = 'unk'
try {
def prNumber = System.getenv('PR_NUMBER') ?: ''
if (!prNumber.isEmpty())
branch = 'pr' + prNumber
else
branch = 'git rev-parse --abbrev-ref HEAD'.execute([], project.rootDir).text.trim()
} catch (Exception e) {
logger.error(e.toString() + ': defaulting to dummy branch ' + branch)
}
return branch
}