Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 294b46c

Browse files
sergey-akhalkovRichard Hua
authored andcommitted
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 #584
1 parent 7572ddc commit 294b46c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

android/codepush.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ gradle.projectsEvaluated {
4040
def resourcesDirConfigName = "jsBundleDir${targetName}"
4141
def resourcesDir = elvisFile(config."${resourcesDirConfigName}") ?:
4242
file("$buildDir/intermediates/res/merged/${targetPath}")
43+
44+
// In case version of 'Android Plugin for Gradle'' is lower than 1.3.0
45+
// '$buildDir' has slightly different structure - 'merged' folder
46+
// does not exists so '${targetPath}' folder contains directly in 'res' folder.
47+
if (!resourcesDir.exists() && file("$buildDir/intermediates/res/${targetPath}").exists()) {
48+
resourcesDir = file("$buildDir/intermediates/res/${targetPath}")
49+
}
50+
4351
def jsBundleFile = file("$jsBundleDir/$bundleAssetName")
4452

4553
// Make this task run right before the bundle task

scripts/recordFilesBeforeBundleCommand.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,15 @@ var TEMP_FILE_PATH = path.join(require("os").tmpdir(), "CodePushResourcesMap.jso
1616
var resourcesDir = process.argv[2];
1717
var resourceFiles = [];
1818

19-
getFilesInFolder(resourcesDir, resourceFiles);
19+
try {
20+
getFilesInFolder(resourcesDir, resourceFiles);
21+
} catch(error) {
22+
var targetPathNotFoundExceptionMessage = "\nResources directory path does not exist.\n";
23+
targetPathNotFoundExceptionMessage += "Unable to find '" + resourcesDir;
24+
targetPathNotFoundExceptionMessage += "' directory. Please check version of Android Plugin for Gradle.";
25+
error.message += targetPathNotFoundExceptionMessage;
26+
throw error;
27+
}
2028

2129
var fileToModifiedTimeMap = {};
2230

0 commit comments

Comments
 (0)