Make block switches work on every page of multi-page docs

There's a bug in some versions of AsciidoctorJ where extensions are
only called on this first conversion performed by a given Asciidoctor
instance. This affects the multi-page documentation where there are
multiple conversions performed – one for each page in the
documentation.

This commit upgrades the version of AsciidoctorJ used by the
Asciidoctor Gradle plugin to 2.4.1, which contains fix for the problem.

Closes gh-23709
This commit is contained in:
Andy Wilkinson 2020-10-16 14:44:14 +01:00
parent 2916bb4c10
commit 23073d9e76

View File

@ -46,6 +46,7 @@ import org.springframework.util.StringUtils;
*
* <ul>
* <li>All warnings are made fatal.
* <li>The version of AsciidoctorJ is upgraded to 2.4.1.
* <li>A task is created to resolve and unzip our documentation resources (CSS and
* Javascript).
* <li>For each {@link AsciidoctorTask} (HTML only):
@ -69,10 +70,13 @@ import org.springframework.util.StringUtils;
*/
class AsciidoctorConventions {
private static final String ASCIIDOCTORJ_VERSION = "2.4.1";
void apply(Project project) {
project.getPlugins().withType(AsciidoctorJPlugin.class, (asciidoctorPlugin) -> {
configureDocResourcesRepository(project);
makeAllWarningsFatal(project);
upgradeAsciidoctorJVersion(project);
UnzipDocumentationResources unzipResources = createUnzipDocumentationResourcesTask(project);
project.getTasks().withType(AbstractAsciidoctorTask.class, (asciidoctorTask) -> {
configureCommonAttributes(project, asciidoctorTask);
@ -110,6 +114,10 @@ class AsciidoctorConventions {
project.getExtensions().getByType(AsciidoctorJExtension.class).fatalWarnings(".*");
}
private void upgradeAsciidoctorJVersion(Project project) {
project.getExtensions().getByType(AsciidoctorJExtension.class).setVersion(ASCIIDOCTORJ_VERSION);
}
private UnzipDocumentationResources createUnzipDocumentationResourcesTask(Project project) {
Configuration documentationResources = project.getConfigurations().maybeCreate("documentationResources");
documentationResources.getDependencies()