From d6fec930d4eb365a6d3936bea1fe40f4800a8cec Mon Sep 17 00:00:00 2001 From: ajmichael Date: Fri, 7 Apr 2017 14:41:19 +0000 Subject: [PATCH] Remove getAaptSupportsMainDexCreation from AndroidSdkProvider. All android_sdk rules are required to have the apksigner binary, which was not included in the build tools until version 24.0.3. So this check is no longer necessary. Instead, we check in AndroidSdkRepositoryFunction. RELNOTES: None PiperOrigin-RevId: 152498753 --- .../lib/rules/android/AndroidBinary.java | 5 +-- .../build/lib/rules/android/AndroidSdk.java | 15 ------- .../lib/rules/android/AndroidSdkProvider.java | 4 -- .../lib/rules/android/AndroidBinaryTest.java | 44 ------------------- .../rules/android/ApkManifestActionTest.java | 3 +- 5 files changed, 2 insertions(+), 69 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 8c9887d3652a35..e640555cc2bcc1 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 @@ -1741,11 +1741,8 @@ private static Artifact createSplitApkResources(RuleContext ruleContext, return splitResources; } - @Nullable private static Artifact createMainDexProguardSpec(RuleContext ruleContext) { - return AndroidSdkProvider.fromRuleContext(ruleContext).getAaptSupportsMainDexGeneration() - ? ProguardHelper.getProguardConfigArtifact(ruleContext, "main_dex") - : null; + return ProguardHelper.getProguardConfigArtifact(ruleContext, "main_dex"); } /** diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdk.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdk.java index dc7164fb87494e..07b88a298b37aa 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdk.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSdk.java @@ -13,8 +13,6 @@ // limitations under the License. package com.google.devtools.build.lib.rules.android; -import com.android.repository.Revision; -import com.google.common.base.Strings; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.FilesToRunProvider; @@ -46,18 +44,6 @@ public ConfiguredTarget create(RuleContext ruleContext) String buildToolsVersion = AggregatingAttributeMapper.of(ruleContext.getRule()) .get("build_tools_version", Type.STRING); - Revision parsedBuildToolsVersion = null; - try { - parsedBuildToolsVersion = - Strings.isNullOrEmpty(buildToolsVersion) - ? null - : Revision.parseRevision(buildToolsVersion); - } catch (NumberFormatException nfe) { - ruleContext.attributeError("build_tools_version", "Invalid version: " + buildToolsVersion); - } - boolean aaptSupportsMainDexGeneration = - parsedBuildToolsVersion == null - || parsedBuildToolsVersion.compareTo(new Revision(24)) >= 0; FilesToRunProvider aidl = ruleContext.getExecutablePrerequisite("aidl", Mode.HOST); FilesToRunProvider aapt = ruleContext.getExecutablePrerequisite("aapt", Mode.HOST); FilesToRunProvider apkBuilder = ruleContext.getExecutablePrerequisite( @@ -88,7 +74,6 @@ public ConfiguredTarget create(RuleContext ruleContext) AndroidSdkProvider.class, AndroidSdkProvider.create( buildToolsVersion, - aaptSupportsMainDexGeneration, frameworkAidl, aidlLib, androidJar, 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 982b7e207352ee..4896bca2457579 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 @@ -30,7 +30,6 @@ public abstract class AndroidSdkProvider implements TransitiveInfoProvider { public static AndroidSdkProvider create( String buildToolsVersion, - boolean aaptSupportsMainDexGeneration, Artifact frameworkAidl, @Nullable TransitiveInfoCollection aidlLib, Artifact androidJar, @@ -50,7 +49,6 @@ public static AndroidSdkProvider create( return new AutoValue_AndroidSdkProvider( buildToolsVersion, - aaptSupportsMainDexGeneration, frameworkAidl, aidlLib, androidJar, @@ -98,8 +96,6 @@ public static boolean verifyPresence(RuleContext ruleContext) { /** The value of build_tools_version. May be null or empty. */ public abstract String getBuildToolsVersion(); - public abstract boolean getAaptSupportsMainDexGeneration(); - public abstract Artifact getFrameworkAidl(); @Nullable diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java index 2574014a6cfa9e..8392ec8b76b594 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidBinaryTest.java @@ -49,7 +49,6 @@ import com.google.devtools.build.lib.vfs.Path; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Set; import org.junit.Before; @@ -2068,49 +2067,6 @@ public void testMainDexAaptGenerationSupported() throws Exception { targetConfig.getBinFragment() + "/java/a/proguard/a/main_dex_a_proguard.cfg")); } - @Test - public void testMainDexAaptGenerationUnsupported() throws Exception { - scratch.file("sdk/BUILD", - "android_sdk(", - " name = 'sdk',", - " build_tools_version = '24.0.0-rc3',", - " aapt = 'aapt',", - " adb = 'adb',", - " aidl = 'aidl',", - " android_jar = 'android.jar',", - " annotations_jar = 'annotations_jar',", - " apkbuilder = 'apkbuilder',", - " apksigner = 'apksigner',", - " dx = 'dx',", - " framework_aidl = 'framework_aidl',", - " main_dex_classes = 'main_dex_classes',", - " main_dex_list_creator = 'main_dex_list_creator',", - " proguard = 'proguard',", - " shrinked_android_jar = 'shrinked_android_jar',", - " zipalign = 'zipalign',", - " resource_extractor = 'resource_extractor')"); - - scratch.file("java/a/BUILD", - "android_binary(", - " name = 'a',", - " srcs = ['A.java'],", - " manifest = 'AndroidManifest.xml',", - " multidex = 'legacy')"); - - useConfiguration( - "--android_sdk=//sdk:sdk", "--experimental_android_use_singlejar_for_multidex"); - ConfiguredTarget a = getConfiguredTarget("//java/a:a"); - Artifact intermediateJar = artifactByPath(ImmutableList.of(getCompressedUnsignedApk(a)), - ".apk", ".dex.zip", ".dex.zip", "main_dex_list.txt", "_intermediate.jar"); - List args = getGeneratingSpawnAction(intermediateJar).getArguments(); - assertEquals(-1, - Collections.indexOfSubList( - args, - ImmutableList.of( - "-include", - targetConfig.getBinFragment() + "/java/a/proguard/a/main_dex_a_proguard.cfg"))); - } - @Test public void testMainDexGenerationWithoutProguardMap() throws Exception { useConfiguration("--experimental_android_use_singlejar_for_multidex"); diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/ApkManifestActionTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/ApkManifestActionTest.java index 022cd7ad5eb82a..b882422a1c180b 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/android/ApkManifestActionTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/android/ApkManifestActionTest.java @@ -49,8 +49,7 @@ public void testActionKey() throws Exception { Artifact outputFile = createArtifact("/workspace/java/test/manifest"); AndroidSdkProvider sdk = AndroidSdkProvider.create( - "23.0.0", - false, // aapt_supports_main_dex_generation + "24.0.3", createArtifact("/workspace/androidsdk/frameworkAidl"), null, // aidlLib, optional createArtifact("/workspace/androidsdk/androidJar"),