【问题标题】:Asciidoctor 'snippets' attribute not found from gradle从 gradle 中找不到 Asciidoctor 'snippets' 属性
【发布时间】:2015-12-16 20:18:50
【问题描述】:

我正在遵循 Spring Rest Docs 参考文档中关于构建配置的说明。但是当我尝试做时,'sn-ps' 属性似乎没有暴露给 Asciidoctor

include::{snippets}/....

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

如果我去掉属性引用,直接放入路径,就会出现包含文件的内容。

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

谢谢。

【问题讨论】:

  • 您的意思是要在外部项目上应用和配置 Asciidoctor 插件吗?我想知道是否没有设置属性,因为 build/generated-snippets 文件夹相对于该项目不存在。如果不是这样,使用--debug 运行构建将显示正在运行的asciidoctor 命令。你能用调试输出的相关部分更新问题吗?
  • 我最初在项目 build.gradle 中有所有与 asciidoctor 相关的条目,但它仍然不起作用,所以我将其移至父级。我使用 --debug 运行构建,但没有看到来自 asciidoctor 的任何命令——只是显示它找到了 jar 文件和版本以及它是否来自 maven 存储库的行。我也没有找到对“sn-ps”的任何引用,以防万一在这方面产生了任何东西。我还将“testCompile”移动到项目 gradle 文件中(受影响的测试在项目处于父级别时正在运行)。
  • 你运行了什么命令? ./gradlew asciidoctor --debug 应该可以解决问题。

标签: asciidoctor spring-restdocs


【解决方案1】:

可以在api-guide.adoc中添加一个名为sn-ps的属性,指向sn-psDir的路径。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-14
    • 2016-02-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多