我正在遵循 Spring Rest Docs 参考文档中关于构建配置的说明。但是当我尝试做时,'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(':...')
}
}
谢谢。