├── .gitignore ├── LICENSE ├── README.md ├── cordova-google-api-version.gradle ├── package.json ├── plugin.xml ├── properties.gradle └── scripts └── before-prepare.js /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Transistor Software 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # !!! This Plugin is obsolete !!! 2 | 3 | cordova-google-api-version 4 | ====================================== 5 | 6 | This plugin solves Google API version conflicts when multiple plugins require different versions of google APIs (eg: `play-services`, `firebase`) by pinning all dependencies to any version you wish. 7 | 8 | # Installation 9 | 10 | Install the plugin providing `--variable GOOGLE_API_VERSION=` 11 | 12 | $ cordova plugin add cordova-google-api-version --variable GOOGLE_API_VERSION=11.2.0 13 | 14 | 15 | # Credits 16 | 17 | Thanks to [**Dave Alden, Working Edge LTD**](https://github.com/dpa99c), for creating the initial implementation of this with his [cordova-android-play-services-gradle-release](https://github.com/dpa99c/cordova-android-play-services-gradle-release) 18 | 19 | License 20 | ================ 21 | 22 | MIT License 23 | 24 | Copyright (c) 2017 Transistor Software 25 | 26 | Permission is hereby granted, free of charge, to any person obtaining a copy 27 | of this software and associated documentation files (the "Software"), to deal 28 | in the Software without restriction, including without limitation the rights 29 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 30 | copies of the Software, and to permit persons to whom the Software is 31 | furnished to do so, subject to the following conditions: 32 | 33 | The above copyright notice and this permission notice shall be included in all 34 | copies or substantial portions of the Software. 35 | 36 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 37 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 38 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 39 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 40 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 41 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 42 | SOFTWARE. 43 | -------------------------------------------------------------------------------- /cordova-google-api-version.gradle: -------------------------------------------------------------------------------- 1 | repositories{ 2 | // Google APIs 11.2.* are now hosted at Maven 3 | maven { 4 | url 'https://maven.google.com' 5 | } 6 | } 7 | 8 | def PLUGIN_NAME = "cordova-google-api-version" 9 | 10 | // Fetch GOOGLE_API_VERSION var from properties.gradle 11 | apply from: PLUGIN_NAME + '/properties.gradle' 12 | 13 | // List of play-services libs to search for. 14 | def GOOGLE_APIS = [ 15 | 'com.google.android.gms', 16 | 'com.google.firebase' 17 | ] 18 | 19 | println("+-----------------------------------------------------------------"); 20 | println("| " + PLUGIN_NAME + ": " + GOOGLE_API_VERSION); 21 | println("+-----------------------------------------------------------------"); 22 | 23 | configurations.all { 24 | resolutionStrategy.eachDependency { DependencyResolveDetails details -> 25 | if (details.requested.group in GOOGLE_APIS) { details.useVersion GOOGLE_API_VERSION } 26 | } 27 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cordova-google-api-version", 3 | "version": "0.0.1", 4 | "description": "Cordova plugin to solve Google API version conflicts by pining a desired version for all Google APIs (eg: play-services, firebase)", 5 | "author": "Chris Scott, Transistor Software", 6 | "license": "MIT", 7 | "dependencies": { 8 | "xml2js": "~0.4.19" 9 | }, 10 | "devDependencies": {} 11 | } 12 | -------------------------------------------------------------------------------- /plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | cordova-google-api-version 8 | Cordova plugin to solve Google API version conflicts by pining a desired version for all Google APIs (eg: play-services, firebase) 9 | Chris Scott, Transistor Software 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /properties.gradle: -------------------------------------------------------------------------------- 1 | ext {GOOGLE_API_VERSION = "11.0.1"} -------------------------------------------------------------------------------- /scripts/before-prepare.js: -------------------------------------------------------------------------------- 1 | var fs = require ('fs'); 2 | var path = require('path'); 3 | var parser = require('xml2js'); 4 | 5 | const PLUGIN_NAME = "cordova-google-api-version"; 6 | const GRADLE_FILENAME = path.resolve(process.cwd(), 'platforms', 'android', PLUGIN_NAME, 'properties.gradle'); 7 | const PROPERTIES_TEMPLATE = 'ext {GOOGLE_API_VERSION = ""}' 8 | 9 | // 1. Parse cordova.xml file and fetch this plugin's 10 | fs.readFile(path.resolve(process.cwd(), 'config.xml'), function(err, data) { 11 | var json = parser.parseString(data, function(err, result) { 12 | if (err) { 13 | return console.log(PLUGIN_NAME, " ERROR: ", err); 14 | } 15 | var plugins = result.widget.plugin; 16 | for (var n=0,len=plugins.length;n in config.xml'); 21 | } 22 | // 2. Update .gradle file. 23 | setGradleGoogleApiVersion(plugin.variable.pop().$.value); 24 | break; 25 | } 26 | } 27 | }); 28 | }); 29 | 30 | /** 31 | * Write properties.gradle with: 32 | * 33 | ext { 34 | GOOGLE_API_VERSION = '' 35 | } 36 | * 37 | */ 38 | function setGradleGoogleApiVersion(version) { 39 | console.log(PLUGIN_NAME, " GOOGLE_API_VERSION: ", version); 40 | fs.writeFile(GRADLE_FILENAME, PROPERTIES_TEMPLATE.replace(//, version), 'utf8', function (err) { 41 | if (err) return console.log(PLUGIN_NAME, " FAILED TO WRITE ", GRADLE_FILENAME, " > ", GOOGLE_API_VERSION, err); 42 | }); 43 | } 44 | 45 | 46 | 47 | 48 | 49 | --------------------------------------------------------------------------------