erisu commented on a change in pull request #1212:
URL: https://github.com/apache/cordova-android/pull/1212#discussion_r663656740
##########
File path: bin/templates/cordova/lib/prepare.js
##########
@@ -92,6 +76,76 @@ module.exports.prepare = function (cordovaProject, options) {
});
};
+function updateUserProjectGradleConfig (configXml, defaultGradleConfigPath,
projectGradleConfigPath) {
+ const defaultGradleConfig = fs.readJSONSync(defaultGradleConfigPath);
+ const profileGradleConfig = fs.readJSONSync(projectGradleConfigPath);
+
+ // Replace modified configs with defaults
+ const mergedConfigs = Object.assign(profileGradleConfig,
defaultGradleConfig);
+
+ const configXmlToGradleMapping = [
+ { xmlKey: 'android-minSdkVersion', gradleKey: 'MIN_SDK_VERSION', type:
Number },
+ { xmlKey: 'android-maxSdkVersion', gradleKey: 'MAX_SDK_VERSION',
default: null, type: Number },
+ { xmlKey: 'android-targetSdkVersion', gradleKey: 'SDK_VERSION', type:
Number },
+ { xmlKey: 'android-buildToolsVersion', gradleKey:
'BUILD_TOOLS_VERSION', type: String },
+ { xmlKey: 'GradleVersion', gradleKey: 'GRADLE_VERSION', type: String },
+ { xmlKey: 'AndroidGradlePluginVersion', gradleKey: 'AGP_VERSION',
type: String },
+ { xmlKey: 'GradlePluginKotlinVersion', gradleKey: 'KOTLIN_VERSION',
type: String },
+ { xmlKey: 'AndroidXAppCompatVersion', gradleKey:
'ANDROIDX_APP_COMPAT_VERSION', type: String },
+ { xmlKey: 'GradlePluginGoogleServicesVersion', gradleKey:
'GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION', type: String },
+ { xmlKey: 'GradlePluginGoogleServicesEnabled', gradleKey:
'IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED', type: Boolean },
+ { xmlKey: 'GradlePluginKotlinEnabled', gradleKey:
'IS_GRADLE_PLUGIN_KOTLIN_ENABLED', type: Boolean }
+ ];
+
+ configXmlToGradleMapping.forEach(mapping => {
+ const configXmlValue = configXml.getPreference(mapping.xmlKey,
'android');
+
+ if (Object.prototype.hasOwnProperty.call(mapping, 'default')) {
+ if (configXmlValue || typeof configXmlValue === 'boolean') {
Review comment:
Changed the code like so:
https://github.com/apache/cordova-android/pull/1212/commits/4b7ac21d3de28486fa3419383514a69e56b3e6ef
##########
File path: bin/templates/cordova/lib/prepare.js
##########
@@ -92,6 +76,76 @@ module.exports.prepare = function (cordovaProject, options) {
});
};
+function updateUserProjectGradleConfig (configXml, defaultGradleConfigPath,
projectGradleConfigPath) {
+ const defaultGradleConfig = fs.readJSONSync(defaultGradleConfigPath);
+ const profileGradleConfig = fs.readJSONSync(projectGradleConfigPath);
+
+ // Replace modified configs with defaults
+ const mergedConfigs = Object.assign(profileGradleConfig,
defaultGradleConfig);
+
+ const configXmlToGradleMapping = [
+ { xmlKey: 'android-minSdkVersion', gradleKey: 'MIN_SDK_VERSION', type:
Number },
+ { xmlKey: 'android-maxSdkVersion', gradleKey: 'MAX_SDK_VERSION',
default: null, type: Number },
+ { xmlKey: 'android-targetSdkVersion', gradleKey: 'SDK_VERSION', type:
Number },
+ { xmlKey: 'android-buildToolsVersion', gradleKey:
'BUILD_TOOLS_VERSION', type: String },
+ { xmlKey: 'GradleVersion', gradleKey: 'GRADLE_VERSION', type: String },
+ { xmlKey: 'AndroidGradlePluginVersion', gradleKey: 'AGP_VERSION',
type: String },
+ { xmlKey: 'GradlePluginKotlinVersion', gradleKey: 'KOTLIN_VERSION',
type: String },
+ { xmlKey: 'AndroidXAppCompatVersion', gradleKey:
'ANDROIDX_APP_COMPAT_VERSION', type: String },
+ { xmlKey: 'GradlePluginGoogleServicesVersion', gradleKey:
'GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION', type: String },
+ { xmlKey: 'GradlePluginGoogleServicesEnabled', gradleKey:
'IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED', type: Boolean },
+ { xmlKey: 'GradlePluginKotlinEnabled', gradleKey:
'IS_GRADLE_PLUGIN_KOTLIN_ENABLED', type: Boolean }
+ ];
+
+ configXmlToGradleMapping.forEach(mapping => {
+ const configXmlValue = configXml.getPreference(mapping.xmlKey,
'android');
+
+ if (Object.prototype.hasOwnProperty.call(mapping, 'default')) {
+ if (configXmlValue || typeof configXmlValue === 'boolean') {
Review comment:
Code updated here:
https://github.com/apache/cordova-android/pull/1212/commits/4b7ac21d3de28486fa3419383514a69e56b3e6ef
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]