|
| 1 | +apply plugin: 'com.android.application' |
| 2 | + |
| 3 | +import groovy.json.JsonSlurper |
| 4 | + |
| 5 | +def getPackage() { |
| 6 | + def packageFile = file("../../package.json") |
| 7 | + if (packageFile.exists()) { |
| 8 | + return new JsonSlurper().parseText(packageFile.text) |
| 9 | + } |
| 10 | + return null |
| 11 | +} |
| 12 | + |
| 13 | +def packageJson = getPackage() |
| 14 | +def version = packageJson ? packageJson.version : "1.0.0" |
| 15 | + |
| 16 | +def versionParts = version.tokenize('.') |
| 17 | +def major = versionParts[0].toInteger() |
| 18 | +def minor = versionParts[1].toInteger() |
| 19 | +def patch = versionParts[2].toInteger() |
| 20 | + |
| 21 | +def generatedVersionCode = major * 10000 + minor * 100 + patch |
| 22 | +def generatedVersionName = version |
| 23 | + |
| 24 | +android { |
| 25 | + namespace "com.crowdsec.manager.mobile" |
| 26 | + compileSdk rootProject.ext.compileSdkVersion |
| 27 | + defaultConfig { |
| 28 | + applicationId "com.crowdsec.manager.mobile" |
| 29 | + minSdkVersion rootProject.ext.minSdkVersion |
| 30 | + targetSdkVersion rootProject.ext.targetSdkVersion |
| 31 | + versionCode generatedVersionCode |
| 32 | + versionName generatedVersionName |
| 33 | + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| 34 | + aaptOptions { |
| 35 | + // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. |
| 36 | + // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61 |
| 37 | + ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~' |
| 38 | + } |
| 39 | + } |
| 40 | + buildTypes { |
| 41 | + release { |
| 42 | + minifyEnabled true |
| 43 | + shrinkResources true |
| 44 | + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 45 | + if (project.hasProperty('RELEASE_STORE_FILE')) |
| 46 | + signingConfig signingConfigs.release |
| 47 | + } |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +repositories { |
| 52 | + flatDir{ |
| 53 | + dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs' |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +dependencies { |
| 58 | + implementation fileTree(include: ['*.jar'], dir: 'libs') |
| 59 | + implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion" |
| 60 | + implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion" |
| 61 | + implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion" |
| 62 | + implementation project(':capacitor-android') |
| 63 | + testImplementation "junit:junit:$junitVersion" |
| 64 | + androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" |
| 65 | + androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" |
| 66 | + implementation project(':capacitor-cordova-android-plugins') |
| 67 | +} |
| 68 | + |
| 69 | +apply from: 'capacitor.build.gradle' |
| 70 | + |
| 71 | +try { |
| 72 | + def servicesJSON = file('google-services.json') |
| 73 | + if (servicesJSON.text) { |
| 74 | + apply plugin: 'com.google.gms.google-services' |
| 75 | + } |
| 76 | +} catch(Exception e) { |
| 77 | + logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work") |
| 78 | +} |
0 commit comments