私はSpring Rest Doc用のgetting started guideを1語ずつフォローしましたが、生成されたスニペットからhtmlを取得できません。春休み用ドックhtmlを作成していません
スニペットは、私は(ビルド/生成-スニペット)を設定ディレクトリに細かい生成されますが、私は、スニペットの外に生成されたHTMLファイルを持つ任意のHTML5 /ディレクトリを参照してくださいすることはできません。
ドキュメントat some pointは、瓶の中のドキュメントをパッケージ化するために何をするかと言うと、それはHTML5 /ディレクトリ内のいくつかのファイルを期待していることは明らかだが、ビルドの実行時にこれが作成されません。
dependsOn asciidoctor
from("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
私は何が欠けていますか?
マイプロジェクトファイル、build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.3.5.RELEASE'
}
}
plugins {
id 'org.asciidoctor.convert' version '1.5.2'
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply plugin: 'jacoco'
apply plugin: 'war'
sourceCompatibility = 1.8
targetCompatibility = 1.8
ext {
snippetsDir = file('build/generated-snippets')
}
repositories {
mavenCentral()
}
dependencies {
compile 'org.springframework.boot:spring-boot-starter-web:1.3.5.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-logging:1.3.5.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-data-jpa:1.3.5.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-data-rest:1.3.5.RELEASE'
compile 'org.springframework.cloud:spring-cloud-starter-aws:1.1.0.RELEASE'
compile 'org.postgresql:postgresql:9.4.1208'
compile 'commons-io:commons-io:2.5'
testCompile 'org.springframework.restdocs:spring-restdocs-mockmvc:1.1.0.RELEASE'
testCompile 'org.springframework.restdocs:spring-restdocs-core:1.1.0.RELEASE'
testCompile 'org.springframework.boot:spring-boot-starter-test:1.3.5.RELEASE'
}
jacoco {
toolVersion = "0.7.6.201602180812"
reportsDir = file("$buildDir/customJacocoReportDir")
}
test {
outputs.dir snippetsDir
jacoco {
append = false
destinationFile = file("$buildDir/jacoco/jacocoTest.exec")
classDumpFile = file("$buildDir/jacoco/classpathdumps")
}
}
asciidoctor {
attributes 'snippets': snippetsDir
inputs.dir snippetsDir
dependsOn test
}
war {
dependsOn asciidoctor
from("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
baseName = project_name
version = version
manifest {
attributes(
'Implementation-Title': project_name,
'Implementation-Version': version
)
}
}
task wrapper(type: Wrapper) {
gradleVersion = '2.13'
}
、簡単なテストファイル私は、テストに使用します。
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
public class ApiDocumentation
{
@Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("build/generated-snippets");
@Autowired
private WebApplicationContext context;
private MockMvc mockMvc;
@Before
public void setUp()
{
mockMvc = MockMvcBuilders.webAppContextSetup(context)
.apply(documentationConfiguration(restDocumentation))
.build();
}
@Test
public void testIndex() throws Exception
{
mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andDo(document("index"));
}
}
生成されたスニペットを含む手書きの '.adoc'ファイルがありますか?また、どのようにビルドを実行していますか? '.adoc'ファイルとスニペットからHTMLを生成するには、' asciidoctor'タスクを実行する必要があります。 –
私は手書きのadocを持っていません。私は1つが必要だと思ったが、拾うためにこれをどこに置くべきかわからない。 [documentation](http://docs.spring.io/spring-restdocs/docs/1.0.x/reference/html5/#getting-started-using-the-snippets)は少し不明です。 asciiidocのgradleプラグインのコードを掘り下げた後、私は[ドキュメントの内容]を変更しようとしました(http://docs.spring.io/spring-restdocs/docs/1.0.x/reference/html5/#getting-started-build- configuration-gradle)をポイント4(入力ディレクトリをsourceDirに変更)でビルド/ asciidoc/htmlでhtmlファイルを見ることができますが、これはドキュメントの間違いですか? – Francesco
いいえ、間違いではありません。生成されたスニペットディレクトリをテストタスクの出力とasciidoctorタスクの入力として設定することで、Gradleはタスクの依存関係を把握し、正確な最新のチェックを実行することができます。 –