Skip to content

Commit

Permalink
Upgrade Doxia to 2.x stack (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski authored Oct 11, 2024
1 parent 909b510 commit 6599b57
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 258 deletions.
73 changes: 30 additions & 43 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@

<properties>
<project.build.outputTimestamp>2024-07-03T21:22:33Z</project.build.outputTimestamp>
<doxiaVersion>1.12.0</doxiaVersion>
<doxia-sitetoolsVersion>1.11.1</doxia-sitetoolsVersion>
<doxiaVersion>2.0.0</doxiaVersion>
<reportingApiVersion>4.0.0</reportingApiVersion>
<reportingImplVersion>4.0.0-M15</reportingImplVersion>
<mavenResolverVersion>1.4.1</mavenResolverVersion>

<!-- override plugins -->
<taglist-maven-plugin.version>${project.version}</taglist-maven-plugin.version>
Expand Down Expand Up @@ -161,60 +163,21 @@
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
<version>3.1.1</version>
<version>${reportingApiVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>3.1.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
</exclusion>
</exclusions>
<version>${reportingImplVersion}</version>
</dependency>

<!-- Doxia -->
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-core</artifactId>
<version>${doxiaVersion}</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-sink-api</artifactId>
<version>${doxiaVersion}</version>
</dependency>

<!-- Doxia-sitetools -->
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-site-renderer</artifactId>
<version>${doxia-sitetoolsVersion}</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- others -->
<dependency>
<groupId>org.apache.commons</groupId>
Expand All @@ -233,11 +196,28 @@
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-connector-basic</artifactId>
<version>${mavenResolverVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-transport-http</artifactId>
<version>${mavenResolverVersion}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
Expand Down Expand Up @@ -303,6 +283,9 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Duser.language=en</argLine>
<systemPropertyVariables>
<localRepository>${settings.localRepository}</localRepository>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -357,6 +340,10 @@

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>taglist-maven-plugin</artifactId>
Expand Down
26 changes: 11 additions & 15 deletions src/main/java/org/codehaus/mojo/taglist/FileAnalyser.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -73,7 +72,7 @@ public class FileAnalyser {
/**
* The Locale of the files to analyze.
*/
private final Locale locale;
private final Locale sourceFileLocale;

/**
* The directories to analyze.
Expand Down Expand Up @@ -117,12 +116,14 @@ 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();
sourceDirs = report.getSourceDirs();
encoding = report.getInputEncoding();
locale = report.getLocale();
sourceFileLocale = report.getSourceFileLocale();
this.tagClasses = tagClasses;
this.includes = report.getIncludesCommaSeparated();
this.excludes = report.getExcludesCommaSeparated();
Expand All @@ -133,7 +134,7 @@ public FileAnalyser(TagListReport report, List<TagClass> tagClasses) {
*
* @return a collection of TagReport objects.
*/
public Collection<TagReport> execute() {
public Collection<TagReport> execute() throws IOException {
List<File> fileList = findFilesToScan();

for (File file : fileList) {
Expand All @@ -156,15 +157,10 @@ public Collection<TagReport> execute() {
*
* @return a List of File objects.
*/
private List<File> findFilesToScan() {
private List<File> findFilesToScan() throws IOException {
List<File> filesList = new ArrayList<>();
try {
for (String sourceDir : sourceDirs) {
filesList.addAll(FileUtils.getFiles(new File(sourceDir), includes, excludes));
}
} catch (IOException e) {
// TODO - fix with Doxia 2.x - canGenerateReport will have a checked exception
throw new UncheckedIOException("Error while trying to find the files to scan.", e);
for (String sourceDir : sourceDirs) {
filesList.addAll(FileUtils.getFiles(new File(sourceDir), includes, excludes));
}
return filesList;
}
Expand All @@ -173,8 +169,8 @@ private List<File> findFilesToScan() {
* Access an input reader that uses the current file encoding.
*
* @param file the file to open in the reader.
* @throws IOException the IO exception.
* @return a reader with the current file encoding.
* @throws IOException the IO exception.
*/
private Reader getReader(File file) throws IOException {
InputStream in = Files.newInputStream(file.toPath());
Expand All @@ -194,7 +190,7 @@ public void scanFile(File file) {
int index;
// look for a tag on this line
for (TagClass tagClass : tagClasses) {
index = tagClass.tagMatchContains(currentLine, locale);
index = tagClass.tagMatchContains(currentLine, sourceFileLocale);
if (index != TagClass.NO_MATCH) {
// there's a tag on this line
String commentType = extractCommentType(currentLine, index);
Expand Down Expand Up @@ -247,7 +243,7 @@ public void scanFile(File file) {
// try to look if the next line is not a new tag
boolean newTagFound = false;
for (TagClass tc : tagClasses) {
if (tc.tagMatchStartsWith(currentComment, locale)) {
if (tc.tagMatchStartsWith(currentComment, sourceFileLocale)) {
newTagFound = true;
break;
}
Expand Down
Loading

0 comments on commit 6599b57

Please sign in to comment.