aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules/android
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2015-11-23 11:53:58 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2015-11-24 14:40:41 +0000
commit2419e6469b6c1f1e4ebbc0f05e1b5f33292f692d (patch)
treebfa63ea61cd383e10f1672ae99f87f3de0847e5b /src/main/java/com/google/devtools/build/lib/rules/android
parent7f5834d41233830814f8748a6b126e74f297c013 (diff)
Require that the Android manifest be called AndroidManifest.xml
aapt requires this. Also eliminate a few places where the unchecked RuleConfigurationException is thrown. -- MOS_MIGRATED_REVID=108491660
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/android')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java23
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java4
2 files changed, 19 insertions, 8 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
index 301b509478..6c89ea7e4c 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java
@@ -197,10 +197,14 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
if (LocalResourceContainer.definesAndroidResources(ruleContext.attributes())) {
// Retrieve and compile the resources defined on the android_binary rule.
if (!LocalResourceContainer.validateRuleContext(ruleContext)) {
- throw new RuleConfigurationException();
+ return null;
+ }
+ ApplicationManifest ruleManifest = androidSemantics.getManifestForRule(ruleContext);
+ if (ruleManifest == null) {
+ return null;
}
- applicationManifest = androidSemantics.getManifestForRule(ruleContext)
- .mergeWith(ruleContext, resourceDeps);
+
+ applicationManifest = ruleManifest.mergeWith(ruleContext, resourceDeps);
resourceApk = applicationManifest.packWithDataAndResources(
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_APK),
ruleContext,
@@ -352,6 +356,9 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
jarToDex,
androidCommon,
resourceClasses);
+ if (dexingOutput == null) {
+ return null;
+ }
Artifact unsignedApk =
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_BINARY_UNSIGNED_APK);
@@ -914,21 +921,21 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
}
/** Dexes the ProguardedJar to generate ClassesDex that has a reference classes.dex. */
- static DexingOutput dex(RuleContext ruleContext, MultidexMode multidexMode, List<String> dexopts,
- Artifact deployJar, Artifact proguardedJar, AndroidCommon common,
+ private static DexingOutput dex(RuleContext ruleContext, MultidexMode multidexMode,
+ List<String> dexopts, Artifact deployJar, Artifact proguardedJar, AndroidCommon common,
JavaTargetAttributes attributes) throws InterruptedException {
String classesDexFileName = getMultidexMode(ruleContext).getOutputDexFilename();
Artifact classesDex = AndroidBinary.getDxArtifact(ruleContext, classesDexFileName);
if (!AndroidBinary.supportsMultidexMode(ruleContext, multidexMode)) {
ruleContext.ruleError("Multidex mode \"" + multidexMode.getAttributeValue()
+ "\" not supported by this version of the Android SDK");
- throw new RuleConfigurationException();
+ return null;
}
int dexShards = ruleContext.attributes().get("dex_shards", Type.INTEGER);
if (dexShards > 1 && multidexMode == MultidexMode.OFF) {
ruleContext.ruleError(".dex sharding is only available in multidex mode");
- throw new RuleConfigurationException();
+ return null;
}
Artifact mainDexList = ruleContext.getPrerequisiteArtifact("main_dex_list", Mode.TARGET);
@@ -936,7 +943,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
|| (mainDexList == null && multidexMode == MultidexMode.MANUAL_MAIN_DEX)) {
ruleContext.ruleError(
"Both \"main_dex_list\" and \"multidex='manual_main_dex'\" must be specified.");
- throw new RuleConfigurationException();
+ return null;
}
if (multidexMode == MultidexMode.OFF) {
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
index 5abce9af36..3474032759 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java
@@ -80,6 +80,9 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory {
final ResourceApk resourceApk;
if (definesLocalResources) {
ApplicationManifest applicationManifest = androidSemantics.getManifestForRule(ruleContext);
+ if (applicationManifest == null) {
+ return null;
+ }
try {
resourceApk = applicationManifest.packWithDataAndResources(
ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_RESOURCES_APK),
@@ -125,6 +128,7 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory {
final Aar aar;
if (definesLocalResources) {
primaryResources = resourceApk.getPrimaryResource();
+ // applicationManifest has already been checked for nullness above in this method
ApplicationManifest applicationManifest = androidSemantics.getManifestForRule(ruleContext);
aar = new Aar(aarOut, applicationManifest.getManifest());
transitiveAars.add(aar);