aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android/ApkActionsBuilder.java
diff options
context:
space:
mode:
authorGravatar Adam Michael <ajmichael@google.com>2016-10-27 19:41:26 +0000
committerGravatar John Cater <jcater@google.com>2016-10-28 16:02:35 +0000
commite5788617934ee28ce1cdcd096e620ab9e7c2f37f (patch)
tree8000ff9868ed0c59c2a049b5299286f7249eb674 /src/main/java/com/google/devtools/build/lib/rules/android/ApkActionsBuilder.java
parent43e5d3bf426125c3dd413234d7b23a4228d22ff1 (diff)
Singlejar apkbuilder now puts resources in the correct location in APK.
This was a bug that only affected builds with a single classes.dex. -- MOS_MIGRATED_REVID=137427786
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android/ApkActionsBuilder.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/ApkActionsBuilder.java37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/ApkActionsBuilder.java b/src/main/java/com/google/devtools/build/lib/rules/android/ApkActionsBuilder.java
index a3b6710f9b..0471854f9f 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/ApkActionsBuilder.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/ApkActionsBuilder.java
@@ -268,15 +268,23 @@ public class ApkActionsBuilder {
.addInputArgument(classesDex);
} else {
compressedApkActionBuilder
+ .addInput(classesDex)
.addArgument("--resources")
- .addInputArgument(classesDex);
+ .addArgument(
+ singleJarResourcesArgument(
+ classesDex.getExecPathString(),
+ classesDex.getFilename()));
}
}
if (javaResourceFile != null) {
compressedApkActionBuilder
+ .addInput(javaResourceFile)
.addArgument("--resources")
- .addInputArgument(javaResourceFile);
+ .addArgument(
+ singleJarResourcesArgument(
+ javaResourceFile.getExecPathString(),
+ javaResourceFile.getFilename()));
}
for (String architecture : nativeLibs.getMap().keySet()) {
@@ -284,11 +292,9 @@ public class ApkActionsBuilder {
compressedApkActionBuilder
.addArgument("--resources")
.addArgument(
- nativeLib.getExecPathString()
- + ":lib/"
- + architecture
- + "/"
- + nativeLib.getFilename())
+ singleJarResourcesArgument(
+ nativeLib.getExecPathString(),
+ "lib/" + architecture + "/" + nativeLib.getFilename()))
.addInput(nativeLib);
}
}
@@ -328,7 +334,9 @@ public class ApkActionsBuilder {
singleJarActionBuilder
.addArgument("--resources")
.addArgument(
- nativeLibs.getName().getExecPathString() + ":" + nativeLibs.getName().getFilename())
+ singleJarResourcesArgument(
+ nativeLibs.getName().getExecPathString(),
+ nativeLibs.getName().getFilename()))
.addInput(nativeLibs.getName());
}
@@ -349,6 +357,19 @@ public class ApkActionsBuilder {
ruleContext.registerAction(singleJarActionBuilder.build(ruleContext));
}
+ /**
+ * The --resources flag to singlejar can have either of the following forms:
+ * <ul>
+ * <li>The path to the input file. In this case the file is placed at the same path in the APK.
+ * <li>{@code from}:{@code to} where {@code from} is that path to the input file and {@code to} is
+ * the location in the APK to put it.
+ * </ul>
+ * This method creates the syntax for the second form.
+ */
+ private static String singleJarResourcesArgument(String from, String to) {
+ return from + ":" + to;
+ }
+
/** Uses the zipalign tool to align the zip boundaries for uncompressed resources by 4 bytes. */
private void zipalignApk(RuleContext ruleContext, Artifact inputApk, Artifact zipAlignedApk) {
ruleContext.registerAction(new SpawnAction.Builder()