我将gradle与asciidoctor-gradle-plugin
一起使用以varioius格式生成文档。我的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'
有人知道如何解决吗?
答案 0 :(得分:1)
作为解决方法,您可以尝试使用旧版本的asciidoctor-gradle-plugin
,例如
org.asciidoctor:asciidoctor-gradle-plugin:1.5.8
我不确定这些版本之间有什么区别,但1.5.8似乎对我有用。