1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
package com.jeantessier.dependencyfinder.ant; |
34 | |
|
35 | |
import java.io.*; |
36 | |
import java.util.*; |
37 | |
|
38 | |
import javax.xml.parsers.*; |
39 | |
|
40 | |
import org.apache.log4j.*; |
41 | |
import org.apache.tools.ant.*; |
42 | |
import org.apache.tools.ant.types.*; |
43 | |
|
44 | |
import org.xml.sax.*; |
45 | |
|
46 | |
import com.jeantessier.dependency.*; |
47 | |
|
48 | 0 | public class DependencyReporter extends GraphTask { |
49 | 0 | private String scopeIncludes = "//"; |
50 | 0 | private String scopeExcludes = ""; |
51 | 0 | private boolean packageScope = false; |
52 | 0 | private String packageScopeIncludes = ""; |
53 | 0 | private String packageScopeExcludes = ""; |
54 | 0 | private boolean classScope = false; |
55 | 0 | private String classScopeIncludes = ""; |
56 | 0 | private String classScopeExcludes = ""; |
57 | 0 | private boolean featureScope = false; |
58 | 0 | private String featureScopeIncludes = ""; |
59 | 0 | private String featureScopeExcludes = ""; |
60 | 0 | private String filterIncludes = "//"; |
61 | 0 | private String filterExcludes = ""; |
62 | 0 | private boolean packageFilter = false; |
63 | 0 | private String packageFilterIncludes = ""; |
64 | 0 | private String packageFilterExcludes = ""; |
65 | 0 | private boolean classFilter = false; |
66 | 0 | private String classFilterIncludes = ""; |
67 | 0 | private String classFilterExcludes = ""; |
68 | 0 | private boolean featureFilter = false; |
69 | 0 | private String featureFilterIncludes = ""; |
70 | 0 | private String featureFilterExcludes = ""; |
71 | |
|
72 | |
private Path scopeIncludesList; |
73 | |
private Path scopeExcludesList; |
74 | |
private Path filterIncludesList; |
75 | |
private Path filterExcludesList; |
76 | |
|
77 | 0 | private boolean showInbounds = false; |
78 | 0 | private boolean showOutbounds = false; |
79 | 0 | private boolean showEmptyNodes = false; |
80 | |
|
81 | 0 | private boolean minimize = false; |
82 | 0 | private boolean maximize = false; |
83 | 0 | private boolean copyOnly = false; |
84 | 0 | private boolean xml = false; |
85 | 0 | private String encoding = XMLPrinter.DEFAULT_ENCODING; |
86 | 0 | private String dtdPrefix = XMLPrinter.DEFAULT_DTD_PREFIX; |
87 | |
private String indentText; |
88 | |
|
89 | |
public String getScopeincludes() { |
90 | 0 | return scopeIncludes; |
91 | |
} |
92 | |
|
93 | |
public void setScopeincludes(String scopeIncludes) { |
94 | 0 | this.scopeIncludes = scopeIncludes; |
95 | 0 | } |
96 | |
|
97 | |
public String getScopeexcludes() { |
98 | 0 | return scopeExcludes; |
99 | |
} |
100 | |
|
101 | |
public void setScopeexcludes(String scopeExcludes) { |
102 | 0 | this.scopeExcludes = scopeExcludes; |
103 | 0 | } |
104 | |
|
105 | |
public boolean getPackagescope() { |
106 | 0 | return packageScope; |
107 | |
} |
108 | |
|
109 | |
public void setPackagescope(boolean packageScope) { |
110 | 0 | this.packageScope = packageScope; |
111 | 0 | } |
112 | |
|
113 | |
public String getPackagescopeincludes() { |
114 | 0 | return packageScopeIncludes; |
115 | |
} |
116 | |
|
117 | |
public void setPackagescopeincludes(String packageScopeIncludes) { |
118 | 0 | this.packageScopeIncludes = packageScopeIncludes; |
119 | 0 | } |
120 | |
|
121 | |
public String getPackagescopeexcludes() { |
122 | 0 | return packageScopeExcludes; |
123 | |
} |
124 | |
|
125 | |
public void setPackagescopeexcludes(String packageScopeExcludes) { |
126 | 0 | this.packageScopeExcludes = packageScopeExcludes; |
127 | 0 | } |
128 | |
|
129 | |
public boolean getClassscope() { |
130 | 0 | return classScope; |
131 | |
} |
132 | |
|
133 | |
public void setClassscope(boolean classScope) { |
134 | 0 | this.classScope = classScope; |
135 | 0 | } |
136 | |
|
137 | |
public String getClassscopeincludes() { |
138 | 0 | return classScopeIncludes; |
139 | |
} |
140 | |
|
141 | |
public void setClassscopeincludes(String classScopeIncludes) { |
142 | 0 | this.classScopeIncludes = classScopeIncludes; |
143 | 0 | } |
144 | |
|
145 | |
public String getClassscopeexcludes() { |
146 | 0 | return classScopeExcludes; |
147 | |
} |
148 | |
|
149 | |
public void setClassscopeexcludes(String classScopeExcludes) { |
150 | 0 | this.classScopeExcludes = classScopeExcludes; |
151 | 0 | } |
152 | |
|
153 | |
public boolean getFeaturescope() { |
154 | 0 | return featureScope; |
155 | |
} |
156 | |
|
157 | |
public void setFeaturescope(boolean featureScope) { |
158 | 0 | this.featureScope = featureScope; |
159 | 0 | } |
160 | |
|
161 | |
public String getFeaturescopeincludes() { |
162 | 0 | return featureScopeIncludes; |
163 | |
} |
164 | |
|
165 | |
public void setFeaturescopeincludes(String featureScopeIncludes) { |
166 | 0 | this.featureScopeIncludes = featureScopeIncludes; |
167 | 0 | } |
168 | |
|
169 | |
public String getFeaturescopeexcludes() { |
170 | 0 | return featureScopeExcludes; |
171 | |
} |
172 | |
|
173 | |
public void setFeaturescopeexcludes(String featureScopeExcludes) { |
174 | 0 | this.featureScopeExcludes = featureScopeExcludes; |
175 | 0 | } |
176 | |
|
177 | |
public String getFilterincludes() { |
178 | 0 | return filterIncludes; |
179 | |
} |
180 | |
|
181 | |
public void setFilterincludes(String filterIncludes) { |
182 | 0 | this.filterIncludes = filterIncludes; |
183 | 0 | } |
184 | |
|
185 | |
public String getFilterexcludes() { |
186 | 0 | return filterExcludes; |
187 | |
} |
188 | |
|
189 | |
public void setFilterexcludes(String filterExcludes) { |
190 | 0 | this.filterExcludes = filterExcludes; |
191 | 0 | } |
192 | |
|
193 | |
public boolean getPackagefilter() { |
194 | 0 | return packageFilter; |
195 | |
} |
196 | |
|
197 | |
public void setPackagefilter(boolean packageFilter) { |
198 | 0 | this.packageFilter = packageFilter; |
199 | 0 | } |
200 | |
|
201 | |
public String getPackagefilterincludes() { |
202 | 0 | return packageFilterIncludes; |
203 | |
} |
204 | |
|
205 | |
public void setPackagefilterincludes(String packageFilterIncludes) { |
206 | 0 | this.packageFilterIncludes = packageFilterIncludes; |
207 | 0 | } |
208 | |
|
209 | |
public String getPackagefilterexcludes() { |
210 | 0 | return packageFilterExcludes; |
211 | |
} |
212 | |
|
213 | |
public void setPackagefilterexcludes(String packageFilterExcludes) { |
214 | 0 | this.packageFilterExcludes = packageFilterExcludes; |
215 | 0 | } |
216 | |
|
217 | |
public boolean getClassfilter() { |
218 | 0 | return classFilter; |
219 | |
} |
220 | |
|
221 | |
public void setClassfilter(boolean classFilter) { |
222 | 0 | this.classFilter = classFilter; |
223 | 0 | } |
224 | |
|
225 | |
public String getClassfilterincludes() { |
226 | 0 | return classFilterIncludes; |
227 | |
} |
228 | |
|
229 | |
public void setClassfilterincludes(String classFilterIncludes) { |
230 | 0 | this.classFilterIncludes = classFilterIncludes; |
231 | 0 | } |
232 | |
|
233 | |
public String getClassfilterexcludes() { |
234 | 0 | return classFilterExcludes; |
235 | |
} |
236 | |
|
237 | |
public void setClassfilterexcludes(String classFilterExcludes) { |
238 | 0 | this.classFilterExcludes = classFilterExcludes; |
239 | 0 | } |
240 | |
|
241 | |
public boolean getFeaturefilter() { |
242 | 0 | return featureFilter; |
243 | |
} |
244 | |
|
245 | |
public void setFeaturefilter(boolean featureFilter) { |
246 | 0 | this.featureFilter = featureFilter; |
247 | 0 | } |
248 | |
|
249 | |
public String getFeaturefilterincludes() { |
250 | 0 | return featureFilterIncludes; |
251 | |
} |
252 | |
|
253 | |
public void setFeaturefilterincludes(String featureFilterIncludes) { |
254 | 0 | this.featureFilterIncludes = featureFilterIncludes; |
255 | 0 | } |
256 | |
|
257 | |
public String getFeaturefilterexcludes() { |
258 | 0 | return featureFilterExcludes; |
259 | |
} |
260 | |
|
261 | |
public void setFeaturefilterexcludes(String featureFilterExcludes) { |
262 | 0 | this.featureFilterExcludes = featureFilterExcludes; |
263 | 0 | } |
264 | |
|
265 | |
public void setP2p(boolean value) { |
266 | 0 | setPackagescope(value); |
267 | 0 | setPackagefilter(value); |
268 | 0 | } |
269 | |
|
270 | |
public void setC2p(boolean value) { |
271 | 0 | setClassscope(value); |
272 | 0 | setPackagefilter(value); |
273 | 0 | } |
274 | |
|
275 | |
public void setC2c(boolean value) { |
276 | 0 | setClassscope(value); |
277 | 0 | setClassfilter(value); |
278 | 0 | } |
279 | |
|
280 | |
public void setF2f(boolean value) { |
281 | 0 | setFeaturescope(value); |
282 | 0 | setFeaturefilter(value); |
283 | 0 | } |
284 | |
|
285 | |
public void setIncludes(String value) { |
286 | 0 | setScopeincludes(value); |
287 | 0 | setFilterincludes(value); |
288 | 0 | } |
289 | |
|
290 | |
public void setExcludes(String value) { |
291 | 0 | setScopeexcludes(value); |
292 | 0 | setFilterexcludes(value); |
293 | 0 | } |
294 | |
|
295 | |
public Path createScopeincludeslist() { |
296 | 0 | if (scopeIncludesList == null) { |
297 | 0 | scopeIncludesList = new Path(getProject()); |
298 | |
} |
299 | |
|
300 | 0 | return scopeIncludesList; |
301 | |
} |
302 | |
|
303 | |
public Path getScopeincludeslist() { |
304 | 0 | return scopeIncludesList; |
305 | |
} |
306 | |
|
307 | |
public Path createScopeexcludeslist() { |
308 | 0 | if (scopeExcludesList == null) { |
309 | 0 | scopeExcludesList = new Path(getProject()); |
310 | |
} |
311 | |
|
312 | 0 | return scopeExcludesList; |
313 | |
} |
314 | |
|
315 | |
public Path getScopeexcludeslist() { |
316 | 0 | return scopeExcludesList; |
317 | |
} |
318 | |
|
319 | |
public Path createFilterincludeslist() { |
320 | 0 | if (filterIncludesList == null) { |
321 | 0 | filterIncludesList = new Path(getProject()); |
322 | |
} |
323 | |
|
324 | 0 | return filterIncludesList; |
325 | |
} |
326 | |
|
327 | |
public Path getFilterincludeslist() { |
328 | 0 | return filterIncludesList; |
329 | |
} |
330 | |
|
331 | |
public Path createFilterexcludeslist() { |
332 | 0 | if (filterExcludesList == null) { |
333 | 0 | filterExcludesList = new Path(getProject()); |
334 | |
} |
335 | |
|
336 | 0 | return filterExcludesList; |
337 | |
} |
338 | |
|
339 | |
public Path getFilterexcludeslist() { |
340 | 0 | return filterExcludesList; |
341 | |
} |
342 | |
|
343 | |
public boolean getShowinbounds() { |
344 | 0 | return showInbounds; |
345 | |
} |
346 | |
|
347 | |
public void setShowinbounds(boolean showInbounds) { |
348 | 0 | this.showInbounds = showInbounds; |
349 | 0 | } |
350 | |
|
351 | |
public boolean getShowoutbounds() { |
352 | 0 | return showOutbounds; |
353 | |
} |
354 | |
|
355 | |
public void setShowoutbounds(boolean showOutbounds) { |
356 | 0 | this.showOutbounds = showOutbounds; |
357 | 0 | } |
358 | |
|
359 | |
public boolean getShowemptynodes() { |
360 | 0 | return showEmptyNodes; |
361 | |
} |
362 | |
|
363 | |
public void setShowemptynodes(boolean showEmptyNodes) { |
364 | 0 | this.showEmptyNodes = showEmptyNodes; |
365 | 0 | } |
366 | |
|
367 | |
public void setShowAll(boolean showAll) { |
368 | 0 | setShowinbounds(showAll); |
369 | 0 | setShowoutbounds(showAll); |
370 | 0 | setShowemptynodes(showAll); |
371 | 0 | } |
372 | |
|
373 | |
public boolean getMinimize() { |
374 | 0 | return minimize; |
375 | |
} |
376 | |
|
377 | |
public void setMinimize(boolean minimize) { |
378 | 0 | this.minimize = minimize; |
379 | 0 | } |
380 | |
|
381 | |
public boolean getMaximize() { |
382 | 0 | return maximize; |
383 | |
} |
384 | |
|
385 | |
public void setMaximize(boolean maximize) { |
386 | 0 | this.maximize = maximize; |
387 | 0 | } |
388 | |
|
389 | |
public boolean getCopyOnly() { |
390 | 0 | return copyOnly; |
391 | |
} |
392 | |
|
393 | |
public void setCopyOnly(boolean copyOnly) { |
394 | 0 | this.copyOnly = copyOnly; |
395 | 0 | } |
396 | |
|
397 | |
public boolean getXml() { |
398 | 0 | return xml; |
399 | |
} |
400 | |
|
401 | |
public void setXml(boolean xml) { |
402 | 0 | this.xml = xml; |
403 | 0 | } |
404 | |
|
405 | |
public String getEncoding() { |
406 | 0 | return encoding; |
407 | |
} |
408 | |
|
409 | |
public void setEncoding(String encoding) { |
410 | 0 | this.encoding = encoding; |
411 | 0 | } |
412 | |
|
413 | |
public String getDtdprefix() { |
414 | 0 | return dtdPrefix; |
415 | |
} |
416 | |
|
417 | |
public void setDtdprefix(String dtdPrefix) { |
418 | 0 | this.dtdPrefix = dtdPrefix; |
419 | 0 | } |
420 | |
|
421 | |
public String getIndenttext() { |
422 | 0 | return indentText; |
423 | |
} |
424 | |
|
425 | |
public void setIntenttext(String indentText) { |
426 | 0 | this.indentText = indentText; |
427 | 0 | } |
428 | |
|
429 | |
protected void validateParameters() throws BuildException { |
430 | 0 | super.validateParameters(); |
431 | |
|
432 | 0 | if (hasScopeRegularExpressionSwitches() && hasScopeListSwitches()) { |
433 | 0 | throw new BuildException("Cannot have scope attributes for regular expressions and lists at the same time!"); |
434 | |
} |
435 | |
|
436 | 0 | if (hasFilterRegularExpressionSwitches() && hasFilterListSwitches()) { |
437 | 0 | throw new BuildException("Cannot have filter attributes for regular expressions and lists at the same time!"); |
438 | |
} |
439 | 0 | } |
440 | |
|
441 | |
public void execute() throws BuildException { |
442 | |
|
443 | 0 | validateParameters(); |
444 | |
|
445 | 0 | VerboseListener verboseListener = new VerboseListener(this); |
446 | |
|
447 | |
try { |
448 | |
GraphCopier copier; |
449 | 0 | if (getCopyOnly() || getMaximize()) { |
450 | 0 | copier = new GraphCopier(getStrategy()); |
451 | |
} else { |
452 | 0 | copier = new GraphSummarizer(getScopeCriteria(), getFilterCriteria()); |
453 | |
} |
454 | |
|
455 | 0 | for (String filename : getSrc().list()) { |
456 | 0 | log("Reading graph from " + filename); |
457 | |
|
458 | 0 | Collection<PackageNode> packages = Collections.emptyList(); |
459 | |
|
460 | 0 | if (filename.endsWith(".xml")) { |
461 | 0 | NodeLoader loader = new NodeLoader(getValidate()); |
462 | 0 | loader.addDependencyListener(verboseListener); |
463 | 0 | packages = loader.load(filename).getPackages().values(); |
464 | |
} |
465 | |
|
466 | 0 | if (getMaximize()) { |
467 | 0 | log("Maximizing ..."); |
468 | 0 | new LinkMaximizer().traverseNodes(packages); |
469 | 0 | } else if (getMinimize()) { |
470 | 0 | log("Minimizing ..."); |
471 | 0 | new LinkMinimizer().traverseNodes(packages); |
472 | |
} |
473 | |
|
474 | 0 | copier.traverseNodes(packages); |
475 | |
} |
476 | |
|
477 | 0 | log("Saving dependency graph to " + getDestfile().getAbsolutePath()); |
478 | |
|
479 | 0 | PrintWriter out = new PrintWriter(new FileWriter(getDestfile())); |
480 | |
|
481 | |
Printer printer; |
482 | 0 | if (getXml()) { |
483 | 0 | printer = new XMLPrinter(out, getEncoding(), getDtdprefix()); |
484 | |
} else { |
485 | 0 | printer = new TextPrinter(out); |
486 | |
} |
487 | |
|
488 | 0 | if (getIndenttext() != null) { |
489 | 0 | printer.setIndentText(getIndenttext()); |
490 | |
} |
491 | |
|
492 | 0 | if (getShowinbounds() || getShowoutbounds() || getShowemptynodes()) { |
493 | 0 | printer.setShowInbounds(getShowinbounds()); |
494 | 0 | printer.setShowOutbounds(getShowoutbounds()); |
495 | 0 | printer.setShowEmptyNodes(getShowemptynodes()); |
496 | |
} |
497 | |
|
498 | 0 | printer.traverseNodes(copier.getScopeFactory().getPackages().values()); |
499 | |
|
500 | 0 | out.close(); |
501 | 0 | } catch (SAXException ex) { |
502 | 0 | throw new BuildException(ex); |
503 | 0 | } catch (ParserConfigurationException ex) { |
504 | 0 | throw new BuildException(ex); |
505 | 0 | } catch (IOException ex) { |
506 | 0 | throw new BuildException(ex); |
507 | 0 | } |
508 | 0 | } |
509 | |
|
510 | |
protected SelectionCriteria getScopeCriteria() throws BuildException { |
511 | 0 | SelectionCriteria result = new ComprehensiveSelectionCriteria(); |
512 | |
|
513 | 0 | if (hasScopeRegularExpressionSwitches()) { |
514 | 0 | result = createRegularExpressionScopeCriteria(); |
515 | 0 | } else if (hasScopeListSwitches()) { |
516 | 0 | result = createCollectionSelectionCriteria(getScopeincludeslist(), getScopeexcludeslist()); |
517 | |
} |
518 | |
|
519 | 0 | return result; |
520 | |
} |
521 | |
|
522 | |
protected SelectionCriteria getFilterCriteria() throws BuildException { |
523 | 0 | SelectionCriteria result = new ComprehensiveSelectionCriteria(); |
524 | |
|
525 | 0 | if (hasFilterRegularExpressionSwitches()) { |
526 | 0 | result = createRegularExpressionFilterCriteria(); |
527 | 0 | } else if (hasFilterListSwitches()) { |
528 | 0 | result = createCollectionSelectionCriteria(getFilterincludeslist(), getFilterexcludeslist()); |
529 | |
} |
530 | |
|
531 | 0 | return result; |
532 | |
} |
533 | |
|
534 | |
protected RegularExpressionSelectionCriteria createRegularExpressionScopeCriteria() throws BuildException { |
535 | 0 | RegularExpressionSelectionCriteria result = new RegularExpressionSelectionCriteria(); |
536 | |
|
537 | 0 | if (getPackagescope() || getClassscope() || getFeaturescope()) { |
538 | 0 | result.setMatchingPackages(getPackagescope()); |
539 | 0 | result.setMatchingClasses(getClassscope()); |
540 | 0 | result.setMatchingFeatures(getFeaturescope()); |
541 | |
} |
542 | |
|
543 | 0 | result.setGlobalIncludes(getScopeincludes()); |
544 | 0 | result.setGlobalExcludes(getScopeexcludes()); |
545 | 0 | result.setPackageIncludes(getPackagescopeincludes()); |
546 | 0 | result.setPackageExcludes(getPackagescopeexcludes()); |
547 | 0 | result.setClassIncludes(getClassscopeincludes()); |
548 | 0 | result.setClassExcludes(getClassscopeexcludes()); |
549 | 0 | result.setFeatureIncludes(getFeaturescopeincludes()); |
550 | 0 | result.setFeatureExcludes(getFeaturescopeexcludes()); |
551 | |
|
552 | 0 | return result; |
553 | |
} |
554 | |
|
555 | |
protected RegularExpressionSelectionCriteria createRegularExpressionFilterCriteria() throws BuildException { |
556 | 0 | RegularExpressionSelectionCriteria result = new RegularExpressionSelectionCriteria(); |
557 | |
|
558 | 0 | if (getPackagefilter() || getClassfilter() || getFeaturefilter()) { |
559 | 0 | result.setMatchingPackages(getPackagefilter()); |
560 | 0 | result.setMatchingClasses(getClassfilter()); |
561 | 0 | result.setMatchingFeatures(getFeaturefilter()); |
562 | |
} |
563 | |
|
564 | 0 | result.setGlobalIncludes(getFilterincludes()); |
565 | 0 | result.setGlobalExcludes(getFilterexcludes()); |
566 | 0 | result.setPackageIncludes(getPackagefilterincludes()); |
567 | 0 | result.setPackageExcludes(getPackagefilterexcludes()); |
568 | 0 | result.setClassIncludes(getClassfilterincludes()); |
569 | 0 | result.setClassExcludes(getClassfilterexcludes()); |
570 | 0 | result.setFeatureIncludes(getFeaturefilterincludes()); |
571 | 0 | result.setFeatureExcludes(getFeaturefilterexcludes()); |
572 | |
|
573 | 0 | return result; |
574 | |
} |
575 | |
|
576 | |
private boolean hasScopeRegularExpressionSwitches() { |
577 | 0 | return |
578 | |
!getScopeincludes().equals("//") || |
579 | |
!getScopeexcludes().equals("") || |
580 | |
getPackagescope() || |
581 | |
!getPackagescopeincludes().equals("") || |
582 | |
!getPackagescopeexcludes().equals("") || |
583 | |
getClassscope() || |
584 | |
!getClassscopeincludes().equals("") || |
585 | |
!getClassscopeexcludes().equals("") || |
586 | |
getFeaturescope() || |
587 | |
!getFeaturescopeincludes().equals("") || |
588 | |
!getFeaturescopeexcludes().equals(""); |
589 | |
} |
590 | |
|
591 | |
private boolean hasScopeListSwitches() { |
592 | 0 | return |
593 | |
getScopeincludeslist() != null || |
594 | |
getScopeexcludeslist() != null; |
595 | |
} |
596 | |
|
597 | |
private boolean hasFilterRegularExpressionSwitches() { |
598 | 0 | return |
599 | |
!getFilterincludes().equals("//") || |
600 | |
!getFilterexcludes().equals("") || |
601 | |
getPackagefilter() || |
602 | |
!getPackagefilterincludes().equals("") || |
603 | |
!getPackagefilterexcludes().equals("") || |
604 | |
getClassfilter() || |
605 | |
!getClassfilterincludes().equals("") || |
606 | |
!getClassfilterexcludes().equals("") || |
607 | |
getFeaturefilter() || |
608 | |
!getFeaturefilterincludes().equals("") || |
609 | |
!getFeaturefilterexcludes().equals(""); |
610 | |
} |
611 | |
|
612 | |
private boolean hasFilterListSwitches() { |
613 | 0 | return |
614 | |
getFilterincludeslist() != null || |
615 | |
getFilterexcludeslist() != null; |
616 | |
} |
617 | |
|
618 | |
private CollectionSelectionCriteria createCollectionSelectionCriteria(Path includes, Path excludes) { |
619 | 0 | return new CollectionSelectionCriteria(loadCollection(includes), loadCollection(excludes)); |
620 | |
} |
621 | |
|
622 | |
private TraversalStrategy getStrategy() throws BuildException { |
623 | 0 | return new SelectiveTraversalStrategy(getScopeCriteria(), getFilterCriteria()); |
624 | |
} |
625 | |
|
626 | |
private Collection<String> loadCollection(Path path) { |
627 | 0 | Collection<String> result = null; |
628 | |
|
629 | 0 | if (path != null) { |
630 | 0 | result = new HashSet<String>(); |
631 | |
|
632 | 0 | for (String filename : path.list()) { |
633 | 0 | BufferedReader reader = null; |
634 | |
String line; |
635 | |
|
636 | |
try { |
637 | 0 | reader = new BufferedReader(new FileReader(filename)); |
638 | 0 | while ((line = reader.readLine()) != null) { |
639 | 0 | result.add(line); |
640 | |
} |
641 | 0 | } catch (IOException ex) { |
642 | 0 | Logger.getLogger(getClass()).error("Couldn't read file " + filename, ex); |
643 | |
} finally { |
644 | 0 | try { |
645 | 0 | if (reader != null) { |
646 | 0 | reader.close(); |
647 | |
} |
648 | 0 | } catch (IOException ex) { |
649 | 0 | Logger.getLogger(getClass()).error("Couldn't close file " + filename, ex); |
650 | 0 | } |
651 | 0 | } |
652 | |
} |
653 | |
} |
654 | |
|
655 | 0 | return result; |
656 | |
} |
657 | |
} |