Skip to content

Commit

Permalink
[JXR-185] Consistently evaluate skip parameter in MavenReport#canGene…
Browse files Browse the repository at this point in the history
…rateReport()
  • Loading branch information
michael-o committed Nov 12, 2023
1 parent 0e94f5b commit 7cd3904
Showing 1 changed file with 22 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -377,40 +377,18 @@ protected ResourceBundle getBundle(Locale locale) {
return ResourceBundle.getBundle("jxr-report", locale, this.getClass().getClassLoader());
}

/**
* Checks whether the report can be generated.
*
* @param sourceDirs list of source directories
* @return true if the report could be generated
*/
protected boolean canGenerateReport(List<String> sourceDirs) {
boolean canGenerate = !sourceDirs.isEmpty();

if (isAggregate() && !project.isExecutionRoot()) {
canGenerate = false;
}
return canGenerate;
}

@Override
protected void executeReport(Locale locale) throws MavenReportException {
if (skip) {
getLog().info("Skipping JXR.");
return;
}
List<String> sourceDirs = constructSourceDirs();
if (canGenerateReport(sourceDirs)) {
// init some attributes -- TODO (javadoc)
init();
// init some attributes -- TODO (javadoc)
init();

// determine version of templates to use
setJavadocTemplatesVersion();
// determine version of templates to use
setJavadocTemplatesVersion();

try {
createXref(locale, getDestinationDirectory(), sourceDirs);
} catch (JxrException | IOException e) {
throw new MavenReportException("Error while generating the HTML source code of the project.", e);
}
try {
createXref(locale, getDestinationDirectory(), constructSourceDirs());
} catch (JxrException | IOException e) {
throw new MavenReportException("Error while generating the HTML source code of the project.", e);
}
}

Expand Down Expand Up @@ -471,7 +449,20 @@ protected List<String> constructSourceDirs() {

@Override
public boolean canGenerateReport() {
return canGenerateReport(constructSourceDirs());
if (skip) {
getLog().info("Skipping JXR.");
return false;
}

if (constructSourceDirs().isEmpty()) {
return false;
}

if (isAggregate() && !project.isExecutionRoot()) {
return false;
}

return true;
}

@Override
Expand Down

0 comments on commit 7cd3904

Please sign in to comment.