Skip to content

Commit

Permalink
Make plugin compatible with maven-site-plugin 4.0.0-M1 (asciidoctor#585)
Browse files Browse the repository at this point in the history
* Bump Doxia to 2.0.0-M1
* Leave note in docs for release
* Use SLF4J in site module (apache/maven-doxia#5)
* Reorder constructor args in AsciidoctorDoxiaParserModule
* Update IT test site.xml

Fixes asciidoctor#578
  • Loading branch information
abelsromero committed Oct 17, 2022
1 parent 151d325 commit 7148457
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.1.2</version>
<version>3.3.0</version>
</plugin>
<!-- tag::plugin-decl[] -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<!-- v2.2.2 of the plugin require Maven Site Plugin 3.1x.0 alongside Doxia 1.11.1 -->
<version>3.12.1</version>
<version>4.0.0-M1</version>
<configuration>
<asciidoc>
<baseDir>${project.basedir}/src/site/asciidoc</baseDir>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import javax.inject.Provider;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.logging.Logger;

/**
* This class is used by <a href="https://maven.apache.org/doxia/overview.html">the Doxia framework</a>
Expand All @@ -33,6 +34,8 @@
@Component(role = Parser.class, hint = AsciidoctorConverterDoxiaParser.ROLE_HINT)
public class AsciidoctorConverterDoxiaParser extends AbstractTextParser {

private Logger logger = LoggerFactory.getLogger(AsciidoctorDoxiaParser.class);

@Inject
protected Provider<MavenProject> mavenProjectProvider;

Expand All @@ -52,7 +55,7 @@ public void parse(Reader reader, Sink sink, String reference) throws ParseExcept
source = "";
}
} catch (IOException ex) {
getLog().error("Could not read AsciiDoc source: " + ex.getLocalizedMessage());
logger.error("Could not read AsciiDoc source: " + ex.getLocalizedMessage());
return;
}

Expand All @@ -79,7 +82,7 @@ public void parse(Reader reader, Sink sink, String reference) throws ParseExcept
String asciidocHtml = convertAsciiDoc(asciidoctor, source, conversionConfig.getOptions());
try {
// process log messages according to mojo configuration
new LogRecordsProcessors(logHandler, siteDirectory, errorMessage -> getLog().error(errorMessage))
new LogRecordsProcessors(logHandler, siteDirectory, errorMessage -> logger.error(errorMessage))
.processLogRecords(memoryLogHandler);
} catch (Exception exception) {
throw new ParseException(exception.getMessage(), exception);
Expand All @@ -91,10 +94,10 @@ public void parse(Reader reader, Sink sink, String reference) throws ParseExcept
private MemoryLogHandler asciidoctorLoggingSetup(Asciidoctor asciidoctor, LogHandler logHandler, File siteDirectory) {

final MemoryLogHandler memoryLogHandler = new MemoryLogHandler(logHandler.getOutputToConsole(), siteDirectory,
logRecord -> getLog().info(LogRecordFormatter.format(logRecord, siteDirectory)));
logRecord -> logger.info(LogRecordFormatter.format(logRecord, siteDirectory)));
asciidoctor.registerLogHandler(memoryLogHandler);
// disable default console output of AsciidoctorJ
Logger.getLogger("asciidoctor").setUseParentHandlers(false);
java.util.logging.Logger.getLogger("asciidoctor").setUseParentHandlers(false);
return memoryLogHandler;
}

Expand Down Expand Up @@ -136,7 +139,7 @@ private void requireLibrary(Asciidoctor asciidoctor, String require) {
try {
asciidoctor.requireLibrary(require);
} catch (Exception ex) {
getLog().error(ex.getLocalizedMessage());
logger.error(ex.getLocalizedMessage());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<project name="Maven Site Plugin IT">
<body>
<menu ref="reports"/>
<menu name="AsciiDoc Pages">
<item name="Sample" href="sample.html"/>
</menu>
${reports}
</body>
</project>
5 changes: 5 additions & 0 deletions docs/modules/site-integration/pages/compatibility-matrix.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ Since v3.x.x the Asciidoctor Maven Plugin has been split into independent compon
|===
|Asciidoctor Maven Plugin | Maven Site Plugin | Supported

// TODO uncomment on release
//|v3.0.x
//|v3.1x.x ~ v4.x.x
//|Yes

|v2.2.2
|v3.1x.x
|Yes
Expand Down

0 comments on commit 7148457

Please sign in to comment.