Skip to content

Commit

Permalink
Add spotless (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
AfigAliyev committed Aug 10, 2022
1 parent b6a9781 commit 304b8ac
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
22 changes: 20 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.spotless)
alias(libs.plugins.detekt)
}

Expand All @@ -38,6 +39,23 @@ tasks.withType<io.gitlab.arturbosch.detekt.Detekt>().configureEach {
exclude("config/**")
}

tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
kotlin {
target("**/*.kt")
targetExclude("build/**/*.kt", "**/build/**/*.kt", "config/**/*.kt")
licenseHeaderFile(rootProject.file("config/spotless/copyright.kt"))
}
kotlinGradle {
target("**/*.gradle.kts")
targetExclude("build/**/*.gradle.kts", "**/build/**/*.gradle.kts")
licenseHeaderFile(
rootProject.file("config/spotless/copyright.kt"),
"(plugins |pluginManagement |import |@file)"
)
}
format("xml") {
target("**/*.xml")
targetExclude("build/**/*.xml", "**/build/**/*.xml", "config/**/*.xml")
licenseHeaderFile(rootProject.file("config/spotless/copyright.xml"), "(<[^!?])")
}
}
16 changes: 16 additions & 0 deletions config/spotless/copyright.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright $YEAR Maximillian Leonov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

16 changes: 16 additions & 0 deletions config/spotless/copyright.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright $YEAR Maximillian Leonov
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
kotlin = "1.7.10"
android-gradle-plugin = "7.2.2"
spotless = "6.9.1"
detekt = "1.21.0"
kode-detekt-rules-compose = "1.1.0"

Expand Down Expand Up @@ -46,4 +47,5 @@ debug = ["androidx-compose-ui-tooling", "androidx-compose-ui-test-manifest"]
android-application = { id = "com.android.application", version.ref = "android-gradle-plugin" }
android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }

0 comments on commit 304b8ac

Please sign in to comment.