인프런 커뮤니티 질문&답변
RestDocs snippets 경로 질문
해결된 질문
작성
·
270
·
수정됨
0

bootJar.enabled = true
jar.enabled = false
configurations {
asciidoctorExt
}
ext {
snippetsDir = file('build/generated-snippets')
}
dependencies {
implementation project(":core:core-domain")
implementation project(":storage:db-main")
implementation project(":support:logging")
implementation project(":tests:api-docs")
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'io.jsonwebtoken:jjwt-api:0.12.3'
implementation 'io.jsonwebtoken:jjwt-impl:0.12.3'
implementation 'io.jsonwebtoken:jjwt-jackson:0.12.3'
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
}
tasks.register('restDocsTest', Test) {
group = 'verification'
useJUnitPlatform {
includeTags('restdocs')
}
}
asciidoctor {
inputs.dir snippetsDir
configurations 'asciidoctorExt'
sources {
include ("**/index.adoc")
}
baseDirFollowsSourceFile()
dependsOn restDocsTest
}냅다 이미지 투척해서 죄송합니다.
위의는 RestDocs Test가 포함된 하위 모듈의 그래들 입니다.
멀티모듈이긴한데 경로는 강의랑 딱히 다를 거 없을 거 같아서했다가 상위로 5번이나 이동 시켜야 정상 작동하네요,,
{docDir}이 src/docs/asciidoc 까지 잡혀가지고
그런 거 같은데
이거 설정은 어디서 할 수 있을까요,,
답변 2
1
안녕하세요, 아효 님!
혹시 설정을 변경하고 싶은 이유가 있을까요?
사실 한번 설정해두면 변경할 일이 거의 없어서 저도 상대경로로 지정해놓고 사용하는데요 ㅎㅎ
저도 자세히 확인해보지는 못했지만 아마 gradle asciidoctor에서 attributes 'snippets': file('build/generated-snippets') 와 같은 형태로 관련된 설정을 할 수 있는 것 같아서, 만약 원하신다면 한번 이런 형태로 시도해 보셔야 할 것 같아요.
감사합니다 🙂
0
안녕하세요, 인프런 AI 인턴입니다. 아효님.
Spring REST Docs에서 생성된 snippets 파일의 경로 문제로 고민하고 계시군요. 경로 문제는 프로젝트 구조와 관련된 사항입니다.
멀티모듈 프로젝트에서 각 모듈의 상대 경로를 관리하는 것은 조금 복잡할 수 있습니다. 강의에서와 같은 단일 모듈 프로젝트와 멀티모듈 프로젝트에서는 상대 경로 계산이 달라질 수 있어요.
해법 요약:
- 상대 경로 확인: 현재 경로에서 snippets가 생성되는 디렉토리까지의 경로를 다시 확인해 보셔야 합니다.
- 절대 경로 사용 (테스트용): 이를 위해 절대 경로를 사용하면 일관된 결과를 얻을 수 있습니다.
아래는 문제를 해결하기 위해 적용할 수 있는 몇 가지 방법입니다.
URL과 관련 참고
- Spring RestDocs 설정 예시:
- Spring RestDocs 설정과 관련된 문제를 풀기 위해 기존 사용자들의 해결책을 확인해 보세요. 예를 들어, 프로젝트 구조와 경로 설정 문제를 다루는 답변들입니다.
- Spring REST Docs 관련 질문
- REST Docs 관련 질문
- Spring RestDocs 설정과 관련된 문제를 풀기 위해 기존 사용자들의 해결책을 확인해 보세요. 예를 들어, 프로젝트 구조와 경로 설정 문제를 다루는 답변들입니다.
- 멀티모듈 프로젝트와 경로 문제:
- 멀티모듈 프로젝트에서 경로 문제를 해결한 다른 사용자들의 경험을 참고해 보세요.
- Spring Rest Docs 강의 질문이 있습니다
- Spring REST Docs 관련 문제 해결
- 멀티모듈 프로젝트에서 경로 문제를 해결한 다른 사용자들의 경험을 참고해 보세요.
경로 문제 해결을 위한 조언
상대 경로 설정
ext { snippetsDir = file('build/generated-snippets') } asciidoctor { inputs.dir snippetsDir configurations 'asciidoctorExt' sources { include("**/index.adoc") } baseDirFollowsSourceFile() dependsOn test }절대 경로 사용
ext { snippetsDir = file("$buildDir/generated-snippets") } asciidoctor { inputs.dir snippetsDir configurations 'asciidoctorExt' sources { include("**/index.adoc") } baseDirFollowsSourceFile() dependsOn test }
원본 URL
저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다.
현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏
추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.





