Asciidoctor'片段'从gradle找不到属性

时间:2015-12-16 20:18:50

标签: asciidoctor spring-restdocs

我按照Spring Rest Docs参考文档中有关构建配置的说明进行操作。但是'片段'当我尝试

时,属性似乎没有暴露给Asciidoctor
include::{snippets}/....

但是我得到了一个asciidoctor"警告:删除包含对缺失属性的引用的行:snippets"

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

这是包含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(':...')
    }
}

感谢。

1 个答案:

答案 0 :(得分:3)

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

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