aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ajmichael <ajmichael@google.com>2017-12-01 13:25:19 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-12-01 13:27:27 -0800
commit6a5669a9b00ed4113ee3945c4a74c35c17a70728 (patch)
tree277156f41b9a0bbe925967e28ec3066871d58c3e
parent062da5cbb5848dbfa1cf8bae028b06313a84ef0d (diff)
Make AndroidSdkProvider.verifyPresence throw.
All call sites were just returning null if it failed anyways. RELNOTES: None PiperOrigin-RevId: 177632366
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidBinary.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidLibrary.java4
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkProvider.java10
4 files changed, 7 insertions, 15 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java b/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java
index 20fdf493e0..5067f30e75 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AarImport.java
@@ -63,9 +63,7 @@ public class AarImport implements RuleConfiguredTargetFactory {
@Override
public ConfiguredTarget create(RuleContext ruleContext)
throws InterruptedException, RuleErrorException {
- if (!AndroidSdkProvider.verifyPresence(ruleContext)) {
- return null;
- }
+ AndroidSdkProvider.verifyPresence(ruleContext);
RuleConfiguredTargetBuilder ruleBuilder = new RuleConfiguredTargetBuilder(ruleContext);
Artifact aar = ruleContext.getPrerequisiteArtifact("aar", Mode.TARGET);
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 d806620b12..b3044d3f0e 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
@@ -101,9 +101,7 @@ public abstract class AndroidBinary implements RuleConfiguredTargetFactory {
CppSemantics cppSemantics = createCppSemantics();
JavaSemantics javaSemantics = createJavaSemantics();
AndroidSemantics androidSemantics = createAndroidSemantics();
- if (!AndroidSdkProvider.verifyPresence(ruleContext)) {
- return null;
- }
+ AndroidSdkProvider.verifyPresence(ruleContext);
NestedSetBuilder<Artifact> filesBuilder = NestedSetBuilder.stableOrder();
JavaCommon javaCommon =
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 d5bd4cb0b6..480b4a6ab2 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
@@ -175,9 +175,7 @@ public abstract class AndroidLibrary implements RuleConfiguredTargetFactory {
validateRuleContext(ruleContext);
JavaSemantics javaSemantics = createJavaSemantics();
AndroidSemantics androidSemantics = createAndroidSemantics();
- if (!AndroidSdkProvider.verifyPresence(ruleContext)) {
- return null;
- }
+ AndroidSdkProvider.verifyPresence(ruleContext);
checkResourceInlining(ruleContext);
NestedSetBuilder<Aar> transitiveAars = NestedSetBuilder.naiveLinkOrder();
NestedSetBuilder<Artifact> transitiveAarArtifacts = NestedSetBuilder.stableOrder();
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkProvider.java
index 2b662a9b1f..741f17d23a 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdkProvider.java
@@ -21,6 +21,7 @@ import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
+import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException;
import javax.annotation.Nullable;
/** Description of the tools Blaze needs from an Android SDK. */
@@ -83,16 +84,13 @@ public abstract class AndroidSdkProvider implements TransitiveInfoProvider {
}
/**
- * Signals an error if the Android SDK cannot be found.
+ * Throws an error if the Android SDK cannot be found.
*/
- public static boolean verifyPresence(RuleContext ruleContext) {
+ public static void verifyPresence(RuleContext ruleContext) throws RuleErrorException {
if (fromRuleContext(ruleContext) == null) {
- ruleContext.ruleError(
+ throw ruleContext.throwWithRuleError(
"No Android SDK found. Use the --android_sdk command line option to specify one.");
- return false;
}
-
- return true;
}
/** The value of build_tools_version. May be null or empty. */