2025-06-18 18:50:46 +02:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.handleCordovaPluginsGradle = exports.installGradlePlugins = exports.updateAndroid = void 0;
|
|
|
|
const tslib_1 = require("tslib");
|
|
|
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
2025-07-06 20:20:48 +02:00
|
|
|
const fs_extra_1 = require("fs-extra");
|
2025-06-18 18:50:46 +02:00
|
|
|
const path_1 = require("path");
|
|
|
|
const colors_1 = tslib_1.__importDefault(require("../colors"));
|
|
|
|
const common_1 = require("../common");
|
|
|
|
const cordova_1 = require("../cordova");
|
|
|
|
const errors_1 = require("../errors");
|
|
|
|
const plugin_1 = require("../plugin");
|
|
|
|
const copy_1 = require("../tasks/copy");
|
|
|
|
const migrate_1 = require("../tasks/migrate");
|
|
|
|
const fs_1 = require("../util/fs");
|
|
|
|
const node_1 = require("../util/node");
|
|
|
|
const template_1 = require("../util/template");
|
|
|
|
const common_2 = require("./common");
|
|
|
|
const platform = 'android';
|
|
|
|
const debug = (0, debug_1.default)('capacitor:android:update');
|
|
|
|
async function updateAndroid(config) {
|
2025-07-06 20:20:48 +02:00
|
|
|
var _a;
|
2025-06-18 18:50:46 +02:00
|
|
|
const plugins = await getPluginsTask(config);
|
2025-07-06 20:20:48 +02:00
|
|
|
const capacitorPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 0 /* PluginType.Core */);
|
2025-06-18 18:50:46 +02:00
|
|
|
(0, plugin_1.printPlugins)(capacitorPlugins, 'android');
|
|
|
|
await writePluginsJson(config, capacitorPlugins);
|
|
|
|
await removePluginsNativeFiles(config);
|
2025-07-06 20:20:48 +02:00
|
|
|
const cordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 1 /* PluginType.Cordova */);
|
2025-06-18 18:50:46 +02:00
|
|
|
await (0, migrate_1.patchOldCapacitorPlugins)(config);
|
|
|
|
if (cordovaPlugins.length > 0) {
|
|
|
|
await copyPluginsNativeFiles(config, cordovaPlugins);
|
|
|
|
}
|
2025-07-06 20:20:48 +02:00
|
|
|
if (!(await (0, fs_extra_1.pathExists)(config.android.webDirAbs))) {
|
2025-06-18 18:50:46 +02:00
|
|
|
await (0, copy_1.copy)(config, platform);
|
|
|
|
}
|
|
|
|
await (0, cordova_1.handleCordovaPluginsJS)(cordovaPlugins, config, platform);
|
2025-07-06 20:20:48 +02:00
|
|
|
await (0, cordova_1.checkPluginDependencies)(plugins, platform, (_a = config.app.extConfig.cordova) === null || _a === void 0 ? void 0 : _a.failOnUninstalledPlugins);
|
2025-06-18 18:50:46 +02:00
|
|
|
await installGradlePlugins(config, capacitorPlugins, cordovaPlugins);
|
|
|
|
await handleCordovaPluginsGradle(config, cordovaPlugins);
|
|
|
|
await (0, cordova_1.writeCordovaAndroidManifest)(cordovaPlugins, config, platform);
|
2025-07-06 20:20:48 +02:00
|
|
|
const incompatibleCordovaPlugins = plugins.filter((p) => (0, plugin_1.getPluginType)(p, platform) === 2 /* PluginType.Incompatible */);
|
2025-06-18 18:50:46 +02:00
|
|
|
(0, plugin_1.printPlugins)(incompatibleCordovaPlugins, platform, 'incompatible');
|
|
|
|
await (0, common_1.checkPlatformVersions)(config, platform);
|
|
|
|
}
|
|
|
|
exports.updateAndroid = updateAndroid;
|
|
|
|
function getGradlePackageName(id) {
|
|
|
|
return id.replace('@', '').replace('/', '-');
|
|
|
|
}
|
|
|
|
async function writePluginsJson(config, plugins) {
|
|
|
|
const classes = await findAndroidPluginClasses(plugins);
|
|
|
|
const pluginsJsonPath = (0, path_1.resolve)(config.android.assetsDirAbs, 'capacitor.plugins.json');
|
2025-07-06 20:20:48 +02:00
|
|
|
await (0, fs_extra_1.writeJSON)(pluginsJsonPath, classes, { spaces: '\t' });
|
2025-06-18 18:50:46 +02:00
|
|
|
}
|
|
|
|
async function findAndroidPluginClasses(plugins) {
|
|
|
|
const entries = [];
|
|
|
|
for (const plugin of plugins) {
|
|
|
|
entries.push(...(await findAndroidPluginClassesInPlugin(plugin)));
|
|
|
|
}
|
|
|
|
return entries;
|
|
|
|
}
|
|
|
|
async function findAndroidPluginClassesInPlugin(plugin) {
|
|
|
|
if (!plugin.android || (0, plugin_1.getPluginType)(plugin, platform) !== 0 /* PluginType.Core */) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
const srcPath = (0, path_1.resolve)(plugin.rootPath, plugin.android.path, 'src/main');
|
2025-07-06 20:20:48 +02:00
|
|
|
const srcFiles = await (0, fs_1.readdirp)(srcPath, {
|
|
|
|
filter: (entry) => !entry.stats.isDirectory() && ['.java', '.kt'].includes((0, path_1.extname)(entry.path)),
|
2025-06-18 18:50:46 +02:00
|
|
|
});
|
|
|
|
const classRegex = /^@(?:CapacitorPlugin|NativePlugin)[\s\S]+?class ([\w]+)/gm;
|
|
|
|
const packageRegex = /^package ([\w.]+);?$/gm;
|
|
|
|
debug('Searching %O source files in %O by %O regex', srcFiles.length, srcPath, classRegex);
|
|
|
|
const entries = await Promise.all(srcFiles.map(async (srcFile) => {
|
2025-07-06 20:20:48 +02:00
|
|
|
const srcFileContents = await (0, fs_extra_1.readFile)(srcFile, { encoding: 'utf-8' });
|
2025-06-18 18:50:46 +02:00
|
|
|
classRegex.lastIndex = 0;
|
|
|
|
const classMatch = classRegex.exec(srcFileContents);
|
|
|
|
if (classMatch) {
|
|
|
|
const className = classMatch[1];
|
|
|
|
debug('Searching %O for package by %O regex', srcFile, packageRegex);
|
|
|
|
packageRegex.lastIndex = 0;
|
|
|
|
const packageMatch = packageRegex.exec(srcFileContents.substring(0, classMatch.index));
|
|
|
|
if (!packageMatch) {
|
2025-07-06 20:20:48 +02:00
|
|
|
(0, errors_1.fatal)(`Package could not be parsed from Android plugin.\n` + `Location: ${colors_1.default.strong(srcFile)}`);
|
2025-06-18 18:50:46 +02:00
|
|
|
}
|
|
|
|
const packageName = packageMatch[1];
|
|
|
|
const classpath = `${packageName}.${className}`;
|
|
|
|
debug('%O is a suitable plugin class', classpath);
|
|
|
|
return {
|
|
|
|
pkg: plugin.id,
|
|
|
|
classpath,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
return entries.filter((entry) => !!entry);
|
|
|
|
}
|
|
|
|
async function installGradlePlugins(config, capacitorPlugins, cordovaPlugins) {
|
|
|
|
const capacitorAndroidPackagePath = (0, node_1.resolveNode)(config.app.rootDir, '@capacitor/android', 'package.json');
|
|
|
|
if (!capacitorAndroidPackagePath) {
|
|
|
|
(0, errors_1.fatal)(`Unable to find ${colors_1.default.strong('node_modules/@capacitor/android')}.\n` +
|
|
|
|
`Are you sure ${colors_1.default.strong('@capacitor/android')} is installed?`);
|
|
|
|
}
|
|
|
|
const capacitorAndroidPath = (0, path_1.resolve)((0, path_1.dirname)(capacitorAndroidPackagePath), 'capacitor');
|
|
|
|
const settingsPath = config.android.platformDirAbs;
|
|
|
|
const dependencyPath = config.android.appDirAbs;
|
|
|
|
const relativeCapcitorAndroidPath = (0, fs_1.convertToUnixPath)((0, path_1.relative)(settingsPath, capacitorAndroidPath));
|
|
|
|
const settingsLines = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
|
|
|
include ':capacitor-android'
|
|
|
|
project(':capacitor-android').projectDir = new File('${relativeCapcitorAndroidPath}')
|
|
|
|
${capacitorPlugins
|
2025-07-06 20:20:48 +02:00
|
|
|
.map((p) => {
|
2025-06-18 18:50:46 +02:00
|
|
|
if (!p.android) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
const relativePluginPath = (0, fs_1.convertToUnixPath)((0, path_1.relative)(settingsPath, p.rootPath));
|
|
|
|
return `
|
|
|
|
include ':${getGradlePackageName(p.id)}'
|
|
|
|
project(':${getGradlePackageName(p.id)}').projectDir = new File('${relativePluginPath}/${p.android.path}')
|
|
|
|
`;
|
|
|
|
})
|
|
|
|
.join('')}`;
|
|
|
|
const applyArray = [];
|
|
|
|
const frameworksArray = [];
|
|
|
|
let prefsArray = [];
|
2025-07-06 20:20:48 +02:00
|
|
|
cordovaPlugins.map((p) => {
|
2025-06-18 18:50:46 +02:00
|
|
|
const relativePluginPath = (0, fs_1.convertToUnixPath)((0, path_1.relative)(dependencyPath, p.rootPath));
|
|
|
|
const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
|
|
|
|
frameworks.map((framework) => {
|
|
|
|
if (framework.$.custom &&
|
|
|
|
framework.$.custom === 'true' &&
|
|
|
|
framework.$.type &&
|
|
|
|
framework.$.type === 'gradleReference') {
|
|
|
|
applyArray.push(`apply from: "${relativePluginPath}/${framework.$.src}"`);
|
|
|
|
}
|
|
|
|
else if (!framework.$.type && !framework.$.custom) {
|
|
|
|
if (framework.$.src.startsWith('platform(')) {
|
|
|
|
frameworksArray.push(` implementation ${framework.$.src}`);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
frameworksArray.push(` implementation "${framework.$.src}"`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
prefsArray = prefsArray.concat((0, plugin_1.getAllElements)(p, platform, 'preference'));
|
|
|
|
});
|
|
|
|
let frameworkString = frameworksArray.join('\n');
|
|
|
|
frameworkString = await replaceFrameworkVariables(config, prefsArray, frameworkString);
|
|
|
|
const dependencyLines = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
|
|
|
|
|
|
|
android {
|
|
|
|
compileOptions {
|
2025-07-06 20:20:48 +02:00
|
|
|
sourceCompatibility JavaVersion.VERSION_21
|
|
|
|
targetCompatibility JavaVersion.VERSION_21
|
2025-06-18 18:50:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
apply from: "../capacitor-cordova-android-plugins/cordova.variables.gradle"
|
|
|
|
dependencies {
|
|
|
|
${capacitorPlugins
|
2025-07-06 20:20:48 +02:00
|
|
|
.map((p) => {
|
2025-06-18 18:50:46 +02:00
|
|
|
return ` implementation project(':${getGradlePackageName(p.id)}')`;
|
|
|
|
})
|
|
|
|
.join('\n')}
|
|
|
|
${frameworkString}
|
|
|
|
}
|
|
|
|
${applyArray.join('\n')}
|
|
|
|
|
|
|
|
if (hasProperty('postBuildExtras')) {
|
|
|
|
postBuildExtras()
|
|
|
|
}
|
|
|
|
`;
|
2025-07-06 20:20:48 +02:00
|
|
|
await (0, fs_extra_1.writeFile)((0, path_1.join)(settingsPath, 'capacitor.settings.gradle'), settingsLines);
|
|
|
|
await (0, fs_extra_1.writeFile)((0, path_1.join)(dependencyPath, 'capacitor.build.gradle'), dependencyLines);
|
2025-06-18 18:50:46 +02:00
|
|
|
}
|
|
|
|
exports.installGradlePlugins = installGradlePlugins;
|
|
|
|
async function handleCordovaPluginsGradle(config, cordovaPlugins) {
|
|
|
|
var _a, _b, _c;
|
|
|
|
const pluginsGradlePath = (0, path_1.join)(config.android.cordovaPluginsDirAbs, 'build.gradle');
|
|
|
|
const kotlinNeeded = await kotlinNeededCheck(config, cordovaPlugins);
|
2025-07-06 20:20:48 +02:00
|
|
|
const kotlinVersionString = (_c = (_b = (_a = config.app.extConfig.cordova) === null || _a === void 0 ? void 0 : _a.preferences) === null || _b === void 0 ? void 0 : _b.GradlePluginKotlinVersion) !== null && _c !== void 0 ? _c : '1.9.25';
|
2025-06-18 18:50:46 +02:00
|
|
|
const frameworksArray = [];
|
|
|
|
let prefsArray = [];
|
|
|
|
const applyArray = [];
|
|
|
|
applyArray.push(`apply from: "cordova.variables.gradle"`);
|
2025-07-06 20:20:48 +02:00
|
|
|
cordovaPlugins.map((p) => {
|
2025-06-18 18:50:46 +02:00
|
|
|
const relativePluginPath = (0, fs_1.convertToUnixPath)((0, path_1.relative)(config.android.cordovaPluginsDirAbs, p.rootPath));
|
|
|
|
const frameworks = (0, plugin_1.getPlatformElement)(p, platform, 'framework');
|
|
|
|
frameworks.map((framework) => {
|
|
|
|
if (!framework.$.type && !framework.$.custom) {
|
|
|
|
frameworksArray.push(framework.$.src);
|
|
|
|
}
|
|
|
|
else if (framework.$.custom &&
|
|
|
|
framework.$.custom === 'true' &&
|
|
|
|
framework.$.type &&
|
|
|
|
framework.$.type === 'gradleReference') {
|
|
|
|
applyArray.push(`apply from: "${relativePluginPath}/${framework.$.src}"`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
prefsArray = prefsArray.concat((0, plugin_1.getAllElements)(p, platform, 'preference'));
|
|
|
|
});
|
|
|
|
let frameworkString = frameworksArray
|
2025-07-06 20:20:48 +02:00
|
|
|
.map((f) => {
|
2025-06-18 18:50:46 +02:00
|
|
|
if (f.startsWith('platform(')) {
|
|
|
|
return ` implementation ${f}`;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return ` implementation "${f}"`;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.join('\n');
|
|
|
|
frameworkString = await replaceFrameworkVariables(config, prefsArray, frameworkString);
|
|
|
|
if (kotlinNeeded) {
|
|
|
|
frameworkString += `\n implementation "androidx.core:core-ktx:$androidxCoreKTXVersion"`;
|
|
|
|
frameworkString += `\n implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"`;
|
|
|
|
}
|
|
|
|
const applyString = applyArray.join('\n');
|
2025-07-06 20:20:48 +02:00
|
|
|
let buildGradle = await (0, fs_extra_1.readFile)(pluginsGradlePath, { encoding: 'utf-8' });
|
2025-06-18 18:50:46 +02:00
|
|
|
buildGradle = buildGradle.replace(/(SUB-PROJECT DEPENDENCIES START)[\s\S]*(\/\/ SUB-PROJECT DEPENDENCIES END)/, '$1\n' + frameworkString.concat('\n') + ' $2');
|
|
|
|
buildGradle = buildGradle.replace(/(PLUGIN GRADLE EXTENSIONS START)[\s\S]*(\/\/ PLUGIN GRADLE EXTENSIONS END)/, '$1\n' + applyString.concat('\n') + '$2');
|
|
|
|
if (kotlinNeeded) {
|
|
|
|
buildGradle = buildGradle.replace(/(buildscript\s{\n(\t|\s{4})repositories\s{\n((\t{2}|\s{8}).+\n)+(\t|\s{4})}\n(\t|\s{4})dependencies\s{\n(\t{2}|\s{8}).+)\n((\t|\s{4})}\n}\n)/, `$1\n classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"\n$8`);
|
|
|
|
buildGradle = buildGradle.replace(/(ext\s{)/, `$1\n androidxCoreKTXVersion = project.hasProperty('androidxCoreKTXVersion') ? rootProject.ext.androidxCoreKTXVersion : '1.8.0'`);
|
|
|
|
buildGradle = buildGradle.replace(/(buildscript\s{)/, `$1\n ext.kotlin_version = project.hasProperty('kotlin_version') ? rootProject.ext.kotlin_version : '${kotlinVersionString}'`);
|
|
|
|
buildGradle = buildGradle.replace(/(apply\splugin:\s'com\.android\.library')/, `$1\napply plugin: 'kotlin-android'`);
|
|
|
|
buildGradle = buildGradle.replace(/(compileOptions\s{\n((\t{2}|\s{8}).+\n)+(\t|\s{4})})\n(})/, `$1\n sourceSets {\n main.java.srcDirs += 'src/main/kotlin'\n }\n$5`);
|
|
|
|
}
|
2025-07-06 20:20:48 +02:00
|
|
|
await (0, fs_extra_1.writeFile)(pluginsGradlePath, buildGradle);
|
2025-06-18 18:50:46 +02:00
|
|
|
const cordovaVariables = `// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
|
|
|
|
ext {
|
|
|
|
cdvMinSdkVersion = project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : ${config.android.minVersion}
|
|
|
|
// Plugin gradle extensions can append to this to have code run at the end.
|
|
|
|
cdvPluginPostBuildExtras = []
|
|
|
|
cordovaConfig = [:]
|
|
|
|
}`;
|
2025-07-06 20:20:48 +02:00
|
|
|
await (0, fs_extra_1.writeFile)((0, path_1.join)(config.android.cordovaPluginsDirAbs, 'cordova.variables.gradle'), cordovaVariables);
|
2025-06-18 18:50:46 +02:00
|
|
|
}
|
|
|
|
exports.handleCordovaPluginsGradle = handleCordovaPluginsGradle;
|
|
|
|
async function kotlinNeededCheck(config, cordovaPlugins) {
|
|
|
|
var _a, _b;
|
2025-07-06 20:20:48 +02:00
|
|
|
if (((_b = (_a = config.app.extConfig.cordova) === null || _a === void 0 ? void 0 : _a.preferences) === null || _b === void 0 ? void 0 : _b.GradlePluginKotlinEnabled) !== 'true') {
|
2025-06-18 18:50:46 +02:00
|
|
|
for (const plugin of cordovaPlugins) {
|
|
|
|
const androidPlatform = (0, plugin_1.getPluginPlatform)(plugin, platform);
|
|
|
|
const sourceFiles = androidPlatform['source-file'];
|
|
|
|
if (sourceFiles) {
|
|
|
|
for (const srcFile of sourceFiles) {
|
|
|
|
if (/^.*\.kt$/.test(srcFile['$'].src)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async function copyPluginsNativeFiles(config, cordovaPlugins) {
|
|
|
|
const pluginsPath = (0, path_1.join)(config.android.cordovaPluginsDirAbs, 'src', 'main');
|
|
|
|
for (const p of cordovaPlugins) {
|
|
|
|
const androidPlatform = (0, plugin_1.getPluginPlatform)(p, platform);
|
|
|
|
if (androidPlatform) {
|
|
|
|
const sourceFiles = androidPlatform['source-file'];
|
|
|
|
if (sourceFiles) {
|
|
|
|
for (const sourceFile of sourceFiles) {
|
|
|
|
const fileName = sourceFile.$.src.split('/').pop();
|
|
|
|
let baseFolder = 'java/';
|
|
|
|
if (fileName.split('.').pop() === 'aidl') {
|
|
|
|
baseFolder = 'aidl/';
|
|
|
|
}
|
2025-07-06 20:20:48 +02:00
|
|
|
const target = sourceFile.$['target-dir'].replace('app/src/main/', '').replace('src/', baseFolder);
|
|
|
|
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, sourceFile.$.src), (0, path_1.join)(pluginsPath, target, fileName));
|
2025-06-18 18:50:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
const resourceFiles = androidPlatform['resource-file'];
|
|
|
|
if (resourceFiles) {
|
|
|
|
for (const resourceFile of resourceFiles) {
|
|
|
|
const target = resourceFile.$['target'];
|
|
|
|
if (resourceFile.$.src.split('.').pop() === 'aar') {
|
2025-07-06 20:20:48 +02:00
|
|
|
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(pluginsPath, 'libs', target.split('/').pop()));
|
2025-06-18 18:50:46 +02:00
|
|
|
}
|
|
|
|
else if (target !== '.') {
|
2025-07-06 20:20:48 +02:00
|
|
|
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, resourceFile.$.src), (0, path_1.join)(pluginsPath, target));
|
2025-06-18 18:50:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const libFiles = (0, plugin_1.getPlatformElement)(p, platform, 'lib-file');
|
|
|
|
for (const libFile of libFiles) {
|
2025-07-06 20:20:48 +02:00
|
|
|
await (0, fs_extra_1.copy)((0, plugin_1.getFilePath)(config, p, libFile.$.src), (0, path_1.join)(pluginsPath, 'libs', libFile.$.src.split('/').pop()));
|
2025-06-18 18:50:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async function removePluginsNativeFiles(config) {
|
2025-07-06 20:20:48 +02:00
|
|
|
await (0, fs_extra_1.remove)(config.android.cordovaPluginsDirAbs);
|
2025-06-18 18:50:46 +02:00
|
|
|
await (0, template_1.extractTemplate)(config.cli.assets.android.cordovaPluginsTemplateArchiveAbs, config.android.cordovaPluginsDirAbs);
|
|
|
|
}
|
|
|
|
async function getPluginsTask(config) {
|
|
|
|
return await (0, common_1.runTask)('Updating Android plugins', async () => {
|
|
|
|
const allPlugins = await (0, plugin_1.getPlugins)(config, 'android');
|
|
|
|
const androidPlugins = await (0, common_2.getAndroidPlugins)(allPlugins);
|
|
|
|
return androidPlugins;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
async function getVariablesGradleFile(config) {
|
|
|
|
const variablesFile = (0, path_1.resolve)(config.android.platformDirAbs, 'variables.gradle');
|
|
|
|
let variablesGradle = '';
|
2025-07-06 20:20:48 +02:00
|
|
|
if (await (0, fs_extra_1.pathExists)(variablesFile)) {
|
|
|
|
variablesGradle = await (0, fs_extra_1.readFile)(variablesFile, { encoding: 'utf-8' });
|
2025-06-18 18:50:46 +02:00
|
|
|
}
|
|
|
|
return variablesGradle;
|
|
|
|
}
|
|
|
|
async function replaceFrameworkVariables(config, prefsArray, frameworkString) {
|
|
|
|
const variablesGradle = await getVariablesGradleFile(config);
|
|
|
|
prefsArray.map((preference) => {
|
|
|
|
if (!variablesGradle.includes(preference.$.name)) {
|
|
|
|
frameworkString = frameworkString.replace(new RegExp(('$' + preference.$.name).replace('$', '\\$&'), 'g'), preference.$.default);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return frameworkString;
|
|
|
|
}
|