diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-05-02 07:24:06 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-05-02 07:24:06 +0000 |
commit | 0033a7cfb82b4d66d2801c9d708ff3db09113f34 (patch) | |
tree | cf2fe8bf7a76563d5d6c05c353351d1001a67332 | |
parent | 17f839bcdec84a348dab2ffdf8afa468daec390a (diff) | |
parent | 55c48ce3f2ac765949265b7c1ab8cf968b0495f0 (diff) | |
download | platform_external_doclava-0033a7cfb82b4d66d2801c9d708ff3db09113f34.tar.gz platform_external_doclava-0033a7cfb82b4d66d2801c9d708ff3db09113f34.tar.bz2 platform_external_doclava-0033a7cfb82b4d66d2801c9d708ff3db09113f34.zip |
Snap for 4756844 from 55c48ce3f2ac765949265b7c1ab8cf968b0495f0 to pi-release
Change-Id: Ie261b9ffbfda4934476c163939ec72ecc4f04426
-rw-r--r-- | src/com/google/doclava/Doclava.java | 14 | ||||
-rw-r--r-- | src/com/google/doclava/Stubs.java | 30 |
2 files changed, 37 insertions, 7 deletions
diff --git a/src/com/google/doclava/Doclava.java b/src/com/google/doclava/Doclava.java index b059a64..8231471 100644 --- a/src/com/google/doclava/Doclava.java +++ b/src/com/google/doclava/Doclava.java @@ -184,6 +184,7 @@ public class Doclava { boolean offlineMode = false; String apiFile = null; String removedApiFile = null; + String removedDexApiFile = null; String exactApiFile = null; String privateApiFile = null; String privateDexApiFile = null; @@ -305,6 +306,8 @@ public class Doclava { apiFile = a[1]; } else if (a[0].equals("-removedApi")) { removedApiFile = a[1]; + } else if (a[0].equals("-removedDexApi")) { + removedDexApiFile = a[1]; } else if (a[0].equals("-exactApi")) { exactApiFile = a[1]; } else if (a[0].equals("-privateApi")) { @@ -556,9 +559,11 @@ public class Doclava { // Stubs if (stubsDir != null || apiFile != null || proguardFile != null || removedApiFile != null - || exactApiFile != null || privateApiFile != null || privateDexApiFile != null) { - Stubs.writeStubsAndApi(stubsDir, apiFile, proguardFile, removedApiFile, exactApiFile, - privateApiFile, privateDexApiFile, stubPackages, stubImportPackages, stubSourceOnly); + || removedDexApiFile != null || exactApiFile != null || privateApiFile != null + || privateDexApiFile != null) { + Stubs.writeStubsAndApi(stubsDir, apiFile, proguardFile, removedApiFile, removedDexApiFile, + exactApiFile, privateApiFile, privateDexApiFile, stubPackages, stubImportPackages, + stubSourceOnly); } Errors.printErrors(); @@ -856,6 +861,9 @@ public class Doclava { if (option.equals("-removedApi")) { return 2; } + if (option.equals("-removedDexApi")) { + return 2; + } if (option.equals("-exactApi")) { return 2; } diff --git a/src/com/google/doclava/Stubs.java b/src/com/google/doclava/Stubs.java index 3d260ea..f5eaf4b 100644 --- a/src/com/google/doclava/Stubs.java +++ b/src/com/google/doclava/Stubs.java @@ -47,8 +47,9 @@ import java.util.stream.Collectors; public class Stubs { public static void writeStubsAndApi(String stubsDir, String apiFile, String keepListFile, - String removedApiFile, String exactApiFile, String privateApiFile, String privateDexApiFile, - HashSet<String> stubPackages, HashSet<String> stubImportPackages, boolean stubSourceOnly) { + String removedApiFile, String removedDexApiFile, String exactApiFile, String privateApiFile, + String privateDexApiFile, HashSet<String> stubPackages, HashSet<String> stubImportPackages, + boolean stubSourceOnly) { // figure out which classes we need final HashSet<ClassInfo> notStrippable = new HashSet<ClassInfo>(); Collection<ClassInfo> all = Converter.allClasses(); @@ -56,6 +57,7 @@ public class Stubs { PrintStream apiWriter = null; PrintStream keepListWriter = null; PrintStream removedApiWriter = null; + PrintStream removedDexApiWriter = null; PrintStream exactApiWriter = null; PrintStream privateApiWriter = null; PrintStream privateDexApiWriter = null; @@ -91,6 +93,17 @@ public class Stubs { "Cannot open file for write"); } } + if (removedDexApiFile != null) { + try { + File removedDexApi = new File(removedDexApiFile); + removedDexApi.getParentFile().mkdirs(); + removedDexApiWriter = new PrintStream( + new BufferedOutputStream(new FileOutputStream(removedDexApi))); + } catch (FileNotFoundException e) { + Errors.error(Errors.IO_ERROR, new SourcePositionInfo(removedDexApiFile, 0, 0), + "Cannot open file for write"); + } + } if (exactApiFile != null) { try { File exactApi = new File(exactApiFile); @@ -239,7 +252,8 @@ public class Stubs { } } - if (privateApiWriter != null || privateDexApiWriter != null || removedApiWriter != null) { + if (privateApiWriter != null || privateDexApiWriter != null || removedApiWriter != null + || removedDexApiWriter != null) { allClassesByPackage = Converter.allClasses().stream() // Make sure that the files only contains information from the required packages. .filter(ci -> stubPackages == null @@ -249,11 +263,12 @@ public class Stubs { final boolean ignoreShown = Doclava.showUnannotated; + Predicate<MemberInfo> memberIsNotCloned = (x -> !x.isCloned()); + FilterPredicate apiFilter = new FilterPredicate(new ApiPredicate().setIgnoreShown(ignoreShown)); ApiPredicate apiReference = new ApiPredicate().setIgnoreShown(true); Predicate<MemberInfo> apiEmit = apiFilter.and(new ElidingPredicate(apiReference)); - Predicate<MemberInfo> memberIsNotCloned = (x -> !x.isCloned()); Predicate<MemberInfo> privateEmit = memberIsNotCloned.and(apiFilter.negate()); Predicate<MemberInfo> privateReference = (x -> true); @@ -261,6 +276,7 @@ public class Stubs { new FilterPredicate(new ApiPredicate().setIgnoreShown(ignoreShown).setMatchRemoved(true)); ApiPredicate removedReference = new ApiPredicate().setIgnoreShown(true).setIgnoreRemoved(true); Predicate<MemberInfo> removedEmit = removedFilter.and(new ElidingPredicate(removedReference)); + Predicate<MemberInfo> removedDexEmit = memberIsNotCloned.and(removedFilter); // Write out the current API if (apiWriter != null) { @@ -291,6 +307,12 @@ public class Stubs { writeApi(removedApiWriter, allClassesByPackage, removedEmit, removedReference); removedApiWriter.close(); } + + // Write out the removed DEX API + if (removedDexApiWriter != null) { + writeDexApi(removedDexApiWriter, allClassesByPackage, removedDexEmit); + removedDexApiWriter.close(); + } } private static boolean shouldWriteStub(final String packageName, |