从 gradle 中找不到 Asciidoctor 'snippets' 属性

标签 asciidoctor spring-restdocs

我正在遵循 Spring Rest 文档引用文档中有关构建配置的说明。但当我尝试这样做时,“snippets”属性似乎并未暴露给 Asciidoctor

include::{snippets}/....

但我得到一个 asciidoctor “警告:删除包含对缺失属性的引用的行:片段”

如果我删除属性引用并直接放入路径中,则会出现包含文件的内容。

这是包含 Rest Docs/Asciidoctor 信息的 build.gradle 文件:

buildscript {
    ext {
        springBootVersion = '1.3.0.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

plugins {
    id "org.asciidoctor.convert" version "1.5.3"
}


allprojects {
    apply plugin: 'groovy'
    apply plugin: 'idea'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8
    group = 'com....'

    ext {
        si = [version: '4.1.7.RELEASE']
        groovy = [version: '2.4.5']
        newRelic = [version: '3.13.0']
        jackson = [version: '2.6.2']
    }

    repositories {
        mavenCentral()
        maven {
            url "http://artifacts...."
        }
        maven {
            url "http://artifacts..../public-snapshots/"
        }
    }

    sourceSets {
        main {
            groovy {
                srcDirs = ['src/main/groovy']
            }
        }
    }

    test {
        include "**/*Test.*"
        exclude "**/*TestBase.*"
        exclude "**/*IntegrationTest.*"
    }

    configurations {
        all*.exclude group: 'org.eclipse.persistence'
        all*.exclude group: 'org.codehaus.jackson'
        all*.exclude group: 'org.slf4j', module: 'log4j-over-slf4j'
        all*.exclude group: 'log4j'
    }

    dependencies {
        compile "org.codehaus.groovy:groovy-all:${groovy.version}"
        compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${jackson.version}"
        compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${jackson.version}"
        compile 'org.mockito:mockito-core:+'
        testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc:1.0.1.RELEASE'
    }

    task wrapper(type: Wrapper) {
        gradleVersion = '2.9'
    }
}

ext {
    snippetsDir = file('build/generated-snippets')
}

test {
    outputs.dir snippetsDir
}

asciidoctor {
    attributes 'snippets': snippetsDir
    inputs.dir snippetsDir
    dependsOn test
}

project(':...') {
    dependencies {
        compile project(':...')
    }
}

谢谢。

最佳答案

您可以在 api-guide.adoc 中添加一个名为 snippets 的属性,该属性指向 snippetsDir 的路径。

:snippets: ../../../build/generated-snippets

关于从 gradle 中找不到 Asciidoctor 'snippets' 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34321308/

相关文章:

java - 从 spring Rest 文档生成 ascii doc api 文档

spring - 如何使用 Spring REST Docs 创建一个 curl 片段以使用双引号而不是单引号?

html - asciidoctor 是否有设置从它输出的源中删除 <paragraph> 和 <p> 标签?

java - Spring 休息文档。生成片段时无效的 UTF-8 中间字节

ms-word - 将 AsciiDoc 映射到 docx 模板

asciidoc - 有条件地包含在 asciidoc 中

java - 尝试获取包括使用 AsciiDoc Java 接口(interface)

spring-restdocs - 使用 Spring REST Docs 记录响应状态

spring-boot - 如何在spring RestDoc(asciidoc)中折叠TOC(目录)?

java - JsonParseException : Invalid UTF-8 middle byte 0x20 with MockMVC and Maven