1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00
vcmi/android/vcmi-app/build.gradle

162 lines
4.4 KiB
Groovy
Raw Normal View History

2024-03-02 23:24:48 +02:00
apply plugin: 'com.android.application'
2023-02-16 10:11:39 +02:00
android {
2024-03-02 23:24:48 +02:00
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
2023-02-26 11:21:46 +02:00
ndkVersion '25.2.9519653'
2023-02-16 10:11:39 +02:00
2024-03-02 23:24:48 +02:00
// Extract native libraries from the APK
packagingOptions.jniLibs.useLegacyPackaging true
2023-02-16 10:11:39 +02:00
defaultConfig {
applicationId "is.xyz.vcmi"
2024-03-02 23:24:48 +02:00
compileSdk = androidCompileSdkVersion.takeAfter("-") as Integer // has "android-" prepended
minSdk = qtMinSdkVersion as Integer
targetSdk = qtTargetSdkVersion as Integer // ANDROID_TARGET_SDK_VERSION in the CMake project
2024-05-06 17:40:17 +02:00
versionCode 1600
versionName "1.6.0"
2024-03-02 23:24:48 +02:00
2023-02-16 10:11:39 +02:00
setProperty("archivesBaseName", "vcmi")
}
2024-03-02 23:24:48 +02:00
sourceSets {
main {
// Qt requires these to be in the android project root
manifest.srcFile '../AndroidManifest.xml'
jniLibs.srcDirs = ['../libs']
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'src/main/res', '../res']
}
}
2023-02-16 10:11:39 +02:00
signingConfigs {
releaseSigning
2023-04-15 10:47:24 +02:00
dailySigning
LoadSigningConfig("releaseSigning")
LoadSigningConfig("dailySigning")
2023-02-16 10:11:39 +02:00
}
buildTypes {
2023-02-26 11:21:46 +02:00
debug {
debuggable true
applicationIdSuffix '.debug'
manifestPlaceholders = [
applicationLabel: 'VCMI debug',
]
2023-02-26 11:21:46 +02:00
ndk {
debugSymbolLevel 'full'
}
}
2023-02-16 10:11:39 +02:00
release {
minifyEnabled false
zipAlignEnabled true
2024-03-02 23:24:48 +02:00
applicationIdSuffix = project.findProperty('applicationIdSuffix')
signingConfig = signingConfigs[project.findProperty('signingConfig') ?: 'releaseSigning']
2023-02-16 10:11:39 +02:00
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
manifestPlaceholders = [
2024-03-02 23:24:48 +02:00
applicationLabel: project.findProperty('applicationLabel') ?: 'VCMI',
]
2023-02-26 11:21:46 +02:00
ndk {
debugSymbolLevel 'full'
2023-02-26 11:21:46 +02:00
}
2023-02-16 10:11:39 +02:00
}
}
tasks.withType(JavaCompile) {
options.compilerArgs += ["-Xlint:deprecation"]
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
2024-03-02 23:24:48 +02:00
// Do not compress Qt binary resources file
aaptOptions {
noCompress 'rcc'
2023-02-16 10:11:39 +02:00
}
}
def CommandOutput(final cmd, final arguments, final cwd) {
try {
new ByteArrayOutputStream().withStream { final os ->
exec {
executable cmd
args arguments
workingDir cwd
standardOutput os
}
return os.toString().trim()
}
}
catch (final Exception ex) {
print("Broken: " + cmd + " " + arguments + " in " + cwd + " :: " + ex.toString())
return ""
}
}
2023-04-15 10:47:24 +02:00
def SigningPropertiesPath(final basePath, final signingConfigKey) {
return file("${basePath}/${signingConfigKey}.properties")
2023-02-16 10:11:39 +02:00
}
def SigningKeystorePath(final basePath, final keystoreFileName) {
2023-02-26 13:14:51 +02:00
return file("${basePath}/${keystoreFileName}")
2023-02-16 10:11:39 +02:00
}
2023-04-15 10:47:24 +02:00
def LoadSigningConfig(final signingConfigKey) {
2023-02-16 10:11:39 +02:00
final def props = new Properties()
2024-03-02 23:24:48 +02:00
final def propFile = SigningPropertiesPath(signingRoot, signingConfigKey)
2023-04-15 10:47:24 +02:00
def signingConfig = android.signingConfigs.getAt(signingConfigKey)
2023-02-16 10:11:39 +02:00
if (propFile.canRead()) {
props.load(new FileInputStream(propFile))
if (props != null
&& props.containsKey('STORE_FILE')
2023-04-15 10:47:24 +02:00
&& props.containsKey('KEY_ALIAS')) {
2024-03-02 23:24:48 +02:00
signingConfig.storeFile = SigningKeystorePath(signingRoot, props['STORE_FILE'])
2023-04-15 10:47:24 +02:00
signingConfig.storePassword = props['STORE_PASSWORD']
signingConfig.keyAlias = props['KEY_ALIAS']
if(props.containsKey('STORE_PASSWORD'))
signingConfig.storePassword = props['STORE_PASSWORD']
else
signingConfig.storePassword = System.getenv("ANDROID_STORE_PASSWORD")
if(props.containsKey('KEY_PASSWORD'))
signingConfig.keyPassword = props['KEY_PASSWORD']
else
signingConfig.keyPassword = System.getenv("ANDROID_KEY_PASSWORD")
2023-02-16 10:11:39 +02:00
} else {
println("Some props from signing file are missing")
2023-04-15 10:47:24 +02:00
android.signingConfigs.putAt(signingConfigKey, null)
2023-02-16 10:11:39 +02:00
}
} else {
println("file with signing properties is missing")
2023-04-15 10:47:24 +02:00
android.signingConfigs.putAt(signingConfigKey, null)
2023-02-16 10:11:39 +02:00
}
}
dependencies {
2024-03-02 23:24:48 +02:00
implementation fileTree(dir: '../libs', include: ['*.jar', '*.aar'])
implementation 'androidx.annotation:annotation:1.7.1'
implementation 'androidx.documentfile:documentfile:1.0.1'
2023-02-16 10:11:39 +02:00
}