From a630b7cb176456de89aa11c51d35084c2ebd5c42 Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Sun, 12 Jun 2022 20:20:01 +0200 Subject: [PATCH] Make plugin compatible with maven-site-plugin 4.0.0-M1 (#585) * Bump Doxia to 2.0.0-M1 * Leave note in docs for release * Use SLF4J in site module (https://github.com/apache/maven-doxia/pull/5) * Reorder constructor args in AsciidoctorDoxiaParserModule * Update IT test site.xml Fixes #578 --- .../src/it/maven-site-plugin/pom.xml | 4 ++-- .../src/it/maven-site-plugin/src/site/site.xml | 2 +- .../maven/site/AsciidoctorDoxiaParser.java | 15 +++++++++------ .../pages/compatibility-matrix.adoc | 5 +++++ 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/asciidoctor-doxia-module/src/it/maven-site-plugin/pom.xml b/asciidoctor-doxia-module/src/it/maven-site-plugin/pom.xml index 26a95a60..50de649d 100644 --- a/asciidoctor-doxia-module/src/it/maven-site-plugin/pom.xml +++ b/asciidoctor-doxia-module/src/it/maven-site-plugin/pom.xml @@ -22,14 +22,14 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.1.2 + 3.3.0 org.apache.maven.plugins maven-site-plugin - 3.12.0 + 4.0.0-M1 ${project.basedir}/src/site/asciidoc diff --git a/asciidoctor-doxia-module/src/it/maven-site-plugin/src/site/site.xml b/asciidoctor-doxia-module/src/it/maven-site-plugin/src/site/site.xml index 31e63818..f9e73e29 100644 --- a/asciidoctor-doxia-module/src/it/maven-site-plugin/src/site/site.xml +++ b/asciidoctor-doxia-module/src/it/maven-site-plugin/src/site/site.xml @@ -1,8 +1,8 @@ + - ${reports} diff --git a/asciidoctor-doxia-module/src/main/java/org/asciidoctor/maven/site/AsciidoctorDoxiaParser.java b/asciidoctor-doxia-module/src/main/java/org/asciidoctor/maven/site/AsciidoctorDoxiaParser.java index 65ee0c82..a6da8571 100644 --- a/asciidoctor-doxia-module/src/main/java/org/asciidoctor/maven/site/AsciidoctorDoxiaParser.java +++ b/asciidoctor-doxia-module/src/main/java/org/asciidoctor/maven/site/AsciidoctorDoxiaParser.java @@ -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 the Doxia framework @@ -33,6 +34,8 @@ @Component(role = Parser.class, hint = AsciidoctorDoxiaParser.ROLE_HINT) public class AsciidoctorDoxiaParser extends AbstractTextParser { + private Logger logger = LoggerFactory.getLogger(AsciidoctorDoxiaParser.class); + @Inject protected Provider mavenProjectProvider; @@ -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; } @@ -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); @@ -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; } @@ -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()); } } } diff --git a/docs/modules/site-integration/pages/compatibility-matrix.adoc b/docs/modules/site-integration/pages/compatibility-matrix.adoc index 3d43d1d0..fd4138f8 100644 --- a/docs/modules/site-integration/pages/compatibility-matrix.adoc +++ b/docs/modules/site-integration/pages/compatibility-matrix.adoc @@ -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