Support build for 'Android Plugin for Gradle' versions lower than 1.3.0 (#651)

In case version of 'Android Plugin for Gradle'' is lower than 1.3.0
'$buildDir' has slightly different structure - 'merged' folder
does not exists so '${targetPath}' folder contains directly in 'res' folder.

Fix issue https://github.com/Microsoft/react-native-code-push/issues/584
This commit is contained in:
Sergey Akhalkov
2017-01-19 04:10:30 +03:00
committed by Richard Hua
parent 7572ddca61
commit 294b46cb0f
2 changed files with 17 additions and 1 deletions

View File

@@ -40,6 +40,14 @@ gradle.projectsEvaluated {
def resourcesDirConfigName = "jsBundleDir${targetName}"
def resourcesDir = elvisFile(config."${resourcesDirConfigName}") ?:
file("$buildDir/intermediates/res/merged/${targetPath}")
// In case version of 'Android Plugin for Gradle'' is lower than 1.3.0
// '$buildDir' has slightly different structure - 'merged' folder
// does not exists so '${targetPath}' folder contains directly in 'res' folder.
if (!resourcesDir.exists() && file("$buildDir/intermediates/res/${targetPath}").exists()) {
resourcesDir = file("$buildDir/intermediates/res/${targetPath}")
}
def jsBundleFile = file("$jsBundleDir/$bundleAssetName")
// Make this task run right before the bundle task

View File

@@ -16,7 +16,15 @@ var TEMP_FILE_PATH = path.join(require("os").tmpdir(), "CodePushResourcesMap.jso
var resourcesDir = process.argv[2];
var resourceFiles = [];
getFilesInFolder(resourcesDir, resourceFiles);
try {
getFilesInFolder(resourcesDir, resourceFiles);
} catch(error) {
var targetPathNotFoundExceptionMessage = "\nResources directory path does not exist.\n";
targetPathNotFoundExceptionMessage += "Unable to find '" + resourcesDir;
targetPathNotFoundExceptionMessage += "' directory. Please check version of Android Plugin for Gradle.";
error.message += targetPathNotFoundExceptionMessage;
throw error;
}
var fileToModifiedTimeMap = {};