mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 07:02:51 +08:00
[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>
This commit is contained in:
parent
e73000023b
commit
bd0c8ce639
@ -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];
|
||||
|
Loading…
Reference in New Issue
Block a user