mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
parent
08c80f77a9
commit
0df50c3f33
40
bin/templates/cordova/lib/prepare.js
vendored
40
bin/templates/cordova/lib/prepare.js
vendored
@ -48,6 +48,7 @@ module.exports.prepare = function (cordovaProject, options) {
|
|||||||
.then(function () {
|
.then(function () {
|
||||||
updateIcons(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
|
updateIcons(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
|
||||||
updateSplashes(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
|
updateSplashes(cordovaProject, path.relative(cordovaProject.root, self.locations.res));
|
||||||
|
updateFileResources(cordovaProject, path.relative(cordovaProject.root, self.locations.root));
|
||||||
})
|
})
|
||||||
.then(function () {
|
.then(function () {
|
||||||
events.emit('verbose', 'Prepared android project successfully');
|
events.emit('verbose', 'Prepared android project successfully');
|
||||||
@ -72,6 +73,7 @@ module.exports.clean = function (options) {
|
|||||||
cleanWww(projectRoot, self.locations);
|
cleanWww(projectRoot, self.locations);
|
||||||
cleanIcons(projectRoot, projectConfig, path.relative(projectRoot, self.locations.res));
|
cleanIcons(projectRoot, projectConfig, path.relative(projectRoot, self.locations.res));
|
||||||
cleanSplashes(projectRoot, projectConfig, path.relative(projectRoot, self.locations.res));
|
cleanSplashes(projectRoot, projectConfig, path.relative(projectRoot, self.locations.res));
|
||||||
|
cleanFileResources(projectRoot, projectConfig, path.relative(projectRoot, self.locations.root));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -401,6 +403,44 @@ function mapImageResources(rootDir, subDir, type, resourceName) {
|
|||||||
return pathMap;
|
return pathMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function updateFileResources(cordovaProject, platformDir) {
|
||||||
|
var files = cordovaProject.projectConfig.getFileResources('android');
|
||||||
|
|
||||||
|
// if there are resource-file elements in config.xml
|
||||||
|
if (files.length === 0) {
|
||||||
|
events.emit('verbose', 'This app does not have additional resource files defined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var resourceMap = {};
|
||||||
|
files.forEach(function(res) {
|
||||||
|
var targetPath = path.join(platformDir, res.target);
|
||||||
|
resourceMap[targetPath] = res.src;
|
||||||
|
});
|
||||||
|
|
||||||
|
events.emit('verbose', 'Updating resource files at ' + platformDir);
|
||||||
|
FileUpdater.updatePaths(
|
||||||
|
resourceMap, { rootDir: cordovaProject.root }, logFileOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function cleanFileResources(projectRoot, projectConfig, platformDir) {
|
||||||
|
var files = projectConfig.getFileResources('android');
|
||||||
|
if (files.length > 0) {
|
||||||
|
events.emit('verbose', 'Cleaning resource files at ' + platformDir);
|
||||||
|
|
||||||
|
var resourceMap = {};
|
||||||
|
files.forEach(function(res) {
|
||||||
|
var filePath = path.join(platformDir, res.target);
|
||||||
|
resourceMap[filePath] = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
FileUpdater.updatePaths(
|
||||||
|
resourceMap, { rootDir: projectRoot, all: true}, logFileOp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets and validates 'AndroidLaunchMode' prepference from config.xml. Returns
|
* Gets and validates 'AndroidLaunchMode' prepference from config.xml. Returns
|
||||||
* preference value and warns if it doesn't seems to be valid
|
* preference value and warns if it doesn't seems to be valid
|
||||||
|
Loading…
Reference in New Issue
Block a user