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

chore: 코딩 컨벤션 설정을 위한 Spotless 세팅 #14

Merged
merged 8 commits into from
Jan 27, 2024
Merged
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
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() {}
}
Loading