봄 휴식 문서 용 getting started guide을 한 단어 씩 따라 갔지만 생성 된 스 니펫에서 HTML을 가져올 수 없습니다.봄 레스트 문서가 HTML을 생성하지 않음
스 니펫은 내가 구성한 디렉토리 (빌드/generated-snippets)에서 제대로 생성되지만 스 니펫에서 생성 된 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'
}
간단한 테스트 파일 I 테스트에 사용
@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가 없다. 나는 내가 필요하다고 생각했다. 그러나 나는 그것을 집기 위해 어디에 두어야하는지 명확하지 않다? [documentation] (http://docs.spring.io/spring-restdocs/docs/1.0.x/reference/html5/#getting-started-using-the-snippets)은 약간 명확하지 않습니다. asciiidoc gradle plugin 코드를 파헤 쳐서 나는 [문서가 말하는 것]을 바꾸려고했다. (http://docs.spring.io/spring-restdocs/docs/1.0.x/reference/html5/#getting-started-build- configuration-gradle) 4 (변경된 inputs.dir을 sourceDir로 변경)에서 html 파일을 빌드/asciidoc/html로 볼 수 있습니다. 이는 문서 오류입니까? – Francesco
아니요, 실수가 아닙니다. 생성 된 snippets 디렉토리를 테스트 작업의 출력과 asciidoctor 작업의 입력으로 설정하면 Gradle이 작업 종속성을 파악하고 정확한 최신 검사를 수행 할 수 있습니다. –