1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package net.sf.jfxdplugin;
19
20 import java.io.File;
21 import java.util.List;
22 import java.util.Locale;
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.plugin.MojoFailureException;
25 import org.apache.maven.reporting.MavenReport;
26 import org.apache.maven.reporting.MavenReportException;
27 import org.codehaus.doxia.sink.Sink;
28 import org.codehaus.plexus.util.StringUtils;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 public class JavafxdocReport extends AbstractJavafxdocMojo implements
47 MavenReport {
48
49
50
51
52
53
54 private String description;
55
56
57
58
59
60 private String destDir = "apidocs";
61
62
63
64
65
66 private String name;
67
68
69
70
71
72
73
74 private File reportOutputDirectory;
75
76
77
78
79
80
81
82
83 public void execute() throws MojoExecutionException, MojoFailureException {
84 try {
85 executeReport();
86 } catch (MavenReportException ex) {
87 String message = formatMessage("report.javafxdoc.error", ex.
88 getMessage());
89 if (isFailOnError()) {
90 throw new MojoExecutionException(message, ex);
91 }
92 getLog().error(message, ex);
93 } catch (RuntimeException ex) {
94 if (isFailOnError()) {
95 throw ex;
96 }
97 getLog().error(formatMessage("report.javafxdoc.error",
98 ex.getMessage()), ex);
99 }
100 }
101
102
103
104
105 public void generate(Sink sink, Locale locale) throws MavenReportException {
106 setOutputDirectory(getReportOutputDirectory());
107 executeReport();
108 }
109
110
111
112
113 public String getOutputName() {
114 return getDestDir() + "/index";
115 }
116
117
118
119
120 public String getCategoryName() {
121 return MavenReport.CATEGORY_PROJECT_REPORTS;
122 }
123
124
125
126
127 public String getName(Locale locale) {
128 if (StringUtils.isEmpty(name)) {
129 name = getBundle(locale).getString("report.javafxdoc.name");
130 }
131
132 return name;
133 }
134
135
136
137
138 public String getDescription(Locale locale) {
139 if (StringUtils.isEmpty(description)) {
140 description = getBundle(locale).getString(
141 "report.javafxdoc.description");
142 }
143
144 return description;
145 }
146
147
148
149
150 public void setReportOutputDirectory(File outputDirectory) {
151 if ((outputDirectory != null) && (!outputDirectory.getAbsolutePath().
152 endsWith(getDestDir()))) {
153 this.reportOutputDirectory = new File(outputDirectory,
154 getDestDir());
155 } else {
156 this.reportOutputDirectory = outputDirectory;
157 }
158 }
159
160
161
162
163 public File getReportOutputDirectory() {
164 if (reportOutputDirectory == null) {
165 return getOutputDirectory();
166 }
167
168 return reportOutputDirectory;
169 }
170
171
172
173
174 public boolean isExternalReport() {
175 return true;
176 }
177
178
179
180
181 public boolean canGenerateReport() {
182 List<String> sourcePaths = getSourcePaths();
183 List<String> files = getFiles(sourcePaths);
184
185 return canGenerateReport(files);
186 }
187
188
189
190
191
192
193 public String getDestDir() {
194 return destDir;
195 }
196
197
198
199
200
201
202 public void setDestDir(String destDir) {
203 this.destDir = destDir;
204 }
205 }