37
37
import org .apache .maven .jxr .pacman .FileManager ;
38
38
import org .apache .maven .jxr .pacman .PackageManager ;
39
39
import org .apache .maven .model .ReportPlugin ;
40
+ import org .apache .maven .plugin .MojoExecution ;
40
41
import org .apache .maven .plugins .annotations .Parameter ;
41
42
import org .apache .maven .project .MavenProject ;
42
43
import org .apache .maven .reporting .AbstractMavenReport ;
@@ -73,10 +74,7 @@ public abstract class AbstractJxrReport extends AbstractMavenReport {
73
74
/**
74
75
* String used at the bottom of the Xref HTML files.
75
76
*/
76
- @ Parameter (
77
- property = "bottom" ,
78
- defaultValue =
79
- "Copyright © {inceptionYear}–{currentYear} {organizationName}. All rights reserved." )
77
+ @ Parameter (property = "bottom" , defaultValue = "\u00A9 {inceptionYear}\u2013 {currentYear} {organizationName}" )
80
78
private String bottom ;
81
79
82
80
// CHECKSTYLE_ON: LineLength
@@ -111,12 +109,6 @@ public abstract class AbstractJxrReport extends AbstractMavenReport {
111
109
@ Parameter
112
110
private ArrayList <String > includes ;
113
111
114
- /**
115
- * The projects in the reactor for aggregation report.
116
- */
117
- @ Parameter (defaultValue = "${reactorProjects}" , readonly = true )
118
- protected List <MavenProject > reactorProjects ;
119
-
120
112
/**
121
113
* Whether to skip this execution.
122
114
*
@@ -202,23 +194,23 @@ && hasSources(currentFile)) {
202
194
}
203
195
204
196
/**
205
- * Creates the Xref for the Java files found in the given source directory and puts them in the given destination
197
+ * Creates the Xref for the Java files found in the given source directory and puts them in the given output
206
198
* directory.
207
199
*
208
200
* @param locale The user locale to use for the Xref generation
209
- * @param destinationDirectory The output directory
201
+ * @param outputDirectory The output directory
210
202
* @param sourceDirs The source directories
211
203
* @throws java.io.IOException
212
204
* @throws org.apache.maven.jxr.JxrException
213
205
*/
214
- private void createXref (Locale locale , String destinationDirectory , List <String > sourceDirs )
206
+ private void createXref (Locale locale , File outputDirectory , List <String > sourceDirs )
215
207
throws IOException , JxrException {
216
208
FileManager fileManager = new FileManager ();
217
209
PackageManager packageManager = new PackageManager (fileManager );
218
210
JavaCodeTransform codeTransform = new JavaCodeTransform (packageManager , fileManager );
219
211
220
212
JXR jxr = new JXR (packageManager , codeTransform );
221
- jxr .setDest (Paths . get ( destinationDirectory ));
213
+ jxr .setDest (outputDirectory . toPath ( ));
222
214
jxr .setInputEncoding (getInputEncoding ());
223
215
jxr .setLocale (locale );
224
216
jxr .setOutputEncoding (getOutputEncoding ());
@@ -242,11 +234,11 @@ private void createXref(Locale locale, String destinationDirectory, List<String>
242
234
}
243
235
244
236
// and finally copy the stylesheet
245
- copyRequiredResources (destinationDirectory );
237
+ copyRequiredResources (outputDirectory );
246
238
}
247
239
248
240
/**
249
- * Returns the bottom text to be displayed at the lower part of the generated JXR reports .
241
+ * Returns the bottom text to be displayed at the lower part of the generated JXR report .
250
242
*/
251
243
private String getBottomText () {
252
244
int currentYear = Calendar .getInstance ().get (Calendar .YEAR );
@@ -258,12 +250,12 @@ private String getBottomText() {
258
250
259
251
if (inceptionYear != null ) {
260
252
if (inceptionYear .equals (year )) {
261
- theBottom = StringUtils .replace (theBottom , "{inceptionYear}– " , "" );
253
+ theBottom = StringUtils .replace (theBottom , "{inceptionYear}\u2013 " , "" );
262
254
} else {
263
255
theBottom = StringUtils .replace (theBottom , "{inceptionYear}" , inceptionYear );
264
256
}
265
257
} else {
266
- theBottom = StringUtils .replace (theBottom , "{inceptionYear}– " , "" );
258
+ theBottom = StringUtils .replace (theBottom , "{inceptionYear}\u2013 " , "" );
267
259
}
268
260
269
261
if (project .getOrganization () == null ) {
@@ -293,28 +285,28 @@ private String getBottomText() {
293
285
}
294
286
295
287
/**
296
- * Copy some required resources (like the stylesheet) to the given directory
288
+ * Copy some required resources (like the stylesheet) to the given target directory
297
289
*
298
- * @param dir the directory to copy the resources to
290
+ * @param targetDirectory the directory to copy the resources to
299
291
*/
300
- private void copyRequiredResources (String dir ) {
292
+ private void copyRequiredResources (File targetDirectory ) {
301
293
if (stylesheet != null && !stylesheet .isEmpty ()) {
302
294
File stylesheetFile = new File (stylesheet );
303
- File destStylesheetFile = new File (dir , "stylesheet.css" );
295
+ File targetStylesheetFile = new File (targetDirectory , "stylesheet.css" );
304
296
305
297
try {
306
298
if (stylesheetFile .isAbsolute ()) {
307
- FileUtils .copyFile (stylesheetFile , destStylesheetFile );
299
+ FileUtils .copyFile (stylesheetFile , targetStylesheetFile );
308
300
} else {
309
301
URL stylesheetUrl = this .getClass ().getClassLoader ().getResource (stylesheet );
310
- FileUtils .copyURLToFile (stylesheetUrl , destStylesheetFile );
302
+ FileUtils .copyURLToFile (stylesheetUrl , targetStylesheetFile );
311
303
}
312
304
} catch (IOException e ) {
313
305
getLog ().warn ("An error occured while copying the stylesheet to the target directory" , e );
314
306
}
315
307
} else {
316
308
if (javadocTemplatesVersion .isAtLeast ("1.8" )) {
317
- copyResources (dir , "jdk8/" , "stylesheet.css" );
309
+ copyResources (targetDirectory , "jdk8/" , "stylesheet.css" );
318
310
} else if (javadocTemplatesVersion .isAtLeast ("1.7" )) {
319
311
String [] jdk7Resources = {
320
312
"stylesheet.css" ,
@@ -323,31 +315,31 @@ private void copyRequiredResources(String dir) {
323
315
"resources/titlebar.gif" ,
324
316
"resources/titlebar_end.gif"
325
317
};
326
- copyResources (dir , "jdk7/" , jdk7Resources );
318
+ copyResources (targetDirectory , "jdk7/" , jdk7Resources );
327
319
} else if (javadocTemplatesVersion .isAtLeast ("1.6" )) {
328
- copyResources (dir , "jdk6/" , "stylesheet.css" );
320
+ copyResources (targetDirectory , "jdk6/" , "stylesheet.css" );
329
321
} else if (javadocTemplatesVersion .isAtLeast ("1.4" )) {
330
- copyResources (dir , "jdk4/" , "stylesheet.css" );
322
+ copyResources (targetDirectory , "jdk4/" , "stylesheet.css" );
331
323
} else {
332
324
// Fallback to the original stylesheet
333
- copyResources (dir , "" , "stylesheet.css" );
325
+ copyResources (targetDirectory , "" , "stylesheet.css" );
334
326
}
335
327
}
336
328
}
337
329
338
330
/**
339
331
* Copy styles and related resources to the given directory
340
332
*
341
- * @param dir the directory to copy the resources to
333
+ * @param targetDirectory the target directory to copy the resources to
342
334
* @param sourceDirectory resources subdirectory to copy from
343
335
* @param files names of files to copy
344
336
*/
345
- private void copyResources (String dir , String sourceDirectory , String ... files ) {
337
+ private void copyResources (File targetDirectory , String sourceDirectory , String ... files ) {
346
338
try {
347
339
for (String file : files ) {
348
340
URL resourceUrl = this .getClass ().getClassLoader ().getResource (sourceDirectory + file );
349
- File destResourceFile = new File (dir , file );
350
- FileUtils .copyURLToFile (resourceUrl , destResourceFile );
341
+ File targetResourceFile = new File (targetDirectory , file );
342
+ FileUtils .copyURLToFile (resourceUrl , targetResourceFile );
351
343
}
352
344
} catch (IOException e ) {
353
345
getLog ().warn ("An error occured while copying the resource to the target directory" , e );
@@ -359,14 +351,18 @@ protected MavenProject getProject() {
359
351
return project ;
360
352
}
361
353
362
- /**
363
- * Returns the Maven session.
364
- * @return Maven session
365
- */
366
354
protected MavenSession getSession () {
367
355
return session ;
368
356
}
369
357
358
+ protected List <MavenProject > getReactorProjects () {
359
+ return reactorProjects ;
360
+ }
361
+
362
+ protected MojoExecution getMojoExecution () {
363
+ return mojoExecution ;
364
+ }
365
+
370
366
/**
371
367
* Returns the correct resource bundle according to the locale.
372
368
*
@@ -386,7 +382,7 @@ protected void executeReport(Locale locale) throws MavenReportException {
386
382
setJavadocTemplatesVersion ();
387
383
388
384
try {
389
- createXref (locale , getDestinationDirectory (), constructSourceDirs ());
385
+ createXref (locale , getPluginReportOutputDirectory (), constructSourceDirs ());
390
386
} catch (JxrException | IOException e ) {
391
387
throw new MavenReportException ("Error while generating the HTML source code of the project." , e );
392
388
}
@@ -450,7 +446,6 @@ protected List<String> constructSourceDirs() {
450
446
@ Override
451
447
public boolean canGenerateReport () {
452
448
if (skip ) {
453
- getLog ().info ("Skipping JXR." );
454
449
return false ;
455
450
}
456
451
@@ -528,11 +523,12 @@ private Path getJavadocLocation() throws IOException {
528
523
}
529
524
530
525
/**
531
- * Abstract method that returns the target directory where the generated JXR reports will be put.
526
+ * Abstract method that returns the plugin report output directory where the generated JXR report will be put
527
+ * beneath {@link #getReportOutputDirectory()}.
532
528
*
533
- * @return a String that contains the target directory name
529
+ * @return a File for the plugin's report output directory
534
530
*/
535
- protected abstract String getDestinationDirectory ();
531
+ protected abstract File getPluginReportOutputDirectory ();
536
532
537
533
/**
538
534
* Abstract method that returns the specified source directories that will be included in the JXR report generation.
0 commit comments