forked from fechanique/cordova-plugin-fcm
-
-
Notifications
You must be signed in to change notification settings - Fork 272
/
FCMPlugin.gradle
111 lines (111 loc) · 7.23 KB
/
FCMPlugin.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
buildscript {
ext {
// Load system enviroment defined values, or, if unavailable, plugin defaults
def ANDROID_GRADLE_TOOLS_VERSION = System.getenv('ANDROID_GRADLE_TOOLS_VERSION') ?: '4.1.0'
try {
// Load configuration from install variables (package.json) two directories above
def PLUGIN_CONFIG = new groovy.json.JsonSlurper().parseText(file("${projectDir}/../../package.json").text).cordova.plugins['cordova-plugin-fcm-with-dependecy-updated']
ANDROID_GRADLE_TOOLS_VERSION = PLUGIN_CONFIG.ANDROID_GRADLE_TOOLS_VERSION
} catch(Exception e0) {
try {
// Load configuration from install variables (package.json) three directories above
def PLUGIN_CONFIG = new groovy.json.JsonSlurper().parseText(file("${projectDir}/../../../package.json").text).cordova.plugins['cordova-plugin-fcm-with-dependecy-updated']
ANDROID_GRADLE_TOOLS_VERSION = PLUGIN_CONFIG.ANDROID_GRADLE_TOOLS_VERSION
} catch(Exception e1) {
def WARNING_STYLE = "${(char)27}[33;49"+"m"
def DEFAULT_STYLE = "${(char)27}[39;49"+"m"
print(WARNING_STYLE+"FCMPlugin: Plugin install variables are not accessible, as package.json was unreachable/unreadable."+DEFAULT_STYLE)
}
}
// Override config with project values if available
ANDROID_GRADLE_TOOLS_VERSION = rootProject.hasProperty('ANDROID_GRADLE_TOOLS_VERSION') ? rootProject.ext.ANDROID_GRADLE_TOOLS_VERSION : ANDROID_GRADLE_TOOLS_VERSION
ext.gradleNumberVersion = ANDROID_GRADLE_TOOLS_VERSION.substring(0, ANDROID_GRADLE_TOOLS_VERSION.lastIndexOf(".")).toFloat()
}
repositories {
mavenCentral()
jcenter()
mavenLocal()
if (gradleNumberVersion >= 3.4f) {
google()
}
}
dependencies {
// Load system enviroment defined values, or, if unavailable, plugin defaults
def ANDROID_GOOGLE_SERVICES_VERSION = System.getenv('ANDROID_GOOGLE_SERVICES_VERSION') ?: '4.3.4'
def ANDROID_GRADLE_TOOLS_VERSION = System.getenv('ANDROID_GRADLE_TOOLS_VERSION') ?: '4.1.0'
try {
// Load configuration from install variables (package.json) two directories above
def PLUGIN_CONFIG = new groovy.json.JsonSlurper().parseText(file("${projectDir}/../../package.json").text).cordova.plugins['cordova-plugin-fcm-with-dependecy-updated']
ANDROID_GOOGLE_SERVICES_VERSION = PLUGIN_CONFIG.ANDROID_GOOGLE_SERVICES_VERSION
ANDROID_GRADLE_TOOLS_VERSION = PLUGIN_CONFIG.ANDROID_GRADLE_TOOLS_VERSION
} catch(Exception e0) {
try {
// Load configuration from install variables (package.json) three directories above
def PLUGIN_CONFIG = new groovy.json.JsonSlurper().parseText(file("${projectDir}/../../../package.json").text).cordova.plugins['cordova-plugin-fcm-with-dependecy-updated']
ANDROID_GOOGLE_SERVICES_VERSION = PLUGIN_CONFIG.ANDROID_GOOGLE_SERVICES_VERSION
ANDROID_GRADLE_TOOLS_VERSION = PLUGIN_CONFIG.ANDROID_GRADLE_TOOLS_VERSION
} catch(Exception e1) {
def WARNING_STYLE = "${(char)27}[33;49"+"m"
def DEFAULT_STYLE = "${(char)27}[39;49"+"m"
print(WARNING_STYLE+"FCMPlugin: Plugin install variables are not accessible, as package.json was unreachable/unreadable."+DEFAULT_STYLE)
}
}
// Override config with project values if available
ANDROID_GOOGLE_SERVICES_VERSION = rootProject.hasProperty('ANDROID_GOOGLE_SERVICES_VERSION') ? rootProject.ext.ANDROID_GOOGLE_SERVICES_VERSION : ANDROID_GOOGLE_SERVICES_VERSION
ANDROID_GRADLE_TOOLS_VERSION = rootProject.hasProperty('ANDROID_GRADLE_TOOLS_VERSION') ? rootProject.ext.ANDROID_GRADLE_TOOLS_VERSION : ANDROID_GRADLE_TOOLS_VERSION
// Avoid use "GRADLE_VERSION" because jitpack sets this like a environment variable
classpath "com.android.tools.build:gradle:${ANDROID_GRADLE_TOOLS_VERSION}"
classpath "com.google.gms:google-services:${ANDROID_GOOGLE_SERVICES_VERSION}"
}
}
repositories {
mavenCentral()
jcenter()
if (gradleNumberVersion >= 3.4f) {
google()
}
}
dependencies {
// Load system enviroment defined values, or, if unavailable, plugin defaults
def ANDROID_FCM_VERSION = System.getenv('ANDROID_FCM_VERSION') ?: '21.0.0'
def ANDROID_FIREBASE_BOM_VERSION = System.getenv('ANDROID_FIREBASE_BOM_VERSION') ?: '26.0.0'
try {
// Load configuration from install variables (package.json) two directories above
def PLUGIN_CONFIG = new groovy.json.JsonSlurper().parseText(file("${projectDir}/../../package.json").text).cordova.plugins['cordova-plugin-fcm-with-dependecy-updated']
ANDROID_FCM_VERSION = PLUGIN_CONFIG.ANDROID_FCM_VERSION
ANDROID_FIREBASE_BOM_VERSION = PLUGIN_CONFIG.ANDROID_FIREBASE_BOM_VERSION
} catch(Exception e0) {
try {
// Load configuration from install variables (package.json) three directories above
def PLUGIN_CONFIG = new groovy.json.JsonSlurper().parseText(file("${projectDir}/../../../package.json").text).cordova.plugins['cordova-plugin-fcm-with-dependecy-updated']
ANDROID_FCM_VERSION = PLUGIN_CONFIG.ANDROID_FCM_VERSION
ANDROID_FIREBASE_BOM_VERSION = PLUGIN_CONFIG.ANDROID_FIREBASE_BOM_VERSION
} catch(Exception e1) {
def WARNING_STYLE = "${(char)27}[33;49"+"m"
def DEFAULT_STYLE = "${(char)27}[39;49"+"m"
print(WARNING_STYLE+"FCMPlugin: Plugin install variables are not accessible, as package.json was unreachable/unreadable."+DEFAULT_STYLE)
}
}
// Override config with project values if available
ANDROID_FCM_VERSION = rootProject.hasProperty('ANDROID_FCM_VERSION') ? rootProject.ext.ANDROID_FCM_VERSION : ANDROID_FCM_VERSION
ANDROID_FIREBASE_BOM_VERSION = rootProject.hasProperty('ANDROID_FIREBASE_BOM_VERSION') ? rootProject.ext.ANDROID_FIREBASE_BOM_VERSION : ANDROID_FIREBASE_BOM_VERSION
if (gradleNumberVersion < 3.4f) {
def WARNING_STYLE = "${(char)27}[33;49"+"m"
def DEFAULT_STYLE = "${(char)27}[39;49"+"m"
print(WARNING_STYLE+"FCMPlugin: Support for Gradle v3.3 or lower is deprecated. Please upgrade to a newer version."+DEFAULT_STYLE)
compile "com.google.firebase:firebase-messaging:${ANDROID_FCM_VERSION}"
} else if (gradleNumberVersion < 5.0f) {
def WARNING_STYLE = "${(char)27}[33;49"+"m"
def DEFAULT_STYLE = "${(char)27}[39;49"+"m"
print(WARNING_STYLE+"FCMPlugin: Support for Gradle v4 or lower is deprecated. Please upgrade to a newer version."+DEFAULT_STYLE)
implementation "com.google.firebase:firebase-messaging:${ANDROID_FCM_VERSION}"
} else {
implementation platform("com.google.firebase:firebase-bom:${ANDROID_FIREBASE_BOM_VERSION}")
implementation "com.google.firebase:firebase-messaging"
}
}
// apply plugin: 'com.google.gms.google-services'
// class must be used instead of id(string) to be able to apply plugin from non-root gradle file
if (!project.plugins.hasPlugin('com.google.gms.google-services')) {
apply plugin: com.google.gms.googleservices.GoogleServicesPlugin
}