diff options
author | 2018-02-22 17:11:24 -0800 | |
---|---|---|
committer | 2018-02-22 17:13:53 -0800 | |
commit | ec77ac96f18bd2cc230f37768130cb215475177f (patch) | |
tree | 37312431546258a0edfe62f2f35127df117fc115 /src/main/java/com/google/devtools/build/lib/rules | |
parent | b2a9e786e880a7afb942951c45ff0851e2a9cb52 (diff) |
Add warning that android_robolectric_test is deprecated in favor of android_local_test.
RELNOTES: None
PiperOrigin-RevId: 186699885
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java index b988dfa566..ceaf10cc9b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java @@ -35,6 +35,7 @@ import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; import com.google.devtools.build.lib.packages.AggregatingAttributeMapper; import com.google.devtools.build.lib.packages.RuleClass.ConfiguredTargetFactory.RuleErrorException; import com.google.devtools.build.lib.packages.Target; +import com.google.devtools.build.lib.rules.android.AndroidConfiguration.AndroidAaptVersion.AndroidRobolectricTestDeprecationLevel; import com.google.devtools.build.lib.rules.cpp.CppConfiguration.DynamicMode; import com.google.devtools.build.lib.rules.cpp.CppOptions.DynamicModeConverter; import com.google.devtools.build.lib.rules.cpp.CppOptions.LibcTopLabelConverter; @@ -96,6 +97,14 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { } } + /** Converter for {@link AndroidRobolectricTestDeprecationLevel} */ + public static final class AndroidRobolectricTestDeprecationLevelConverter + extends EnumConverter<AndroidRobolectricTestDeprecationLevel> { + public AndroidRobolectricTestDeprecationLevelConverter() { + super(AndroidRobolectricTestDeprecationLevel.class, "android robolectric deprecation level"); + } + } + /** * Value used to avoid multiple configurations from conflicting. * @@ -199,6 +208,30 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { return null; } + /** android_robolectric_test deprecation levels */ + public enum AndroidRobolectricTestDeprecationLevel { + OFF, + WARNING, + DEPRECATED; + + public static List<String> getAttributeValues() { + return ImmutableList.of( + OFF.name().toLowerCase(), + WARNING.name().toLowerCase(), + DEPRECATED.name().toLowerCase()); + } + + public static AndroidRobolectricTestDeprecationLevel fromString(String value) { + for (AndroidRobolectricTestDeprecationLevel level : + AndroidRobolectricTestDeprecationLevel.values()) { + if (level.name().equals(value)) { + return level; + } + } + return null; + } + } + // TODO(corysmith): Move to ApplicationManifest when no longer needed as a public function. @Nullable public static AndroidAaptVersion chooseTargetAaptVersion(RuleContext ruleContext) @@ -786,6 +819,18 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { ) public boolean fixedResourceNeverlinking; + @Option( + name = "android_robolectric_test_deprecation_level", + defaultValue = "off", + documentationCategory = OptionDocumentationCategory.UNDOCUMENTED, + effectTags = {OptionEffectTag.AFFECTS_OUTPUTS, OptionEffectTag.BUILD_FILE_SEMANTICS}, + converter = AndroidRobolectricTestDeprecationLevelConverter.class, + help = + "Determine the deprecation level of android_robolectric_test. Can be 'off', " + + "'warning', or 'deprecated'." + ) + public AndroidRobolectricTestDeprecationLevel robolectricTestDeprecationLevel; + @Override public FragmentOptions getHost() { Options host = (Options) super.getHost(); @@ -868,6 +913,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { private final boolean useParallelDex2Oat; private final boolean skipParsingAction; private final boolean fixedResourceNeverlinking; + private final AndroidRobolectricTestDeprecationLevel robolectricTestDeprecationLevel; AndroidConfiguration(Options options) throws InvalidConfigurationException { this.sdk = options.sdk; @@ -905,6 +951,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { this.useParallelDex2Oat = options.useParallelDex2Oat; this.skipParsingAction = options.skipParsingAction; this.fixedResourceNeverlinking = options.fixedResourceNeverlinking; + this.robolectricTestDeprecationLevel = options.robolectricTestDeprecationLevel; if (incrementalDexingShardsAfterProguard < 0) { throw new InvalidConfigurationException( @@ -954,7 +1001,8 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { boolean throwOnResourceConflict, boolean useParallelDex2Oat, boolean skipParsingAction, - boolean fixedResourceNeverlinking) { + boolean fixedResourceNeverlinking, + AndroidRobolectricTestDeprecationLevel robolectricTestDeprecationLevel) { this.sdk = sdk; this.cpu = cpu; this.useIncrementalNativeLibs = useIncrementalNativeLibs; @@ -987,6 +1035,7 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { this.useParallelDex2Oat = useParallelDex2Oat; this.skipParsingAction = skipParsingAction; this.fixedResourceNeverlinking = fixedResourceNeverlinking; + this.robolectricTestDeprecationLevel = robolectricTestDeprecationLevel; } public String getCpu() { @@ -1134,6 +1183,10 @@ public class AndroidConfiguration extends BuildConfiguration.Fragment { return this.fixedResourceNeverlinking; } + public AndroidRobolectricTestDeprecationLevel getRobolectricTestDeprecationLevel() { + return robolectricTestDeprecationLevel; + } + @Override public void addGlobalMakeVariables(ImmutableMap.Builder<String, String> globalMakeEnvBuilder) { globalMakeEnvBuilder.put("ANDROID_CPU", cpu); |