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

Bump doxia-core to v2.0.0-M3 (asciidoctor#590)

* Bump maven-site-plugin in IT to v4.0.0-M3
* Add skin to IT (mandatory since v4.0.0-M2)

Bump maven-site and doxia to latests

* maven-site-plugin v4.0.0-M8
* doxia & fluido skin 2.0.0-M6
* Sections and tables updated

Bump maven-site to M13, Doxia to M8
  • Loading branch information
abelsromero committed Jan 13, 2024
1 parent 2e4b6c5 commit ec75e4b
Show file tree
Hide file tree
Showing 15 changed files with 221 additions and 108 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Bug Fixes::

Improvements::

* Make the site module compatible with maven-site-plugin v4.x.x (#585, #590)
* Split plugin and site integration in sub-modules: asciidoctor-maven-plugin and asciidoctor-doxia-module (#595)
* Add 'asciidoc' as valid file extension in AsciidoctorDoxiaParserModule (#595)
* Fix throwing an exception when registering a non Extension (#596)
Expand Down
55 changes: 52 additions & 3 deletions asciidoctor-converter-doxia-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
<description>Asciidoctor Doxia Parser based on Asciidoctor Html converter (for Maven Site integration)</description>
<url>https://github.com/asciidoctor/asciidoctor-maven-plugin</url>

<properties>
<doxia.version>2.0.0-M8</doxia.version>
<maven.coveralls.plugin.version>4.3.0</maven.coveralls.plugin.version>
<plexus.component.metadata.version>2.1.1</plexus.component.metadata.version>
</properties>

<dependencies>
<dependency>
<groupId>org.asciidoctor</groupId>
Expand All @@ -36,7 +42,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven.version}</version>
<version>${maven.project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -47,7 +53,7 @@
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-site-renderer</artifactId>
<version>1.11.1</version>
<version>${doxia.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -57,7 +63,7 @@
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<version>${plexus-component-metadata.version}</version>
<version>${plexus.component.metadata.version}</version>
<executions>
<execution>
<goals>
Expand All @@ -69,8 +75,51 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>${maven.coveralls.plugin.version}</version>
<dependencies>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<versionRange>[${plexus.component.metadata.version},)</versionRange>
<goals>
<goal>generate-metadata</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.1.2</version>
<version>3.5.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-M13</version>
<configuration>
<asciidoc>
<baseDir>${project.basedir}/src/site/asciidoc</baseDir>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
<version>1.11.1</version>
<version>2.0.0-M6</version>
</skin>
</project>
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 final Logger logger = LoggerFactory.getLogger(AsciidoctorConverterDoxiaParser.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 @@ -90,11 +93,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(),
logRecord -> getLog().info(LogRecordFormatter.format(logRecord, siteDirectory)));
final MemoryLogHandler memoryLogHandler = new MemoryLogHandler(logHandler.getOutputToConsole(), 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 +138,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
56 changes: 52 additions & 4 deletions asciidoctor-parser-doxia-module/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@

<name>Asciidoctor Parser Doxia Module</name>
<description>Asciidoctor Doxia Module based on Asciidoctor AST processing (for Maven Site integration)</description>
<url>https://github.com/asciidoctor/asciidoctor-maven-plugin</url>

<properties>
<doxia.version>2.0.0-M6</doxia.version>
<maven.coveralls.plugin.version>4.3.0</maven.coveralls.plugin.version>
<plexus.component.metadata.version>2.1.1</plexus.component.metadata.version>
</properties>

<dependencies>
<dependency>
Expand All @@ -36,7 +41,7 @@
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>${maven.version}</version>
<version>${maven.project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -52,7 +57,7 @@
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-site-renderer</artifactId>
<version>1.11.1</version>
<version>${doxia.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -62,7 +67,7 @@
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<version>${plexus-component-metadata.version}</version>
<version>${plexus.component.metadata.version}</version>
<executions>
<execution>
<goals>
Expand All @@ -74,8 +79,51 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>${maven.coveralls.plugin.version}</version>
<dependencies>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
</plugin>
</plugins>

<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
<versionRange>[${plexus.component.metadata.version},)</versionRange>
<goals>
<goal>generate-metadata</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.1.2</version>
<version>3.5.0</version>
</plugin>
<!-- tag::plugin-decl[] -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
<version>4.0.0-M8</version>
<configuration>
<asciidoc>
<baseDir>${project.basedir}/src/site/asciidoc</baseDir>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
<project name="Maven Site Plugin IT">
<body>
<menu ref="reports"/>
<menu name="AsciiDoc Pages">
<item name="Sample" href="sample.html"/>
</menu>
${reports}
</body>
<!-- Skins are mandatory since maven-site-plugin v4.0.0-M2 -->
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
<version>2.0.0-M6</version>
</skin>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ class HtmlAsserter {
void containsSectionTitle(String value, int level) {
def found = -1

def id = value.replaceAll(" ", "_")
def id = value.toLowerCase().replaceAll(" ", "_")
if (level == 2) {
found = find("<h2><a name=\"$id\"></a>$value</h2>")
found = find("<h2><a id=\"$id\"></a>$value</h2>")
} else if (level == 3) {
found = find("<h3><a name=\"$id\"></a>$value</h3>")
found = find("<h3><a id=\"$id\"></a>$value</h3>")
} else if (level == 4) {
found = find("<h4><a name=\"$id\"></a>$value</h4>")
found = find("<h4><a id=\"$id\"></a>$value</h4>")
}
assertFound("Section Title (level:$level)", value, found)
}
Expand Down
Loading

0 comments on commit ec75e4b

Please sign in to comment.