From c6f3a397ef35db20f1cdbad9e507e79bf9f0f010 Mon Sep 17 00:00:00 2001 From: Jaehyun Ahn <91878695+uwoobeat@users.noreply.github.com> Date: Sat, 27 Jan 2024 16:48:06 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EC=BD=94=EB=94=A9=20=EC=BB=A8?= =?UTF-8?q?=EB=B2=A4=EC=85=98=20=EC=84=A4=EC=A0=95=EC=9D=84=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20Spotless=20=EC=84=B8=ED=8C=85=20(#14)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: plain jar 생성되지 않도록 변경 * chore: spotless 추가 및 설정 * style: spotless 포맷팅 적용 * chore: 커밋 전 spotless 적용을 위한 pre-commit 작성 * docs: CODEOWNER 변경 * chore: palantir java format 사용하도록 변경 * style: spotless 적용 --- .github/CODEOWNERS | 2 +- .../\342\231\273\357\270\217-refactor.md" | 2 +- .../\342\232\231\357\270\217-chore.md" | 2 +- ".github/ISSUE_TEMPLATE/\342\234\205-test.md" | 2 +- .../ISSUE_TEMPLATE/\342\234\250-feature.md" | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 6 +- .../workflows/pull_request_gradle_build.yml | 2 +- build.gradle | 79 +++++++++++++------ scripts/pre-commit | 14 ++++ .../com/gdschongik/gdsc/GdscApplication.java | 6 +- .../gdschongik/gdsc/GdscApplicationTests.java | 6 +- 11 files changed, 81 insertions(+), 42 deletions(-) create mode 100644 scripts/pre-commit diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c847e4068..95f197770 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -@GDSC-Hongik/backend-dev +* @GDSC-Hongik/backend-dev diff --git "a/.github/ISSUE_TEMPLATE/\342\231\273\357\270\217-refactor.md" "b/.github/ISSUE_TEMPLATE/\342\231\273\357\270\217-refactor.md" index e162a0bec..88bc4565e 100644 --- "a/.github/ISSUE_TEMPLATE/\342\231\273\357\270\217-refactor.md" +++ "b/.github/ISSUE_TEMPLATE/\342\231\273\357\270\217-refactor.md" @@ -8,4 +8,4 @@ assignees: '' --- ## 📌 Description -- +- diff --git "a/.github/ISSUE_TEMPLATE/\342\232\231\357\270\217-chore.md" "b/.github/ISSUE_TEMPLATE/\342\232\231\357\270\217-chore.md" index cb9dcf837..ae4a239a4 100644 --- "a/.github/ISSUE_TEMPLATE/\342\232\231\357\270\217-chore.md" +++ "b/.github/ISSUE_TEMPLATE/\342\232\231\357\270\217-chore.md" @@ -8,4 +8,4 @@ assignees: '' --- ## 📌 Description -- +- diff --git "a/.github/ISSUE_TEMPLATE/\342\234\205-test.md" "b/.github/ISSUE_TEMPLATE/\342\234\205-test.md" index d2574fca4..8227bee86 100644 --- "a/.github/ISSUE_TEMPLATE/\342\234\205-test.md" +++ "b/.github/ISSUE_TEMPLATE/\342\234\205-test.md" @@ -8,4 +8,4 @@ assignees: '' --- ## 📌 Description -- +- diff --git "a/.github/ISSUE_TEMPLATE/\342\234\250-feature.md" "b/.github/ISSUE_TEMPLATE/\342\234\250-feature.md" index 08842a612..23b437e9e 100644 --- "a/.github/ISSUE_TEMPLATE/\342\234\250-feature.md" +++ "b/.github/ISSUE_TEMPLATE/\342\234\250-feature.md" @@ -8,4 +8,4 @@ assignees: '' --- ## 📌 Description -- +- diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 68f377c47..187a45fde 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -2,10 +2,10 @@ - close # ## 📌 작업 내용 및 특이사항 -- +- ## 📝 참고사항 -- +- ## 📚 기타 -- +- diff --git a/.github/workflows/pull_request_gradle_build.yml b/.github/workflows/pull_request_gradle_build.yml index db5b331d0..1dda5e788 100644 --- a/.github/workflows/pull_request_gradle_build.yml +++ b/.github/workflows/pull_request_gradle_build.yml @@ -20,7 +20,7 @@ jobs: - name: gradlew 권한 부여 run: chmod +x ./gradlew - + - name: Gradle Build uses: gradle/gradle-build-action@v2 with: diff --git a/build.gradle b/build.gradle index c76ec6058..5a7430182 100644 --- a/build.gradle +++ b/build.gradle @@ -1,52 +1,79 @@ plugins { - id 'java' - id 'org.springframework.boot' version '3.2.1' - id 'io.spring.dependency-management' version '1.1.4' - id 'org.asciidoctor.jvm.convert' version '3.3.2' + id 'java' + id 'org.springframework.boot' version '3.2.1' + id 'io.spring.dependency-management' version '1.1.4' + id 'org.asciidoctor.jvm.convert' version '3.3.2' + id 'com.diffplug.spotless' version '6.23.3' } group = 'com.gdschongik' version = '0.0.1-SNAPSHOT' java { - sourceCompatibility = '17' + sourceCompatibility = '17' } configurations { - compileOnly { - extendsFrom annotationProcessor - } + compileOnly { + extendsFrom annotationProcessor + } } repositories { - mavenCentral() + mavenCentral() } ext { - set('snippetsDir', file("build/generated-snippets")) + set('snippetsDir', file("build/generated-snippets")) } dependencies { - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'org.springframework.boot:spring-boot-starter-web' - compileOnly 'org.projectlombok:lombok' - runtimeOnly 'com.h2database:h2' - runtimeOnly 'com.mysql:mysql-connector-j' - annotationProcessor 'org.projectlombok:lombok' - testImplementation 'org.springframework.boot:spring-boot-starter-test' - testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' - testImplementation 'org.springframework.security:spring-security-test' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-web' + compileOnly 'org.projectlombok:lombok' + runtimeOnly 'com.h2database:h2' + runtimeOnly 'com.mysql:mysql-connector-j' + annotationProcessor 'org.projectlombok:lombok' + testImplementation 'org.springframework.boot:spring-boot-starter-test' + testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc' + testImplementation 'org.springframework.security:spring-security-test' } tasks.named('test') { - outputs.dir snippetsDir - useJUnitPlatform() + outputs.dir snippetsDir + useJUnitPlatform() } tasks.named('asciidoctor') { - inputs.dir snippetsDir - dependsOn test + inputs.dir snippetsDir + dependsOn test +} + +jar { + enabled = false +} + +spotless { + format 'misc', { + target '**/*.yml', '**/*.gradle', '**/*.md' + trimTrailingWhitespace() + indentWithSpaces(4) + endWithNewline() + } + + java { + removeUnusedImports() + palantirJavaFormat() + formatAnnotations() + } +} + +tasks.register('updateGitHooks', Copy) { + from './scripts/pre-commit' + into '.git/hooks' + + compileJava.dependsOn(this) } diff --git a/scripts/pre-commit b/scripts/pre-commit new file mode 100644 index 000000000..3783ed295 --- /dev/null +++ b/scripts/pre-commit @@ -0,0 +1,14 @@ +# 변경된 파일들 이름만 추출하여 저장 +stagedFiles=$(git diff --staged --name-only) + +# SpotlessApply 실행 +echo "Running spotlessApply. Formatting code..." +./gradlew spotlessApply + +# 변경사항이 발생한 파일들 다시 git add +for file in $stagedFiles; do + if test -f "$file"; then + git add "$file" + fi +done + diff --git a/src/main/java/com/gdschongik/gdsc/GdscApplication.java b/src/main/java/com/gdschongik/gdsc/GdscApplication.java index 02f7de3a0..be1268410 100644 --- a/src/main/java/com/gdschongik/gdsc/GdscApplication.java +++ b/src/main/java/com/gdschongik/gdsc/GdscApplication.java @@ -6,7 +6,7 @@ @SpringBootApplication public class GdscApplication { - public static void main(String[] args) { - SpringApplication.run(GdscApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(GdscApplication.class, args); + } } diff --git a/src/test/java/com/gdschongik/gdsc/GdscApplicationTests.java b/src/test/java/com/gdschongik/gdsc/GdscApplicationTests.java index da37566af..1e73666e7 100644 --- a/src/test/java/com/gdschongik/gdsc/GdscApplicationTests.java +++ b/src/test/java/com/gdschongik/gdsc/GdscApplicationTests.java @@ -6,8 +6,6 @@ @SpringBootTest class GdscApplicationTests { - @Test - void contextLoads() { - } - + @Test + void contextLoads() {} }