-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Move Spotless configurations from buildscripts/init.gradle.kts to build.gradle.kts #1549
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
Changes from all commits
4ce0e24
27a033f
b7396ac
1eecdba
40d4d89
c572c92
d4cd209
75ad3bc
cd9b613
d93f228
59f2ba2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,53 @@ plugins { | |
alias(libs.plugins.kotlin.android) apply false | ||
alias(libs.plugins.kotlin.parcelize) apply false | ||
alias(libs.plugins.compose) apply false | ||
alias(libs.plugins.spotless) apply false | ||
} | ||
|
||
apply("${project.rootDir}/buildscripts/toml-updater-config.gradle") | ||
|
||
subprojects { | ||
apply(plugin = "com.diffplug.spotless") | ||
configure<com.diffplug.gradle.spotless.SpotlessExtension> { | ||
ratchetFrom = "origin/main" | ||
kotlin { | ||
target("**/*.kt") | ||
targetExclude("**/build/**/*.kt") | ||
ktlint().editorConfigOverride( | ||
mapOf( | ||
"ktlint_code_style" to "android_studio", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"ij_kotlin_allow_trailing_comma" to true, | ||
"ktlint_function_naming_ignore_when_annotated_with" to "Composable", | ||
// These rules were introduced in ktlint 0.46.0 and should not be | ||
// enabled without further discussion. They are disabled for now. | ||
// See: https://github.com/pinterest/ktlint/releases/tag/0.46.0 | ||
"disabled_rules" to | ||
"filename," + | ||
"annotation,annotation-spacing," + | ||
"argument-list-wrapping," + | ||
"double-colon-spacing," + | ||
"enum-entry-name-case," + | ||
"multiline-if-else," + | ||
"no-empty-first-line-in-method-block," + | ||
"package-name," + | ||
"trailing-comma," + | ||
"spacing-around-angle-brackets," + | ||
"spacing-between-declarations-with-annotations," + | ||
"spacing-between-declarations-with-comments," + | ||
"unary-op-spacing" | ||
) | ||
) | ||
licenseHeaderFile(rootProject.file("spotless/copyright.kt")) | ||
} | ||
format("kts") { | ||
target("**/*.kts") | ||
targetExclude("**/build/**/*.kts") | ||
// Look for the first line that doesn't have a block comment (assumed to be the license) | ||
licenseHeaderFile(rootProject.file("spotless/copyright.kt"), "(^(?![\\/ ]\\*).*$)") | ||
} | ||
kotlinGradle { | ||
target("*.gradle.kts") | ||
ktlint() | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,53 @@ plugins { | |
alias(libs.plugins.kotlin.android) apply false | ||
alias(libs.plugins.kotlin.parcelize) apply false | ||
alias(libs.plugins.compose) apply false | ||
alias(libs.plugins.spotless) apply false | ||
} | ||
|
||
apply("${project.rootDir}/buildscripts/toml-updater-config.gradle") | ||
|
||
subprojects { | ||
apply(plugin = "com.diffplug.spotless") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
configure<com.diffplug.gradle.spotless.SpotlessExtension> { | ||
ratchetFrom = "origin/main" | ||
kotlin { | ||
target("**/*.kt") | ||
targetExclude("**/build/**/*.kt") | ||
ktlint().editorConfigOverride( | ||
mapOf( | ||
"ktlint_code_style" to "android_studio", | ||
cartland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"ij_kotlin_allow_trailing_comma" to true, | ||
"ktlint_function_naming_ignore_when_annotated_with" to "Composable", | ||
// These rules were introduced in ktlint 0.46.0 and should not be | ||
// enabled without further discussion. They are disabled for now. | ||
// See: https://github.com/pinterest/ktlint/releases/tag/0.46.0 | ||
"disabled_rules" to | ||
"filename," + | ||
"annotation,annotation-spacing," + | ||
"argument-list-wrapping," + | ||
"double-colon-spacing," + | ||
"enum-entry-name-case," + | ||
"multiline-if-else," + | ||
"no-empty-first-line-in-method-block," + | ||
"package-name," + | ||
"trailing-comma," + | ||
"spacing-around-angle-brackets," + | ||
"spacing-between-declarations-with-annotations," + | ||
"spacing-between-declarations-with-comments," + | ||
"unary-op-spacing" | ||
) | ||
) | ||
licenseHeaderFile(rootProject.file("spotless/copyright.kt")) | ||
} | ||
format("kts") { | ||
target("**/*.kts") | ||
targetExclude("**/build/**/*.kts") | ||
// Look for the first line that doesn't have a block comment (assumed to be the license) | ||
licenseHeaderFile(rootProject.file("spotless/copyright.kt"), "(^(?![\\/ ]\\*).*$)") | ||
} | ||
kotlinGradle { | ||
target("*.gradle.kts") | ||
ktlint() | ||
} | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,53 @@ plugins { | |
alias(libs.plugins.hilt) apply false | ||
alias(libs.plugins.ksp) apply false | ||
alias(libs.plugins.compose) apply false | ||
alias(libs.plugins.spotless) apply false | ||
} | ||
|
||
apply("${project.rootDir}/buildscripts/toml-updater-config.gradle") | ||
|
||
subprojects { | ||
apply(plugin = "com.diffplug.spotless") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
configure<com.diffplug.gradle.spotless.SpotlessExtension> { | ||
ratchetFrom = "origin/main" | ||
kotlin { | ||
target("**/*.kt") | ||
targetExclude("**/build/**/*.kt") | ||
ktlint().editorConfigOverride( | ||
mapOf( | ||
"ktlint_code_style" to "android_studio", | ||
cartland marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"ij_kotlin_allow_trailing_comma" to true, | ||
"ktlint_function_naming_ignore_when_annotated_with" to "Composable", | ||
// These rules were introduced in ktlint 0.46.0 and should not be | ||
// enabled without further discussion. They are disabled for now. | ||
// See: https://github.com/pinterest/ktlint/releases/tag/0.46.0 | ||
"disabled_rules" to | ||
"filename," + | ||
"annotation,annotation-spacing," + | ||
"argument-list-wrapping," + | ||
"double-colon-spacing," + | ||
"enum-entry-name-case," + | ||
"multiline-if-else," + | ||
"no-empty-first-line-in-method-block," + | ||
"package-name," + | ||
"trailing-comma," + | ||
"spacing-around-angle-brackets," + | ||
"spacing-between-declarations-with-annotations," + | ||
"spacing-between-declarations-with-comments," + | ||
"unary-op-spacing" | ||
) | ||
) | ||
licenseHeaderFile(rootProject.file("spotless/copyright.kt")) | ||
} | ||
format("kts") { | ||
target("**/*.kts") | ||
targetExclude("**/build/**/*.kts") | ||
// Look for the first line that doesn't have a block comment (assumed to be the license) | ||
licenseHeaderFile(rootProject.file("spotless/copyright.kt"), "(^(?![\\/ ]\\*).*$)") | ||
} | ||
kotlinGradle { | ||
target("*.gradle.kts") | ||
ktlint() | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin is already applied at the top level, so this
apply
call is redundant and can be removed to simplify the configuration.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct because I want to apply the plugin to the
subprojects
. @bentrengrove do you see any optimization I can make?