Warning, /graphics/krita/packaging/android/apk/build.gradle is written in an unsupported language. File is not indexed.

0001 buildscript {
0002     repositories {
0003         google()
0004         mavenCentral()
0005     }
0006 
0007     dependencies {
0008         classpath 'com.android.tools.build:gradle:7.2.1'
0009     }
0010 }
0011 
0012 repositories {
0013     google()
0014     mavenCentral()
0015 }
0016 
0017 apply plugin: 'com.android.application'
0018 
0019 dependencies {
0020     implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
0021 }
0022 
0023 ext {
0024     abi = System.getenv('ANDROID_ABI') ?: project.ext.properties['abi']
0025     ndkpath = System.getenv('ANDROID_NDK_HOME') ?: project.ext.properties['ndk.dir']  // TODO: Newer versions of Qt do support this dir
0026     installPrefix = '../krita-android-build'
0027     qtResPath = System.getenv('KRITA_BUILD_APPBUNDLE') ? '../i/src/android/java' : ""
0028 }
0029 
0030 task configure() {
0031     doLast {
0032         if (abi == null && !project.hasProperty("abi")) {
0033             logger.error('ANDROID_ABI not specified using the default one instead: arm64-v8a')
0034             abi = 'arm64-v8a'
0035         }
0036 
0037         def libs = new File(installPrefix, 'lib')
0038         if (!libs.exists()) {
0039             throw new FileNotFoundException('Krita libraries not found, please check if -p=krita-bin finished without errors')
0040         }
0041     }
0042 }
0043 
0044 task writeConfig(type: WriteProperties) {
0045     outputFile = file("gradle.properties")
0046     def gradleProperties = new Properties()
0047     outputFile.withInputStream { gradleProperties.load(it) }
0048 
0049     properties gradleProperties
0050     property 'abi', abi
0051     property 'ndk.dir', ndkpath
0052 }
0053 
0054 // copy libs(plugins) which start with krita*.so and rename
0055 // them to start with `lib_`
0056 task copyLibs(type: Copy) {
0057     from "$installPrefix/lib"
0058     into "libs/$abi"
0059     rename ('^krita(.*).so$', 'lib_krita$1.so')
0060 }
0061 
0062 task copyFonts(type: Copy) {
0063     def etcDir = "../i/"
0064     from "$etcDir/etc"
0065     into 'assets/etc/'
0066     include '**'
0067 }
0068 
0069 /*
0070  * androiddeployqt doesn't fully copy the directories. Hidden directories
0071  * to be specific. That's why we copy manually and then delete the partial
0072  * one it creates
0073  */
0074 task copyAssets(type: Copy) {
0075     from "$installPrefix/share/"
0076     into 'assets/'
0077     include '**'
0078 }
0079 
0080 task copyLocaleFiles(type: Copy) {
0081     def libsDir = "../i/"
0082     from "$libsDir/share/locale"
0083     from "$libsDir/translations"
0084     into 'assets/locale/'
0085     include '**'
0086 }
0087 
0088 task copyExtraMltFiles(type: Copy) {
0089     def libsDir = "../i/"
0090     from "$libsDir/share/mlt-7"
0091     into 'assets/mlt'
0092     include '**'
0093 }
0094 
0095 /*
0096  * Remove "share" folder in assets. It is copied both manually and by
0097  * androiddeployqt(reason in copyAssets task).
0098  */
0099 task removeDuplicateAssets(type: Delete) {
0100     delete "assets/share"
0101 }
0102 
0103 def isPackagingAPK() {
0104     return gradle.taskGraph.hasTask(assembleRelease) || gradle.taskGraph.hasTask(assembleDebug)
0105 }
0106 
0107 android {
0108     compileSdkVersion androidCompileSdkVersion.toInteger()
0109 
0110     ndkPath ndkpath
0111 
0112     packagingOptions {
0113         jniLibs {
0114             useLegacyPackaging = true
0115         }
0116     }
0117 
0118     sourceSets {
0119         main {
0120             manifest.srcFile 'AndroidManifest.xml'
0121             java.srcDirs = [qt5AndroidDir + '/src', qtResPath + '/src', 'src', 'java']
0122             aidl.srcDirs = [qt5AndroidDir + '/src', qtResPath + '/src', 'src', 'aidl']
0123             res.srcDirs = [qt5AndroidDir + '/res',  qtResPath + '/res', 'res']
0124             resources.srcDirs = ['src']
0125             renderscript.srcDirs = ['src']
0126             assets.srcDirs = ['assets']
0127             jniLibs.srcDirs = ['libs', 'lib']
0128         }
0129         nightly {
0130             manifest.srcFile 'flavors/next/AndroidManifest.xml'
0131         }
0132         debug {
0133             manifest.srcFile 'flavors/debug/AndroidManifest.xml'
0134         }
0135     }
0136 
0137     buildTypes {
0138         release {
0139             minifyEnabled true
0140             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
0141                     'proguard-rules.pro'
0142         }
0143         nightly {
0144             initWith release
0145             applicationIdSuffix ".next"
0146         }
0147         debug {
0148             applicationIdSuffix ".debug"
0149         }
0150     }
0151 
0152     // This is needed because, gradle by default ignores hidden assets.
0153     aaptOptions {
0154         ignoreAssetsPattern "!.foajasoie"
0155     }
0156 
0157     lintOptions {
0158         abortOnError false
0159     }
0160 
0161     project.ext.constant = 5
0162 
0163     def versionMajor    = 5
0164     def versionMinor    = 0
0165 
0166     /**
0167      * This version does **not** correspond to the patch version
0168      * of Krita. Instead, it is just incremented for every public
0169      * (including alpha and beta) release of versionMajor.versionMinor
0170      * branch
0171      */
0172     def versionRelease  = 0
0173 
0174     defaultConfig {
0175         targetSdkVersion 33
0176         minSdkVersion 23
0177         versionCode project.ext.constant * 1000000 + versionMajor * 10000 + versionMinor * 100 + versionRelease
0178         versionName "5.2.0-prealpha"
0179         archivesBaseName = System.getenv('KRITA_BUILD_APPBUNDLE') ? "krita-$versionName" : "krita-$abi-$versionName"
0180     }
0181 
0182     preBuild.dependsOn(configure)
0183     configure.onlyIf { isPackagingAPK() }
0184     configure.finalizedBy(writeConfig)
0185     configure.finalizedBy(copyLibs)
0186     configure.finalizedBy(copyFonts)
0187     configure.finalizedBy(copyAssets)
0188     configure.finalizedBy(copyLocaleFiles)
0189     configure.finalizedBy(copyExtraMltFiles)
0190     configure.finalizedBy(removeDuplicateAssets)
0191 }
0192 
0193 dependencies {
0194     implementation 'com.android.billingclient:billing:5.0.0'
0195     implementation 'androidx.annotation:annotation:1.4.0'
0196     implementation files('../i/jar/SDL2Android.jar')
0197 }