2016-03-04 53 views
0

我跟着的testng示例spring-restdocs 1.1.0.BUILD-SNAPSHOT。我能夠通過gradle生成adoc文件。但是當我使用maven時,它不生成doc文件。spring-restdocs 1.1.0.BUILD-SNAPSHOT maven不生成adoc文件

MMY 的pom.xml的詳細信息如下:

<dependency> 
    <groupId>org.springframework.restdocs</groupId> 
    <artifactId>spring-restdocs-mockmvc</artifactId> 
    <version>1.1.0.BUILD-SNAPSHOT</version> 
    <scope>test</scope> 
</dependency> 
<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <configuration> 
     <includes> 
      <include>**/*TestNgApplicationTests.java</include> 
     </includes> 
    </configuration> 
</plugin> 
<plugin> 
    <groupId>org.asciidoctor</groupId> 
    <artifactId>asciidoctor-maven-plugin</artifactId> 
    <version>1.5.2.1</version> 
    <executions> 
     <execution> 
      <id>generate-docs</id> 
      <phase>prepare-package</phase> 
      <goals> 
       <goal>process-asciidoc</goal> 
      </goals> 
      <configuration> 
       <backend>html</backend> 
       <doctype>book</doctype> 
       <attributes> 
        <snippets>${snippetsDirectory}</snippets> 
       </attributes> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
<plugin> 
    <artifactId>maven-resources-plugin</artifactId> 
    <executions> 
     <execution> 
      <id>copy-resources</id> 
      <phase>prepare-package</phase> 
      <goals> 
       <goal>copy-resources</goal> 
      </goals> 
      <configuration> 
       <outputDirectory>${project.build.directory}/classes/static/docs</outputDirectory> 
       <resources> 
        <resource> 
         <directory>${project.build.directory}/generated-docs</directory> 
        </resource> 
       </resources> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 
+0

哪裏位於你的'.adoc'文件? Maven Asciidoctor插件對Gradle Asciidoctor插件使用了不同的默認位置 –

回答

2

嘗試使用此命令從終端運行:

$> mvn package 
  • 生成的文件應該是/target下。
    • 生成片段應該在/target/generated-snippets下。
    • 生成.html應該在/target/generated-docs下。

請確保您有您的生成,片段目錄配置爲/目標目錄上您的測試類:

@Rule 
public RestDocumentation restDocumentation = 
    new RestDocumentation("target/generated-snippets"); 
+0

謝謝,之前我使用的是TestNG測試用例,它不生成文檔,但是最新的restdocs版本能夠生成文檔 –