|
17 | 17 | import com.google.common.annotations.VisibleForTesting;
|
18 | 18 | import com.google.common.base.Preconditions;
|
19 | 19 | import com.google.common.base.Strings;
|
| 20 | +import com.google.common.collect.ImmutableList; |
20 | 21 | import com.google.common.collect.Lists;
|
21 | 22 | import com.google.common.io.Files;
|
22 | 23 | import com.google.common.io.Resources;
|
@@ -67,6 +68,7 @@ class Options {
|
67 | 68 | private File outputFile = new File("tree-shaker-report.txt");
|
68 | 69 | private LibraryInfo summary;
|
69 | 70 | private String summaryOutputFile;
|
| 71 | + private List<LibraryInfo> summaries = Lists.newArrayList(); |
70 | 72 |
|
71 | 73 | // The default source version number if not passed with -source is determined from the system
|
72 | 74 | // properties of the running java version after parsing the argument list.
|
@@ -135,11 +137,27 @@ public LibraryInfo getSummary() {
|
135 | 137 | public void setSummary(LibraryInfo summary) {
|
136 | 138 | this.summary = summary;
|
137 | 139 | }
|
138 |
| - |
| 140 | + |
| 141 | + public List<LibraryInfo> getSummaries() { |
| 142 | + return summaries; |
| 143 | + } |
| 144 | + |
| 145 | + public void setSummaries(List<LibraryInfo> summaries) { |
| 146 | + this.summaries = summaries; |
| 147 | + } |
| 148 | + |
| 149 | + public void addSummary(LibraryInfo summary) { |
| 150 | + this.summaries.add(summary); |
| 151 | + } |
| 152 | + |
139 | 153 | public String getSummaryOutputFile() {
|
140 | 154 | return summaryOutputFile;
|
141 | 155 | }
|
142 | 156 |
|
| 157 | + public void setSummaryOutputFile(String summaryOutputFile) { |
| 158 | + this.summaryOutputFile = summaryOutputFile; |
| 159 | + } |
| 160 | + |
143 | 161 | private void addManifest(String manifestFile) throws IOException {
|
144 | 162 | BufferedReader in = new BufferedReader(new FileReader(new File(manifestFile)));
|
145 | 163 | try {
|
@@ -192,6 +210,16 @@ public static Options parse(String[] args) throws IOException {
|
192 | 210 | return options;
|
193 | 211 | }
|
194 | 212 |
|
| 213 | + private static List<LibraryInfo> readSummaries(List<String> summaries) throws IOException { |
| 214 | + List<LibraryInfo> result = Lists.newArrayList(); |
| 215 | + for (String summary : summaries) { |
| 216 | + result.add( |
| 217 | + LibraryInfo.parseFrom( |
| 218 | + Files.toByteArray(new File(summary)), ExtensionRegistry.getGeneratedRegistry())); |
| 219 | + } |
| 220 | + return result; |
| 221 | + } |
| 222 | + |
195 | 223 | private static void processArgsFile(String filename, Options options) throws IOException {
|
196 | 224 | if (filename.isEmpty()) {
|
197 | 225 | usage("no @ file specified");
|
@@ -220,6 +248,11 @@ private static void processArgs(String[] args, Options options) throws IOExcepti
|
220 | 248 | usage("-classpath requires an argument");
|
221 | 249 | }
|
222 | 250 | options.classpath = args[nArg];
|
| 251 | + } else if (arg.equals("-summaries")) { |
| 252 | + if (++nArg == args.length) { |
| 253 | + usage("--summaries requires an argument"); |
| 254 | + } |
| 255 | + options.setSummaries(readSummaries(ImmutableList.copyOf(args[nArg].split(":")))); |
223 | 256 | } else if (arg.equals("-summary")) {
|
224 | 257 | if (++nArg == args.length) {
|
225 | 258 | usage("-summary requires an argument");
|
|
0 commit comments