3737import org .apache .maven .jxr .pacman .FileManager ;
3838import org .apache .maven .jxr .pacman .PackageManager ;
3939import org .apache .maven .model .ReportPlugin ;
40+ import org .apache .maven .plugin .MojoExecution ;
4041import org .apache .maven .plugins .annotations .Parameter ;
4142import org .apache .maven .project .MavenProject ;
4243import org .apache .maven .reporting .AbstractMavenReport ;
@@ -73,10 +74,7 @@ public abstract class AbstractJxrReport extends AbstractMavenReport {
7374 /**
7475 * String used at the bottom of the Xref HTML files.
7576 */
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}" )
8078 private String bottom ;
8179
8280 // CHECKSTYLE_ON: LineLength
@@ -111,12 +109,6 @@ public abstract class AbstractJxrReport extends AbstractMavenReport {
111109 @ Parameter
112110 private ArrayList <String > includes ;
113111
114- /**
115- * The projects in the reactor for aggregation report.
116- */
117- @ Parameter (defaultValue = "${reactorProjects}" , readonly = true )
118- protected List <MavenProject > reactorProjects ;
119-
120112 /**
121113 * Whether to skip this execution.
122114 *
@@ -202,23 +194,23 @@ && hasSources(currentFile)) {
202194 }
203195
204196 /**
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
206198 * directory.
207199 *
208200 * @param locale The user locale to use for the Xref generation
209- * @param destinationDirectory The output directory
201+ * @param outputDirectory The output directory
210202 * @param sourceDirs The source directories
211203 * @throws java.io.IOException
212204 * @throws org.apache.maven.jxr.JxrException
213205 */
214- private void createXref (Locale locale , String destinationDirectory , List <String > sourceDirs )
206+ private void createXref (Locale locale , File outputDirectory , List <String > sourceDirs )
215207 throws IOException , JxrException {
216208 FileManager fileManager = new FileManager ();
217209 PackageManager packageManager = new PackageManager (fileManager );
218210 JavaCodeTransform codeTransform = new JavaCodeTransform (packageManager , fileManager );
219211
220212 JXR jxr = new JXR (packageManager , codeTransform );
221- jxr .setDest (Paths . get ( destinationDirectory ));
213+ jxr .setDest (outputDirectory . toPath ( ));
222214 jxr .setInputEncoding (getInputEncoding ());
223215 jxr .setLocale (locale );
224216 jxr .setOutputEncoding (getOutputEncoding ());
@@ -242,11 +234,11 @@ private void createXref(Locale locale, String destinationDirectory, List<String>
242234 }
243235
244236 // and finally copy the stylesheet
245- copyRequiredResources (destinationDirectory );
237+ copyRequiredResources (outputDirectory );
246238 }
247239
248240 /**
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 .
250242 */
251243 private String getBottomText () {
252244 int currentYear = Calendar .getInstance ().get (Calendar .YEAR );
@@ -258,12 +250,12 @@ private String getBottomText() {
258250
259251 if (inceptionYear != null ) {
260252 if (inceptionYear .equals (year )) {
261- theBottom = StringUtils .replace (theBottom , "{inceptionYear}– " , "" );
253+ theBottom = StringUtils .replace (theBottom , "{inceptionYear}\u2013 " , "" );
262254 } else {
263255 theBottom = StringUtils .replace (theBottom , "{inceptionYear}" , inceptionYear );
264256 }
265257 } else {
266- theBottom = StringUtils .replace (theBottom , "{inceptionYear}– " , "" );
258+ theBottom = StringUtils .replace (theBottom , "{inceptionYear}\u2013 " , "" );
267259 }
268260
269261 if (project .getOrganization () == null ) {
@@ -293,28 +285,28 @@ private String getBottomText() {
293285 }
294286
295287 /**
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
297289 *
298- * @param dir the directory to copy the resources to
290+ * @param targetDirectory the directory to copy the resources to
299291 */
300- private void copyRequiredResources (String dir ) {
292+ private void copyRequiredResources (File targetDirectory ) {
301293 if (stylesheet != null && !stylesheet .isEmpty ()) {
302294 File stylesheetFile = new File (stylesheet );
303- File destStylesheetFile = new File (dir , "stylesheet.css" );
295+ File targetStylesheetFile = new File (targetDirectory , "stylesheet.css" );
304296
305297 try {
306298 if (stylesheetFile .isAbsolute ()) {
307- FileUtils .copyFile (stylesheetFile , destStylesheetFile );
299+ FileUtils .copyFile (stylesheetFile , targetStylesheetFile );
308300 } else {
309301 URL stylesheetUrl = this .getClass ().getClassLoader ().getResource (stylesheet );
310- FileUtils .copyURLToFile (stylesheetUrl , destStylesheetFile );
302+ FileUtils .copyURLToFile (stylesheetUrl , targetStylesheetFile );
311303 }
312304 } catch (IOException e ) {
313305 getLog ().warn ("An error occured while copying the stylesheet to the target directory" , e );
314306 }
315307 } else {
316308 if (javadocTemplatesVersion .isAtLeast ("1.8" )) {
317- copyResources (dir , "jdk8/" , "stylesheet.css" );
309+ copyResources (targetDirectory , "jdk8/" , "stylesheet.css" );
318310 } else if (javadocTemplatesVersion .isAtLeast ("1.7" )) {
319311 String [] jdk7Resources = {
320312 "stylesheet.css" ,
@@ -323,31 +315,31 @@ private void copyRequiredResources(String dir) {
323315 "resources/titlebar.gif" ,
324316 "resources/titlebar_end.gif"
325317 };
326- copyResources (dir , "jdk7/" , jdk7Resources );
318+ copyResources (targetDirectory , "jdk7/" , jdk7Resources );
327319 } else if (javadocTemplatesVersion .isAtLeast ("1.6" )) {
328- copyResources (dir , "jdk6/" , "stylesheet.css" );
320+ copyResources (targetDirectory , "jdk6/" , "stylesheet.css" );
329321 } else if (javadocTemplatesVersion .isAtLeast ("1.4" )) {
330- copyResources (dir , "jdk4/" , "stylesheet.css" );
322+ copyResources (targetDirectory , "jdk4/" , "stylesheet.css" );
331323 } else {
332324 // Fallback to the original stylesheet
333- copyResources (dir , "" , "stylesheet.css" );
325+ copyResources (targetDirectory , "" , "stylesheet.css" );
334326 }
335327 }
336328 }
337329
338330 /**
339331 * Copy styles and related resources to the given directory
340332 *
341- * @param dir the directory to copy the resources to
333+ * @param targetDirectory the target directory to copy the resources to
342334 * @param sourceDirectory resources subdirectory to copy from
343335 * @param files names of files to copy
344336 */
345- private void copyResources (String dir , String sourceDirectory , String ... files ) {
337+ private void copyResources (File targetDirectory , String sourceDirectory , String ... files ) {
346338 try {
347339 for (String file : files ) {
348340 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 );
351343 }
352344 } catch (IOException e ) {
353345 getLog ().warn ("An error occured while copying the resource to the target directory" , e );
@@ -359,14 +351,18 @@ protected MavenProject getProject() {
359351 return project ;
360352 }
361353
362- /**
363- * Returns the Maven session.
364- * @return Maven session
365- */
366354 protected MavenSession getSession () {
367355 return session ;
368356 }
369357
358+ protected List <MavenProject > getReactorProjects () {
359+ return reactorProjects ;
360+ }
361+
362+ protected MojoExecution getMojoExecution () {
363+ return mojoExecution ;
364+ }
365+
370366 /**
371367 * Returns the correct resource bundle according to the locale.
372368 *
@@ -386,7 +382,7 @@ protected void executeReport(Locale locale) throws MavenReportException {
386382 setJavadocTemplatesVersion ();
387383
388384 try {
389- createXref (locale , getDestinationDirectory (), constructSourceDirs ());
385+ createXref (locale , getPluginReportOutputDirectory (), constructSourceDirs ());
390386 } catch (JxrException | IOException e ) {
391387 throw new MavenReportException ("Error while generating the HTML source code of the project." , e );
392388 }
@@ -450,7 +446,6 @@ protected List<String> constructSourceDirs() {
450446 @ Override
451447 public boolean canGenerateReport () {
452448 if (skip ) {
453- getLog ().info ("Skipping JXR." );
454449 return false ;
455450 }
456451
@@ -528,11 +523,12 @@ private Path getJavadocLocation() throws IOException {
528523 }
529524
530525 /**
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()}.
532528 *
533- * @return a String that contains the target directory name
529+ * @return a File for the plugin's report output directory
534530 */
535- protected abstract String getDestinationDirectory ();
531+ protected abstract File getPluginReportOutputDirectory ();
536532
537533 /**
538534 * Abstract method that returns the specified source directories that will be included in the JXR report generation.
0 commit comments