Skip to content
Permalink
Browse files
[Android] Added support for BoM imports (#1311)
* Added support for BoM imports

https://docs.gradle.org/current/userguide/platforms.html#sub:bom_import

Changes

* propertiesObj.systemLibs regex - exclude the value contains (
* added propertiesObj.bomPlatforms - any value which matches platform("...")

* Fix eslint style issues

Co-authored-by: 8bhsolutions <48874658+8bhsolutions@users.noreply.github.com>
  • Loading branch information
ebhsgit and ebhsgit committed May 18, 2022
1 parent e730000 commit bd0c8ce6398be2f3c005787dc383d4c98677b635
Showing 1 changed file with 15 additions and 1 deletion.
@@ -140,7 +140,8 @@ class ProjectBuilder {
return {
libs: findAllUniq(data, /^\s*android\.library\.reference\.\d+=(.*)(?:\s|$)/mg),
gradleIncludes: findAllUniq(data, /^\s*cordova\.gradle\.include\.\d+=(.*)(?:\s|$)/mg),
systemLibs: findAllUniq(data, /^\s*cordova\.system\.library\.\d+=(.*)(?:\s|$)/mg)
systemLibs: findAllUniq(data, /^\s*cordova\.system\.library\.\d+=((?!.*\().*)(?:\s|$)/mg),
bomPlatforms: findAllUniq(data, /^\s*cordova\.system\.library\.\d+=platform\((?:'|")(.*)(?:'|")\)/mg)
};
}

@@ -234,11 +235,24 @@ class ProjectBuilder {
[/^\/?google\/google_play_services\/libproject\/google-play-services_lib\/?$/, 'com.google.android.gms:play-services:+']
];

propertiesObj.bomPlatforms.forEach(function (p) {
if (!/:.*:/.exec(p)) {
throw new CordovaError('Malformed BoM platform: ' + p);
}

// Add bom platform
depsList += ' implementation platform("' + p + '")\n';
});

propertiesObj.systemLibs.forEach(function (p) {
let mavenRef;
// It's already in gradle form if it has two ':'s
if (/:.*:/.exec(p)) {
mavenRef = p;
} else if (/:.*/.exec(p)) {
// Support BoM imports
mavenRef = p;
events.emit('warn', 'Library expects a BoM package: ' + p);
} else {
for (let i = 0; i < SYSTEM_LIBRARY_MAPPINGS.length; ++i) {
const pair = SYSTEM_LIBRARY_MAPPINGS[i];

0 comments on commit bd0c8ce

Please sign in to comment.