使用 Spring Restdoc 时配置 asciidoctor
Configuring asciidoctor when using Spring Restdoc
我正在采用 Spring Rest Docs 并且测试成功创建了 *.adoc 文件。
我在 src/docs/asciidoc 目录中创建了 api-guide.doc 文件来创建 html,但是当我 运行 asciidoc 作为 gradle任务,它会产生以下错误。
Some problems were found with the configuration of task ':asciidoctor' (type 'AsciidoctorTask').
- In plugin 'org.asciidoctor.convert' type 'org.asciidoctor.gradle.AsciidoctorTask' method 'asGemPath()' should not be annotated with: @Optional, @InputDirectory.
我用 spring 初始化程序初始化了项目,所以我相信 gradle 依赖项没有问题。
plugins {
id 'org.springframework.boot' version '2.5.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.asciidoctor.convert' version '1.5.8'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
ext {
set('snippetsDir', file("build/generated-snippets"))
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
}
test {
outputs.dir snippetsDir
useJUnitPlatform()
}
asciidoctor {
inputs.dir snippetsDir
dependsOn test
}
可能是什么问题?
一个 update needs to be made to https://start.spring.io 以便它生成与 Gradle 7.
兼容的配置
你可以通过降级到 Gradle 6.x 来避免这个问题,或者你可以通过替换 [=10] 来切换到更新版本的 Asciidoctor Gradle 插件=] 与 id 'org.asciidoctor.jvm.convert' version '3.3.2'
我正在采用 Spring Rest Docs 并且测试成功创建了 *.adoc 文件。
我在 src/docs/asciidoc 目录中创建了 api-guide.doc 文件来创建 html,但是当我 运行 asciidoc 作为 gradle任务,它会产生以下错误。
Some problems were found with the configuration of task ':asciidoctor' (type 'AsciidoctorTask').
- In plugin 'org.asciidoctor.convert' type 'org.asciidoctor.gradle.AsciidoctorTask' method 'asGemPath()' should not be annotated with: @Optional, @InputDirectory.
我用 spring 初始化程序初始化了项目,所以我相信 gradle 依赖项没有问题。
plugins {
id 'org.springframework.boot' version '2.5.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'org.asciidoctor.convert' version '1.5.8'
id 'java'
}
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
ext {
set('snippetsDir', file("build/generated-snippets"))
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
}
test {
outputs.dir snippetsDir
useJUnitPlatform()
}
asciidoctor {
inputs.dir snippetsDir
dependsOn test
}
可能是什么问题?
一个 update needs to be made to https://start.spring.io 以便它生成与 Gradle 7.
兼容的配置你可以通过降级到 Gradle 6.x 来避免这个问题,或者你可以通过替换 [=10] 来切换到更新版本的 Asciidoctor Gradle 插件=] 与 id 'org.asciidoctor.jvm.convert' version '3.3.2'