Skip to content

Commit d30b2ff

Browse files
Replace plugin variables in all Android .xml files
In case a plugin has plugin variable, during project preparation CLI replaces the usage of the variable in plugin's AndroidManifest with the value set in the current project's package.json. This is not enough, we have to set the variables in all plugin's .xml files, so the value could be used in resource and later read from the JAVA code. Enumarate plugin's files and replace plugin variables in all .xml files.
1 parent 5f3be6e commit d30b2ff

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

lib/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export var LIVESYNC_EXCLUDED_DIRECTORIES = ["app_resources"];
1515
export var TESTING_FRAMEWORKS = ['jasmine', 'mocha', 'qunit'];
1616
export let TEST_RUNNER_NAME = "nativescript-unit-test-runner";
1717
export let LIVESYNC_EXCLUDED_FILE_PATTERNS = ["**/*.js.map", "**/*.ts"];
18+
export let XML_FILE_EXTENSION = ".xml";
1819

1920
export class ReleaseType {
2021
static MAJOR = "major";

lib/services/android-project-service.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,11 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
327327
this.$fs.ensureDirectoryExists(resourcesDestinationDirectoryPath).wait();
328328
shell.cp("-Rf", path.join(pluginPlatformsFolderPath, "*"), resourcesDestinationDirectoryPath);
329329

330-
let pluginConfigurationFilePath = path.join(resourcesDestinationDirectoryPath, this.platformData.configurationFileName);
331-
if (this.$fs.exists(pluginConfigurationFilePath).wait()) {
332-
this.$pluginVariablesService.interpolate(pluginData, pluginConfigurationFilePath).wait();
333-
}
330+
(this.$fs.enumerateFilesInDirectorySync(resourcesDestinationDirectoryPath, file => this.$fs.getFsStats(file).wait().isDirectory() || path.extname(file) === constants.XML_FILE_EXTENSION) || [])
331+
.forEach(file => {
332+
this.$logger.trace(`Interpolate data for plugin file: ${file}`);
333+
this.$pluginVariablesService.interpolate(pluginData, file).wait();
334+
});
334335
}
335336

336337
// Copy include.gradle file

lib/xml-validator.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"use strict";
33

44
import { EOL } from "os";
5+
import * as constants from "./constants";
56

67
export class XmlValidator implements IXmlValidator {
78
constructor(private $fs: IFileSystem,
@@ -11,7 +12,7 @@ export class XmlValidator implements IXmlValidator {
1112
return (() => {
1213
let xmlHasErrors = false;
1314
sourceFiles
14-
.filter(file => _.endsWith(file, ".xml"))
15+
.filter(file => _.endsWith(file, constants.XML_FILE_EXTENSION))
1516
.forEach(file => {
1617
let errorOutput = this.getXmlFileErrors(file).wait();
1718
let hasErrors = !!errorOutput;

0 commit comments

Comments
 (0)