Skip to content

Commit 6599b57

Browse files
Upgrade Doxia to 2.x stack (#160)
1 parent 909b510 commit 6599b57

File tree

7 files changed

+255
-258
lines changed

7 files changed

+255
-258
lines changed

pom.xml

Lines changed: 30 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@
105105

106106
<properties>
107107
<project.build.outputTimestamp>2024-07-03T21:22:33Z</project.build.outputTimestamp>
108-
<doxiaVersion>1.12.0</doxiaVersion>
109-
<doxia-sitetoolsVersion>1.11.1</doxia-sitetoolsVersion>
108+
<doxiaVersion>2.0.0</doxiaVersion>
109+
<reportingApiVersion>4.0.0</reportingApiVersion>
110+
<reportingImplVersion>4.0.0-M15</reportingImplVersion>
111+
<mavenResolverVersion>1.4.1</mavenResolverVersion>
110112

111113
<!-- override plugins -->
112114
<taglist-maven-plugin.version>${project.version}</taglist-maven-plugin.version>
@@ -161,60 +163,21 @@
161163
<dependency>
162164
<groupId>org.apache.maven.reporting</groupId>
163165
<artifactId>maven-reporting-api</artifactId>
164-
<version>3.1.1</version>
166+
<version>${reportingApiVersion}</version>
165167
</dependency>
166168
<dependency>
167169
<groupId>org.apache.maven.reporting</groupId>
168170
<artifactId>maven-reporting-impl</artifactId>
169-
<version>3.1.0</version>
170-
<exclusions>
171-
<exclusion>
172-
<groupId>org.apache.maven</groupId>
173-
<artifactId>maven-core</artifactId>
174-
</exclusion>
175-
<exclusion>
176-
<groupId>org.apache.maven</groupId>
177-
<artifactId>maven-plugin-api</artifactId>
178-
</exclusion>
179-
</exclusions>
171+
<version>${reportingImplVersion}</version>
180172
</dependency>
181173

182174
<!-- Doxia -->
183-
<dependency>
184-
<groupId>org.apache.maven.doxia</groupId>
185-
<artifactId>doxia-core</artifactId>
186-
<version>${doxiaVersion}</version>
187-
<scope>runtime</scope>
188-
<exclusions>
189-
<exclusion>
190-
<groupId>org.codehaus.plexus</groupId>
191-
<artifactId>plexus-container-default</artifactId>
192-
</exclusion>
193-
</exclusions>
194-
</dependency>
195175
<dependency>
196176
<groupId>org.apache.maven.doxia</groupId>
197177
<artifactId>doxia-sink-api</artifactId>
198178
<version>${doxiaVersion}</version>
199179
</dependency>
200180

201-
<!-- Doxia-sitetools -->
202-
<dependency>
203-
<groupId>org.apache.maven.doxia</groupId>
204-
<artifactId>doxia-site-renderer</artifactId>
205-
<version>${doxia-sitetoolsVersion}</version>
206-
<exclusions>
207-
<exclusion>
208-
<groupId>org.apache.maven</groupId>
209-
<artifactId>maven-artifact</artifactId>
210-
</exclusion>
211-
<exclusion>
212-
<groupId>org.codehaus.plexus</groupId>
213-
<artifactId>plexus-container-default</artifactId>
214-
</exclusion>
215-
</exclusions>
216-
</dependency>
217-
218181
<!-- others -->
219182
<dependency>
220183
<groupId>org.apache.commons</groupId>
@@ -233,11 +196,28 @@
233196
<version>3.3.0</version>
234197
<scope>test</scope>
235198
</dependency>
199+
<dependency>
200+
<groupId>org.apache.maven.resolver</groupId>
201+
<artifactId>maven-resolver-connector-basic</artifactId>
202+
<version>${mavenResolverVersion}</version>
203+
<scope>test</scope>
204+
</dependency>
205+
<dependency>
206+
<groupId>org.apache.maven.resolver</groupId>
207+
<artifactId>maven-resolver-transport-http</artifactId>
208+
<version>${mavenResolverVersion}</version>
209+
<scope>test</scope>
210+
</dependency>
236211
<dependency>
237212
<groupId>org.junit.jupiter</groupId>
238213
<artifactId>junit-jupiter-api</artifactId>
239214
<scope>test</scope>
240215
</dependency>
216+
<dependency>
217+
<groupId>org.junit.jupiter</groupId>
218+
<artifactId>junit-jupiter-params</artifactId>
219+
<scope>test</scope>
220+
</dependency>
241221
<dependency>
242222
<groupId>org.junit.vintage</groupId>
243223
<artifactId>junit-vintage-engine</artifactId>
@@ -303,6 +283,9 @@
303283
<artifactId>maven-surefire-plugin</artifactId>
304284
<configuration>
305285
<argLine>-Duser.language=en</argLine>
286+
<systemPropertyVariables>
287+
<localRepository>${settings.localRepository}</localRepository>
288+
</systemPropertyVariables>
306289
</configuration>
307290
</plugin>
308291
<plugin>
@@ -357,6 +340,10 @@
357340

358341
<reporting>
359342
<plugins>
343+
<plugin>
344+
<groupId>org.apache.maven.plugins</groupId>
345+
<artifactId>maven-jxr-plugin</artifactId>
346+
</plugin>
360347
<plugin>
361348
<groupId>org.codehaus.mojo</groupId>
362349
<artifactId>taglist-maven-plugin</artifactId>

src/main/java/org/codehaus/mojo/taglist/FileAnalyser.java

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.io.InputStreamReader;
2626
import java.io.LineNumberReader;
2727
import java.io.Reader;
28-
import java.io.UncheckedIOException;
2928
import java.nio.file.Files;
3029
import java.util.ArrayList;
3130
import java.util.Collection;
@@ -73,7 +72,7 @@ public class FileAnalyser {
7372
/**
7473
* The Locale of the files to analyze.
7574
*/
76-
private final Locale locale;
75+
private final Locale sourceFileLocale;
7776

7877
/**
7978
* The directories to analyze.
@@ -117,12 +116,14 @@ public class FileAnalyser {
117116
* @param tagClasses the array of tag classes to use for searching
118117
*/
119118
public FileAnalyser(TagListReport report, List<TagClass> tagClasses) {
119+
// TODO - direct class TagListReport should not be used,
120+
// we can add a separate args or new class/interface for group of args
120121
multipleLineCommentsOn = report.isMultipleLineComments();
121122
emptyCommentsOn = report.isEmptyComments();
122123
log = report.getLog();
123124
sourceDirs = report.getSourceDirs();
124125
encoding = report.getInputEncoding();
125-
locale = report.getLocale();
126+
sourceFileLocale = report.getSourceFileLocale();
126127
this.tagClasses = tagClasses;
127128
this.includes = report.getIncludesCommaSeparated();
128129
this.excludes = report.getExcludesCommaSeparated();
@@ -133,7 +134,7 @@ public FileAnalyser(TagListReport report, List<TagClass> tagClasses) {
133134
*
134135
* @return a collection of TagReport objects.
135136
*/
136-
public Collection<TagReport> execute() {
137+
public Collection<TagReport> execute() throws IOException {
137138
List<File> fileList = findFilesToScan();
138139

139140
for (File file : fileList) {
@@ -156,15 +157,10 @@ public Collection<TagReport> execute() {
156157
*
157158
* @return a List of File objects.
158159
*/
159-
private List<File> findFilesToScan() {
160+
private List<File> findFilesToScan() throws IOException {
160161
List<File> filesList = new ArrayList<>();
161-
try {
162-
for (String sourceDir : sourceDirs) {
163-
filesList.addAll(FileUtils.getFiles(new File(sourceDir), includes, excludes));
164-
}
165-
} catch (IOException e) {
166-
// TODO - fix with Doxia 2.x - canGenerateReport will have a checked exception
167-
throw new UncheckedIOException("Error while trying to find the files to scan.", e);
162+
for (String sourceDir : sourceDirs) {
163+
filesList.addAll(FileUtils.getFiles(new File(sourceDir), includes, excludes));
168164
}
169165
return filesList;
170166
}
@@ -173,8 +169,8 @@ private List<File> findFilesToScan() {
173169
* Access an input reader that uses the current file encoding.
174170
*
175171
* @param file the file to open in the reader.
176-
* @throws IOException the IO exception.
177172
* @return a reader with the current file encoding.
173+
* @throws IOException the IO exception.
178174
*/
179175
private Reader getReader(File file) throws IOException {
180176
InputStream in = Files.newInputStream(file.toPath());
@@ -194,7 +190,7 @@ public void scanFile(File file) {
194190
int index;
195191
// look for a tag on this line
196192
for (TagClass tagClass : tagClasses) {
197-
index = tagClass.tagMatchContains(currentLine, locale);
193+
index = tagClass.tagMatchContains(currentLine, sourceFileLocale);
198194
if (index != TagClass.NO_MATCH) {
199195
// there's a tag on this line
200196
String commentType = extractCommentType(currentLine, index);
@@ -247,7 +243,7 @@ public void scanFile(File file) {
247243
// try to look if the next line is not a new tag
248244
boolean newTagFound = false;
249245
for (TagClass tc : tagClasses) {
250-
if (tc.tagMatchStartsWith(currentComment, locale)) {
246+
if (tc.tagMatchStartsWith(currentComment, sourceFileLocale)) {
251247
newTagFound = true;
252248
break;
253249
}

0 commit comments

Comments
 (0)