Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5기 김용상, 임수진] Spring Boot JPA 게시판 구현 미션 제출합니다. #268

Open
wants to merge 11 commits into
base: suzzingv
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions board/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

.gradle/
.idea/
build/
gradle/
logs/
83 changes: 83 additions & 0 deletions board/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.5'
id 'io.spring.dependency-management' version '1.1.3'
id 'org.asciidoctor.jvm.convert' version '3.3.2'

}

group = 'com.example'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
asciidoctorExt
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
implementation 'org.springframework.boot:spring-boot-starter-validation'
}

ext {
snippetsDir = file('build/generated-snippets')
}

asciidoctor {
inputs.dir snippetsDir
configurations 'asciidoctorExt'
dependsOn test
}

asciidoctor.doFirst {
delete file("src/main/resources/static/docs")
}

bootJar {
dependsOn asciidoctor
from("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
}

task copyDocument(type: Copy) {
dependsOn asciidoctor
from file("$buildDir/docs/asciidoc")
into file("src/main/resources/static/docs")
}

build {
dependsOn copyDocument
}

test {
useJUnitPlatform()
outputs.dir snippetsDir
}
Comment on lines +39 to +73
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restdocs 관련된 설정들이 보여지는데, 어떤 것들인지 소개 해주실수 있을까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plugins {
id 'org.asciidoctor.jvm.convert' version '3.3.2'
}
: AsciiDoc 파일을 다른 형식으로 변환하는 기능을 제공하는 기능입니다.

ext {
snippetsDir = file('build/generated-snippets')
}
: Gradle 빌드 스크립트에서 ext 블록을 사용하여 snippetsDir라는 확장 속성을 정의하는 부분입니다. 코드 스니펫, 테스트 결과 또는 문서의 일부 등이 여기에 저장될 수 있습니다.

asciidoctor {
inputs.dir snippetsDir
configurations 'asciidoctorExt'
dependsOn test
}
: asciidoctor는 AsciiDoctor 플러그인의 설정 블록을 지칭합니다.

inputs.dir snippetsDir: 여기서 snippetsDir은 앞서 정의한 디렉토리 경로를 참조하며, AsciiDoctor에게 입력으로 제공될 디렉토리를 설정합니다. AsciiDoctor 변환 작업에 이 디렉토리의 내용이 사용됩니다.

configurations 'asciidoctorExt': 구성(configuration)을 설정합니다. AsciiDoctor 플러그인의 추가적인 확장 기능을 위한 설정입니다.

dependsOn test: 현재 설정된 작업이 테스트 작업(test)에 종속되어 있다는 것을 나타냅니다.

asciidoctor.doFirst {
delete file("src/main/resources/static/docs")
}
: doFirst는 특정 작업이 실행되기 전에 수행할 작업을 정의하는 Gradle의 메서드입니다. delete file("src/main/resources/static/docs")는 src/main/resources/static/docs 경로에 있는 파일 또는 디렉토리를 삭제하는 명령어입니다. 이 코드는 AsciiDoctor 변환 작업을 실행하기 전에 해당 경로에 있는 파일이나 디렉토리를 삭제하도록 합니다.

bootJar {
dependsOn asciidoctor
from("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
}
: bootJar는 Spring Boot 애플리케이션을 JAR 파일로 패키징하는 작업을 정의하는 부분입니다.

dependsOn asciidoctor: bootJar 작업이 asciidoctor 작업에 종속되어 있다는 것을 나타냅니다. 따라서 asciidoctor 작업이 먼저 실행된 후에 bootJar 작업이 실행됩니다.

from("${asciidoctor.outputDir}/html5"): AsciiDoctor의 출력 디렉토리에서 HTML5로 된 결과물을 가져오도록 설정합니다.

into 'static/docs': 가져온 HTML5 결과물을 static/docs 디렉토리에 넣도록 설정하고 있습니다.

task copyDocument(type: Copy) {
dependsOn asciidoctor
from file("$buildDir/docs/asciidoc")
into file("src/main/resources/static/docs")
}
: Copy 유형의 작업으로 정의되어 있으며, 다른 작업인 asciidoctor에 의존하고 있습니다. dependsOn asciidoctor 라인은 asciidoctor 작업이 먼저 실행된 후에 copyDocument 작업이 실행되어야 함을 의미합니다. AsciiDoc 문서가 있는 디렉토리("$buildDir/docs/asciidoc")에서 파일을 가져와서(from) src/main/resources/static/docs 디렉토리로 복사(into)하는 것으로 보입니다.

build {
dependsOn copyDocument
}
: build 단계가 copyDocument 작업이 완료된 후에 실행될 것임을 의미합니다.

test {
useJUnitPlatform()
outputs.dir snippetsDir
}
: outputs.dir snippetsDir는 테스트 작업이 완료된 후 생성된 결과물이나 출력물을 snippetsDir 디렉토리로 저장하도록 합니다. snippetsDir은 출력 디렉토리를 나타내며, 테스트가 생성하는 어떤 산출물을 저장하는 데 사용됩니다.




tasks.named('bootBuildImage') {
builder = 'paketobuildpacks/builder-jammy-base:latest'
}

tasks.named('test') {
useJUnitPlatform()
}
13 changes: 13 additions & 0 deletions board/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: '3'

services:
mysql:
image: mysql:latest
container_name: board
environment:
MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE: board
MYSQL_CHARSET: utf8mb4
MYSQL_COLLATION: utf8mb4_unicode_ci
ports:
- "3307:3306"
Binary file added board/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions board/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading