当定义了多个后端时,asciidoctorj-pdf 会产生 ArrayIndexOutOfBoundsException

asciidoctorj-pdf produces ArrayIndexOutOfBoundsException when more than one backends are defined

我使用 gradle 和 asciidoctor-gradle-plugin 来生成各种格式的文档。我的 build.gradle 看起来像:

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
      classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.9.2'
      classpath 'org.asciidoctor:asciidoctorj-diagram:1.5.0'
      classpath 'org.asciidoctor:asciidoctorj-pdf:1.5.0-alpha.16'
   }
}

apply plugin: 'java'
apply plugin: 'org.asciidoctor.convert'


asciidoctorj {
    version = '1.6.0'
}

asciidoctor {
    resources{
        from('src/images')
        into './images'
    }
    backends 'pdf', 'docbook', 'html5'
    requires 'asciidoctor-diagram'
    sourceDir = file('src/')
    outputDir = file('build/')
    attributes \
        'imagesoutdir': "./images"
}

asciidoctor 任务是 运行 时,我得到错误:

10:09:08 AM: Executing task 'asciidoctor'...

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at org.asciidoctor.internal.EnvironmentInjector.inject(EnvironmentInjector.java:31)
    at org.asciidoctor.internal.JRubyAsciidoctor.injectEnvironmentVariables(JRubyAsciidoctor.java:142)
    at org.asciidoctor.internal.JRubyAsciidoctor.createJRubyAsciidoctorInstance(JRubyAsciidoctor.java:129)
    at org.asciidoctor.internal.JRubyAsciidoctor.create(JRubyAsciidoctor.java:82)
    at org.asciidoctor.Asciidoctor$Factory.create(Asciidoctor.java:726)
    at org.asciidoctor.gradle.backported.AsciidoctorJavaExec.getAsciidoctorInstance(AsciidoctorJavaExec.groovy:73)
    at org.asciidoctor.gradle.backported.AsciidoctorJavaExec.run(AsciidoctorJavaExec.groovy:39)
    at org.asciidoctor.gradle.backported.AsciidoctorJavaExec.main(AsciidoctorJavaExec.groovy:195)
:asciidoctor FAILED

奇怪的是,当 backends 正好设置为一个

时,错误消失了
backends 'pdf'

有人知道怎么解决吗?

作为解决方法,您可以尝试使用旧版本的 asciidoctor-gradle-plugin,例如

org.asciidoctor:asciidoctor-gradle-plugin:1.5.8

我不太确定这些版本之间有什么区别,但 1.5.8 似乎适合我。