Skip to content

Instantly share code, notes, and snippets.

@soulduse
Created December 13, 2020 03:13
Show Gist options
  • Save soulduse/54e3c95f256e0ba95ca099290e910417 to your computer and use it in GitHub Desktop.
Save soulduse/54e3c95f256e0ba95ca099290e910417 to your computer and use it in GitHub Desktop.
Root Gradle 설정
val projectGroup: String by project
val projectVersion: String by project
val kotlinVersion: String by project
val ktlintVersion: String by project
plugins {
val kotlinVersion = "1.4.10"
kotlin("jvm") version kotlinVersion
kotlin("kapt") version kotlinVersion
}
allprojects {
group = projectGroup
version = projectVersion
repositories {
jcenter()
mavenCentral()
}
}
subprojects {
apply {
plugin("kotlin")
}
val ktlint by configurations.creating
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
ktlint("com.pinterest:ktlint:$ktlintVersion")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks {
val outputDir = "${project.buildDir}/reports/ktlint"
val inputFiles = project.fileTree(mapOf("dir" to "src", "include" to "**/*.kt"))
val ktlintCheck by creating(JavaExec::class) {
inputs.files(inputFiles)
outputs.dir(outputDir)
description = "Check Kotlin code style."
classpath = ktlint
main = "com.pinterest.ktlint.Main"
args = listOf("src/**/*.kt")
}
val ktlintFormat by creating(JavaExec::class) {
inputs.files(inputFiles)
outputs.dir(outputDir)
description = "Fix Kotlin code style deviations."
classpath = ktlint
main = "com.pinterest.ktlint.Main"
args = listOf("-F", "src/**/*.kt")
}
}
}
@soulduse
Copy link
Author

ktlint를 사용하는 이유는 좀더 깔끔한 코드 관리를 위해 사용하게 되었습니다.
불필요한 쓰레기 코드가 남는것을 방지하고, 코드 스타일(린트)를 통일 하기 위해 사용합니다.
https://github.com/pinterest/ktlint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment