build.gradle 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. apply plugin: 'com.android.application'
  2. def fmodeJpushEnabled = providers.gradleProperty('fmodeJpushEnabled').getOrElse('false').toBoolean()
  3. def fmodeJpushAppKey = providers.environmentVariable('JPUSH_APPKEY').getOrElse('')
  4. android {
  5. namespace = "cn.fmode.app"
  6. compileSdk = rootProject.ext.compileSdkVersion
  7. defaultConfig {
  8. applicationId "cn.fmode.app"
  9. minSdkVersion rootProject.ext.minSdkVersion
  10. targetSdkVersion rootProject.ext.targetSdkVersion
  11. versionCode 1
  12. versionName "1.0"
  13. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  14. buildConfigField 'boolean', 'JPUSH_ENABLED', fmodeJpushEnabled.toString()
  15. manifestPlaceholders += [JPUSH_APPKEY: fmodeJpushAppKey, JPUSH_CHANNEL: 'fmode', JPUSH_ENABLED: fmodeJpushEnabled.toString()]
  16. aaptOptions {
  17. // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
  18. // Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
  19. ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
  20. }
  21. }
  22. buildFeatures {
  23. buildConfig = true
  24. }
  25. if (!fmodeJpushEnabled) {
  26. sourceSets.main.java {
  27. exclude '**/JPushSdk.java', '**/JPushReceiver.java', '**/JPushService.java', '**/JPushClickActivity.java'
  28. }
  29. }
  30. if (fmodeJpushEnabled && file('src/jpush/AndroidManifest.xml').exists()) {
  31. sourceSets.debug.manifest.srcFile 'src/jpush/AndroidManifest.xml'
  32. sourceSets.release.manifest.srcFile 'src/jpush/AndroidManifest.xml'
  33. }
  34. buildTypes {
  35. release {
  36. minifyEnabled false
  37. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  38. }
  39. }
  40. }
  41. repositories {
  42. if (fmodeJpushEnabled) {
  43. maven {
  44. url 'https://maven.jiguang.cn/nexus/content/repositories/releases/'
  45. content { includeGroup 'cn.jiguang.sdk' }
  46. }
  47. }
  48. flatDir{
  49. dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
  50. }
  51. }
  52. dependencies {
  53. if (fmodeJpushEnabled) {
  54. implementation('cn.jiguang.sdk:jpush:6.3.1') {
  55. exclude group: 'cn.jiguang.sdk', module: 'jcore'
  56. }
  57. implementation 'cn.jiguang.sdk:jcore:5.6.0'
  58. }
  59. implementation fileTree(include: ['*.jar'], dir: 'libs')
  60. implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
  61. implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
  62. implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
  63. implementation project(':capacitor-android')
  64. testImplementation "junit:junit:$junitVersion"
  65. androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
  66. androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
  67. implementation project(':capacitor-cordova-android-plugins')
  68. }
  69. apply from: 'capacitor.build.gradle'
  70. try {
  71. def servicesJSON = file('google-services.json')
  72. if (servicesJSON.text) {
  73. apply plugin: 'com.google.gms.google-services'
  74. }
  75. } catch(Exception e) {
  76. logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
  77. }