Skip to content

Commit

Permalink
Upgrade Doxia to 2.x stack - fix 5
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Oct 11, 2024
1 parent 408c9a6 commit 2e31b1e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/main/java/org/codehaus/mojo/taglist/FileAnalyser.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public class FileAnalyser {
* @param tagClasses the array of tag classes to use for searching
*/
public FileAnalyser(TagListReport report, List<TagClass> tagClasses) {
// TODO - direct class TagListReport should not be used,
// we can add a separate args or new class/interface for group of args
multipleLineCommentsOn = report.isMultipleLineComments();
emptyCommentsOn = report.isEmptyComments();
log = report.getLog();
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/codehaus/mojo/taglist/TagListReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class TagListReport extends AbstractMavenReport {
*
* @since 2.4
*/
// TODO rename to sourceFilesLocale
@Parameter(property = "sourceFileLocale", defaultValue = "en")
private String sourceFileLocale;

Expand Down Expand Up @@ -539,10 +540,10 @@ void setSourceFileLocale(String sourceFileLocale) {
*/
public Locale getSourceFileLocale() {
String[] items = sourceFileLocale.split("_");
if (items.length > 3) {
if (sourceFileLocale.isEmpty() || items.length > 3) {
getLog().warn("Invalid java.util.Locale format '" + sourceFileLocale
+ "' for 'sourceFileLocale' use ROOT locale");
return Locale.ROOT;
+ "' for 'sourceFileLocale' using 'ENGLISH' locale");
return Locale.ENGLISH;
}

String language = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public class TaglistReportRenderer extends AbstractMavenReportRenderer {
private ResourceBundle bundle;

/**
* The output path of the site.
* The output path of the report.
*/
private final File siteOutputDirectory;
private final File reportOutputDirectory;

/**
* A list of sorted tag reports.
Expand All @@ -74,7 +74,7 @@ public class TaglistReportRenderer extends AbstractMavenReportRenderer {
public TaglistReportRenderer(TagListReport report, Collection<TagReport> tagReports) {
super(report.getSink());
this.sortedTagReports = new TreeSet<>(tagReports);
this.siteOutputDirectory = report.getReportOutputDirectory();
this.reportOutputDirectory = report.getReportOutputDirectory();
this.showEmptyDetails = report.isShowEmptyDetails();
}

Expand Down Expand Up @@ -208,7 +208,7 @@ private void doCommentLine(FileReport fileReport, Integer lineNumber) {
String link = null;
if (xrefLocation != null) {
String fileLink = xrefLocation + "/" + fileReport.getClassNameWithSlash() + ".html";
File xrefFile = new File(siteOutputDirectory, fileLink.substring(2));
File xrefFile = new File(reportOutputDirectory, fileLink.substring(2));

// Link only if file exists in xref
if (xrefFile.exists()) {
Expand All @@ -218,7 +218,7 @@ private void doCommentLine(FileReport fileReport, Integer lineNumber) {
// If the file was not linked to xref and there is a test xref location check it
if (link == null && testXrefLocation != null) {
String testFileLink = testXrefLocation + "/" + fileReport.getClassNameWithSlash() + ".html";
File testXrefFile = new File(siteOutputDirectory, testFileLink.substring(2));
File testXrefFile = new File(reportOutputDirectory, testFileLink.substring(2));

// Link only if file exists in test xref
if (testXrefFile.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ static Stream<Arguments> sourceFileLocaleParserTest() {
of("en", new Locale("en")),
of("en_US", new Locale("en", "US")),
of("en_US_win", new Locale("en", "US", "win")),
of("en_US_win_XX", Locale.ROOT),
of("", Locale.ROOT));
of("en_US_win_XX", Locale.ENGLISH),
of("", Locale.ENGLISH));
}

@ParameterizedTest
Expand Down

0 comments on commit 2e31b1e

Please sign in to comment.