Skip to content

Commit

Permalink
Merge pull request #3 from cyberagent-zemi/atsushi/ktlint
Browse files Browse the repository at this point in the history
Ktlintの設定
  • Loading branch information
mori-atsushi committed Jun 24, 2021
2 parents 94790ee + f94087c commit fd662cb
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*]
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
31 changes: 31 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/ktlint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ allprojects {
}
}

subprojects {
apply(from = "$rootDir/config/ktlint.gradle.kts")

repositories {
google()
mavenCentral()
}
}

tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/Deps.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Deps {
const val ktlint = "com.pinterest:ktlint:${Versions.ktlint}"
}
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Versions {
const val ktlint = "0.41.0"
}
32 changes: 32 additions & 0 deletions config/ktlint.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
val ktlint by configurations.creating

dependencies {
ktlint(Deps.ktlint) {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
}
}

val outputDir = "${project.buildDir}/reports/ktlint/"
val inputFiles = project.fileTree(mapOf("dir" to "src", "include" to "**/*.kt"))

val ktlintCheck by tasks.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 tasks.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")
}
2 changes: 1 addition & 1 deletion samples/android-sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ dependencies {
implementation(kotlin("stdlib"))

implementation(project(":katalog"))
}
}

0 comments on commit fd662cb

Please sign in to comment.