Skip to content

Commit

Permalink
chore: 코딩 컨벤션 설정을 위한 Spotless 세팅 (#14)
Browse files Browse the repository at this point in the history
* chore: plain jar 생성되지 않도록 변경

* chore: spotless 추가 및 설정

* style: spotless 포맷팅 적용

* chore: 커밋 전 spotless 적용을 위한 pre-commit 작성

* docs: CODEOWNER 변경

* chore: palantir java format 사용하도록 변경

* style: spotless 적용
  • Loading branch information
uwoobeat authored Jan 27, 2024
1 parent 734e690 commit c6f3a39
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
@GDSC-Hongik/backend-dev
* @GDSC-Hongik/backend-dev
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/♻️-refactor.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ assignees: ''
---

## 📌 Description
-
-
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/⚙️-chore.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ assignees: ''
---

## 📌 Description
-
-
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/✅-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ assignees: ''
---

## 📌 Description
-
-
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/✨-feature.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ assignees: ''
---

## 📌 Description
-
-
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
- close #

## 📌 작업 내용 및 특이사항
-
-

## 📝 참고사항
-
-

## 📚 기타
-
-
2 changes: 1 addition & 1 deletion .github/workflows/pull_request_gradle_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- name: gradlew 권한 부여
run: chmod +x ./gradlew

- name: Gradle Build
uses: gradle/gradle-build-action@v2
with:
Expand Down
79 changes: 53 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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)
}
14 changes: 14 additions & 0 deletions scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -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

6 changes: 3 additions & 3 deletions src/main/java/com/gdschongik/gdsc/GdscApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
6 changes: 2 additions & 4 deletions src/test/java/com/gdschongik/gdsc/GdscApplicationTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
@SpringBootTest
class GdscApplicationTests {

@Test
void contextLoads() {
}

@Test
void contextLoads() {}
}

0 comments on commit c6f3a39

Please sign in to comment.