1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.rat;
20
21 import java.io.File;
22
23 import org.apache.commons.cli.Options;
24 import org.apache.rat.document.RatDocumentAnalysisException;
25 import org.apache.rat.help.Help;
26 import org.apache.rat.utils.DefaultLog;
27
28 import static java.lang.String.format;
29
30
31
32
33 public final class Report {
34
35
36
37
38
39
40
41
42 public static void main(final String[] args) throws Exception {
43 DefaultLog.getInstance().info(new VersionInfo().toString());
44 ReportConfiguration configuration = OptionCollection.parseCommands(new File("."), args, Report::printUsage);
45 if (configuration != null) {
46 configuration.validate(DefaultLog.getInstance()::error);
47 Reporter reporter = new Reporter(configuration);
48 reporter.output();
49 reporter.writeSummary(DefaultLog.getInstance().asWriter());
50
51 if (configuration.getClaimValidator().hasErrors()) {
52 configuration.getClaimValidator().logIssues(reporter.getClaimsStatistic());
53 throw new RatDocumentAnalysisException(format("Issues with %s",
54 String.join(", ",
55 configuration.getClaimValidator().listIssues(reporter.getClaimsStatistic()))));
56 }
57 }
58 }
59
60
61
62
63
64 private static void printUsage(final Options opts) {
65 new Help(System.out).printUsage(opts);
66 }
67
68 private Report() {
69
70 }
71 }